libquicktime-1.2.4/0000755000175000017500000000000011735135732011210 500000000000000libquicktime-1.2.4/m4/0000755000175000017500000000000011735135732011530 500000000000000libquicktime-1.2.4/m4/lqt_opt_cflags.m40000644000175000017500000000461510463377277014732 00000000000000# # Automatic OPT_CFLAGS generation by Burkhard Plaum (2005-05-24) # dnl LQT_TRY_CFLAGS (CFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS]) dnl check if $CC supports a given set of cflags AC_DEFUN([LQT_TRY_CFLAGS], [AC_MSG_CHECKING([if $CC supports $1 flags]) SAVE_CFLAGS="$CFLAGS" CFLAGS="$1" AC_TRY_COMPILE([],[],[lqt_try_cflags_ok=yes],[lqt_try_cflags_ok=no]) CFLAGS="$SAVE_CFLAGS" AC_MSG_RESULT([$lqt_try_cflags_ok]) if test x"$lqt_try_cflags_ok" = x"yes"; then ifelse([$2],[],[:],[$2]) else ifelse([$3],[],[:],[$3]) fi]) dnl LQT_OPT_CFLAGS(CPU_TYPE [, ADDITIONAL_OPT_FLAGS]) dnl Get proper optimization flags. dnl dnl CPU_TYPE: host_cpu variable as obtained from AC_CANONICAL_HOST dnl ADDITIONAL_OPT_FLAGS: Additional optimization flags (e.g. -O3 --fast-math) dnl On output, the Variable LQT_OPT_CFLAGS will be set to the compiler flags dnl Furthermore, is debuggind was requested, the variable LQT_DEBUG will be dnl set to "true" AC_DEFUN([LQT_OPT_CFLAGS],[ dnl dnl Debugging Support dnl LQT_DEBUG=false AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug],[Enable debugging, disable optimization])], [case "${enableval}" in yes) LQT_DEBUG=true ;; no) LQT_DEBUG=false ;; esac],[LQT_DEBUG=false]) dnl dnl Extra cflags from the commandline. Can have the special values "none" or "auto" dnl AC_ARG_WITH(cpuflags, AC_HELP_STRING([--with-cpuflags],[Set CPU specific compiler flags. Default is auto, which does autodetection. Specify none for compiling the most portable binaries]), lqt_cpuflags="$withval", lqt_cpuflags="auto") if test "x$lqt_cpuflags" = "xnone"; then lqt_cpuflags="" fi dnl dnl Autodetect CPU specific flags dnl if test "x$lqt_cpuflags" = "xauto"; then lqt_cpu_family="" case [$1] in i[[3-7]]86) lqt_cpu_family=x86;; x86_64*) lqt_cpu_family=x86;; powerpc | powerpc64) lqt_cpu_family=ppc;; *) lqt_cpu_family="";; esac if test x$lqt_cpu_family = x; then lqt_cpuflags="" else lqt_cpuflags=`$srcdir/cpuinfo.sh $lqt_cpu_family` fi fi dnl dnl Build the final flags dnl lqt_additional_opt_flags=ifelse([$2],[],[],[$2]) lqt_test_flags=$lqt_cpuflags if test x$LQT_DEBUG = xtrue; then lqt_test_cflags="$lqt_test_flags -g" else lqt_test_cflags="$lqt_test_flags $lqt_additional_opt_flags" fi OPT_CFLAGS="" for i in $lqt_test_cflags; do LQT_TRY_CFLAGS($i, OPT_CFLAGS="$OPT_CFLAGS $i") ; done ]) libquicktime-1.2.4/m4/ltsugar.m40000644000175000017500000001042411735135707013376 00000000000000# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 6 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59 which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. # Needed until we can rely on m4_combine added in Autoconf 2.62. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) libquicktime-1.2.4/m4/libtool.m40000644000175000017500000077464711735135706013410 00000000000000# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool 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. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ]) # serial 56 LT_INIT # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_CC_BASENAME(CC) # ------------------- # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. m4_defun([_LT_CC_BASENAME], [for cc_temp in $1""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl _LT_PROG_ECHO_BACKSLASH case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from `configure', and `config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # `config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain="$ac_aux_dir/ltmain.sh" ])# _LT_PROG_LTMAIN ## ------------------------------------- ## ## Accumulate code for creating libtool. ## ## ------------------------------------- ## # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the `libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) ## ------------------------ ## ## FIXME: Eliminate VARNAME ## ## ------------------------ ## # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [m4_assert([$# <= 2])dnl _$0(m4_quote(m4_default([$1], [[, ]])), m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) m4_define([_lt_decl_varnames_tagged], [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to `config.status' so that its # declaration there will have the same value as in `configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "X$" | $Xsed -e "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags="_LT_TAGS"dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the `libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into `config.status', and then the shell code to quote escape them in # for loops in `config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Fix-up fallback echo if it was mangled by the above quoting rules. case \$lt_ECHO in *'\\\[$]0 --fallback-echo"')dnl " lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\` ;; esac _LT_OUTPUT_LIBTOOL_INIT ]) # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) cat >"$CONFIG_LT" <<_LTEOF #! $SHELL # Generated by $as_me. # Run this file to recreate a libtool stub with the current configuration. lt_cl_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ \`$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2008 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test $[#] != 0 do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try \`$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try \`$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. if test "$no_create" != yes; then lt_cl_success=: test "$silent" = yes && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) fi ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # _LT_COPYING _LT_LIBTOOL_TAGS # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac _LT_PROG_LTMAIN # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) _LT_PROG_XSI_SHELLFNS sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[[012]]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES # -------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(whole_archive_flag_spec, $1)='' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=echo _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" m4_if([$1], [CXX], [ if test "$lt_cv_apple_cc_single_mod" != "yes"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX # ----------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl AC_LINK_IFELSE(AC_LANG_PROGRAM,[ lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/ p } }' aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [ifdef([AC_DIVERSION_NOTICE], [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], [AC_DIVERT_PUSH(NOTICE)]) $1 AC_DIVERT_POP ])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Add some code to the start of the generated configure script which # will find an echo command which doesn't interpret backslashes. m4_defun([_LT_PROG_ECHO_BACKSLASH], [_LT_SHELL_INIT([ # Check that we are running under the correct shell. SHELL=${CONFIG_SHELL-/bin/sh} case X$lt_ECHO in X*--fallback-echo) # Remove one level of quotation (which was required for Make). ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` ;; esac ECHO=${lt_ECHO-echo} if test "X[$]1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X[$]1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then # Yippee, $ECHO works! : else # Restart under the correct shell. exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} fi if test "X[$]1" = X--fallback-echo; then # used as fallback echo shift cat <<_LT_EOF [$]* _LT_EOF exit 0 fi # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test -z "$lt_ECHO"; then if test "X${echo_test_string+set}" != Xset; then # find a string as large as possible, as long as the shell can cope with it for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... if { echo_test_string=`eval $cmd`; } 2>/dev/null && { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null then break fi done fi if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then : else # The Solaris, AIX, and Digital Unix default echo programs unquote # backslashes. This makes it impossible to quote backslashes using # echo "$something" | sed 's/\\/\\\\/g' # # So, first we look for a working echo in the user's PATH. lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for dir in $PATH /usr/ucb; do IFS="$lt_save_ifs" if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then ECHO="$dir/echo" break fi done IFS="$lt_save_ifs" if test "X$ECHO" = Xecho; then # We didn't find a better echo, so look for alternatives. if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # This shell has a builtin print -r that does the trick. ECHO='print -r' elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && test "X$CONFIG_SHELL" != X/bin/ksh; then # If we have ksh, try running configure again with it. ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} export ORIGINAL_CONFIG_SHELL CONFIG_SHELL=/bin/ksh export CONFIG_SHELL exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} else # Try using printf. ECHO='printf %s\n' if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # Cool, printf works : elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL export CONFIG_SHELL SHELL="$CONFIG_SHELL" export SHELL ECHO="$CONFIG_SHELL [$]0 --fallback-echo" elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then ECHO="$CONFIG_SHELL [$]0 --fallback-echo" else # maybe with a smaller string... prev=: for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null then break fi prev="$cmd" done if test "$prev" != 'sed 50q "[$]0"'; then echo_test_string=`eval $prev` export echo_test_string exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} else # Oops. We lost completely, so just stick with echo. ECHO=echo fi fi fi fi fi fi # Copy echo and quote the copy suitably for passing to libtool from # the Makefile, instead of quoting the original, which is used later. lt_ECHO=$ECHO if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" fi AC_SUBST(lt_ECHO) ]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that does not interpret backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '[#]line __oline__ "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; sparc*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) LD="${LD-ld} -m elf64_sparc" ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" ])# _LT_ENABLE_LOCK # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [AC_CHECK_TOOL(AR, ar, false) test -z "$AR" && AR=ar test -z "$AR_FLAGS" && AR_FLAGS=cru _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1]) AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM conftest* ]) if test x"[$]$2" = xyes; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" ]) if test x"[$]$2" = xyes; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ = "XX$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n $lt_cv_sys_max_cmd_len ; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "$cross_compiling" = yes; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line __oline__ "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif void fnord() { int i=42;} int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) ]) ]) ]) ]) ]) ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links="nottested" if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test "$hard_links" = no; then AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", [Define to the sub-directory in which libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then # We can hardcode non-existent directories. if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` else lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[[4-9]]*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$host_os in yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH printed by # mingw gcc, but we are running on Cygwin. Gcc prints its search # path with ; separators, and with drive letters. We can handle the # drive letters (cygwin fileutils understands them), so leave them, # especially as we might pass files found there to a mingw objdump, # which wouldn't understand a cygwinified path. Ahh. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; esac ;; *) library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[123]]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555. postinstall_cmds='chmod 555 $lib' ;; interix[[3-9]]*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[[89]] | openbsd2.[[89]].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[List of archive names. First name is the real one, the rest are links. The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([], [sys_lib_dlsearch_path_spec], [2], [Run-time system search path for libraries]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program which can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$1; then lt_cv_path_MAGIC_CMD="$ac_dir/$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac]) MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program which can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test "$withval" = no || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method == "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi]) if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :) AC_SUBST([DUMPBIN]) if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM="-lm") ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ const struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_save_LIBS="$LIBS" lt_save_CFLAGS="$CFLAGS" LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS="$lt_save_LIBS" CFLAGS="$lt_save_CFLAGS" else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= AC_MSG_CHECKING([for $compiler option to produce PIC]) m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC*) # IBM XL 8.0 on PPC _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd* | netbsdelf*-gnu) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # Lahey Fortran 8.1. lf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; pgcc* | pgf77* | pgf90* | pgf95*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl*) # IBM XL C 8.0/Fortran 10.1 on PPC _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; *Sun\ F*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' ;; linux* | k*bsd*-gnu) _LT_TAGVAR(link_all_deplibs, $1)=no ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; linux* | k*bsd*-gnu) _LT_TAGVAR(link_all_deplibs, $1)=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes if test "$with_gnu_ld" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.9.1, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to modify your PATH *** so that a non-GNU linker is found, and then restart. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag= tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi _LT_TAGVAR(link_all_deplibs, $1)=no else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; freebsd1*) _LT_TAGVAR(ld_shlibs, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; hpux10*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test "$GCC" = yes -a "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" AC_LINK_IFELSE(int foo(void) {}, _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' ) LDFLAGS="$save_LDFLAGS" else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' else case $host_os in openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' ;; esac fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_MSG_CHECKING([whether -lc should be explicitly linked in]) $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then _LT_TAGVAR(archive_cmds_need_lc, $1)=no else _LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)]) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], [[If ld is used when linking, flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting ${shlibpath_var} if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [fix_srcfile_path], [1], [Fix the shell variable $srcfile for the compiler]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC="$CC" AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report which library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC="$lt_save_CC" ])# _LT_LANG_C_CONFIG # _LT_PROG_CXX # ------------ # Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++ # compiler, we have our own version here. m4_defun([_LT_PROG_CXX], [ pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes]) AC_PROG_CXX if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi popdef([AC_MSG_ERROR]) ])# _LT_PROG_CXX dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([_LT_PROG_CXX], []) # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [AC_REQUIRE([_LT_PROG_CXX])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared # libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd[[12]]*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; gnu*) ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 will use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; xl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='echo' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd2*) # C++ shared libraries are fairly broken _LT_TAGVAR(ld_shlibs, $1)=no ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=echo else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='echo' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(GCC, $1)="$GXX" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ]) dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case $p in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue else prev= fi if test "$pre_test_object_deps_done" = no; then case $p in -L* | -R*) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)="${prev}${p}" else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" fi fi ;; *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)="$p" else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)="$p" else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_PROG_F77 # ------------ # Since AC_PROG_F77 is broken, in that it returns the empty string # if there is no fortran compiler, we have our own version here. m4_defun([_LT_PROG_F77], [ pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes]) AC_PROG_F77 if test -z "$F77" || test "X$F77" = "Xno"; then _lt_disable_F77=yes fi popdef([AC_MSG_ERROR]) ])# _LT_PROG_F77 dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([_LT_PROG_F77], []) # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_REQUIRE([_LT_PROG_F77])dnl AC_LANG_PUSH(Fortran 77) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_F77" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC CC=${F77-"f77"} compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$G77" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC="$lt_save_CC" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_PROG_FC # ----------- # Since AC_PROG_FC is broken, in that it returns the empty string # if there is no fortran compiler, we have our own version here. m4_defun([_LT_PROG_FC], [ pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes]) AC_PROG_FC if test -z "$FC" || test "X$FC" = "Xno"; then _lt_disable_FC=yes fi popdef([AC_MSG_ERROR]) ])# _LT_PROG_FC dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([_LT_PROG_FC], []) # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_REQUIRE([_LT_PROG_FC])dnl AC_LANG_PUSH(Fortran) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_FC" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC CC=${FC-"f95"} compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC="$lt_save_CC" fi # test "$_lt_disable_FC" != yes AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC="$lt_save_CC" ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code="$lt_simple_compile_test_code" # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC GCC= CC=${RC-"windres"} compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC="$lt_save_CC" ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_OBJDUMP # -------------- # If we don't have a new enough Autoconf to choose the best objdump # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_OBJDUMP], [AC_CHECK_TOOL(OBJDUMP, objdump, false) test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f $lt_ac_sed && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test $lt_ac_count -gt 10 && break lt_ac_count=`expr $lt_ac_count + 1` if test $lt_ac_count -gt $lt_ac_max; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [AC_MSG_CHECKING([whether the shell understands some XSI constructs]) # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes AC_MSG_RESULT([$xsi_shell]) _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) AC_MSG_CHECKING([whether the shell understands "+="]) lt_shell_append=no ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes AC_MSG_RESULT([$lt_shell_append]) _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PROG_XSI_SHELLFNS # --------------------- # Bourne and XSI compatible variants of some useful shell functions. m4_defun([_LT_PROG_XSI_SHELLFNS], [case $xsi_shell in yes) cat << \_LT_EOF >> "$cfgfile" # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac } # func_basename file func_basename () { func_basename_result="${1##*/}" } # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}" } # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). func_stripname () { # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"} } # func_opt_split func_opt_split () { func_opt_split_opt=${1%%=*} func_opt_split_arg=${1#*=} } # func_lo2o object func_lo2o () { case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac } # func_xform libobj-or-source func_xform () { func_xform_result=${1%.*}.lo } # func_arith arithmetic-term... func_arith () { func_arith_result=$(( $[*] )) } # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=${#1} } _LT_EOF ;; *) # Bourne compatible functions. cat << \_LT_EOF >> "$cfgfile" # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_basename file func_basename () { func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` } dnl func_dirname_and_basename dnl A portable version of this function is already defined in general.m4sh dnl so there is no need for it here. # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "X${3}" \ | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "X${3}" \ | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; esac } # sed scripts: my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q' my_sed_long_arg='1s/^-[[^=]]*=//' # func_opt_split func_opt_split () { func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` } # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` } # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'` } # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "$[@]"` } # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len` } _LT_EOF esac case $lt_shell_append in yes) cat << \_LT_EOF >> "$cfgfile" # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "$[1]+=\$[2]" } _LT_EOF ;; *) cat << \_LT_EOF >> "$cfgfile" # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "$[1]=\$$[1]\$[2]" } _LT_EOF ;; esac ]) libquicktime-1.2.4/m4/ltversion.m40000644000175000017500000000127711735135707013750 00000000000000# ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # Generated from ltversion.in. # serial 3017 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.2.6b]) m4_define([LT_PACKAGE_REVISION], [1.3017]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.2.6b' macro_revision='1.3017' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) libquicktime-1.2.4/m4/nls.m40000644000175000017500000000226611566403572012516 00000000000000# nls.m4 serial 3 (gettext-0.15) dnl Copyright (C) 1995-2003, 2005-2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl This file can can be used in projects which are not available under dnl the GNU General Public License or the GNU Library General Public dnl License but which still want to provide support for the GNU gettext dnl functionality. dnl Please note that the actual code of the GNU gettext library is covered dnl by the GNU Library General Public License, and the rest of the GNU dnl gettext package package is covered by the GNU General Public License. dnl They are *not* in the public domain. dnl Authors: dnl Ulrich Drepper , 1995-2000. dnl Bruno Haible , 2000-2003. AC_PREREQ(2.50) AC_DEFUN([AM_NLS], [ AC_MSG_CHECKING([whether NLS is requested]) dnl Default is enabled NLS AC_ARG_ENABLE(nls, [ --disable-nls do not use Native Language Support], USE_NLS=$enableval, USE_NLS=yes) AC_MSG_RESULT($USE_NLS) AC_SUBST(USE_NLS) ]) libquicktime-1.2.4/m4/iconv.m40000644000175000017500000001375311566403572013043 00000000000000# iconv.m4 serial AM6 (gettext-0.17) dnl Copyright (C) 2000-2002, 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], [ dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV dnl accordingly. AC_LIB_LINKFLAGS_BODY([iconv]) ]) AC_DEFUN([AM_ICONV_LINK], [ dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and dnl those with the standalone portable GNU libiconv installed). AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV dnl accordingly. AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) dnl Add $INCICONV to CPPFLAGS before performing the following checks, dnl because if the user has installed libiconv and not disabled its use dnl via --without-libiconv-prefix, he wants to use it. The first dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. am_save_CPPFLAGS="$CPPFLAGS" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) AC_CACHE_CHECK([for iconv], am_cv_func_iconv, [ am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no AC_TRY_LINK([#include #include ], [iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd);], am_cv_func_iconv=yes) if test "$am_cv_func_iconv" != yes; then am_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" AC_TRY_LINK([#include #include ], [iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd);], am_cv_lib_iconv=yes am_cv_func_iconv=yes) LIBS="$am_save_LIBS" fi ]) if test "$am_cv_func_iconv" = yes; then AC_CACHE_CHECK([for working iconv], am_cv_func_iconv_works, [ dnl This tests against bugs in AIX 5.1 and HP-UX 11.11. am_save_LIBS="$LIBS" if test $am_cv_lib_iconv = yes; then LIBS="$LIBS $LIBICONV" fi AC_TRY_RUN([ #include #include int main () { /* Test against AIX 5.1 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); if (cd_utf8_to_88591 != (iconv_t)(-1)) { static const char input[] = "\342\202\254"; /* EURO SIGN */ char buf[10]; const char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_utf8_to_88591, (char **) &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) return 1; } } #if 0 /* This bug could be worked around by the caller. */ /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ { iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; char buf[50]; const char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_88591_to_utf8, (char **) &inptr, &inbytesleft, &outptr, &outbytesleft); if ((int)res > 0) return 1; } } #endif /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is provided. */ if (/* Try standardized names. */ iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) /* Try IRIX, OSF/1 names. */ && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) /* Try AIX names. */ && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) /* Try HP-UX names. */ && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) return 1; return 0; }], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no], [case "$host_os" in aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; *) am_cv_func_iconv_works="guessing yes" ;; esac]) LIBS="$am_save_LIBS" ]) case "$am_cv_func_iconv_works" in *no) am_func_iconv=no am_cv_lib_iconv=no ;; *) am_func_iconv=yes ;; esac else am_func_iconv=no am_cv_lib_iconv=no fi if test "$am_func_iconv" = yes; then AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function and it works.]) fi if test "$am_cv_lib_iconv" = yes; then AC_MSG_CHECKING([how to link with libiconv]) AC_MSG_RESULT([$LIBICONV]) else dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV dnl either. CPPFLAGS="$am_save_CPPFLAGS" LIBICONV= LTLIBICONV= fi AC_SUBST(LIBICONV) AC_SUBST(LTLIBICONV) ]) AC_DEFUN([AM_ICONV], [ AM_ICONV_LINK if test "$am_cv_func_iconv" = yes; then AC_MSG_CHECKING([for iconv declaration]) AC_CACHE_VAL(am_cv_proto_iconv, [ AC_TRY_COMPILE([ #include #include extern #ifdef __cplusplus "C" #endif #if defined(__STDC__) || defined(__cplusplus) size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); #else size_t iconv(); #endif ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` AC_MSG_RESULT([$]{ac_t:- }[$]am_cv_proto_iconv) AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, [Define as const if the declaration of iconv() needs const.]) fi ]) libquicktime-1.2.4/m4/lib-ld.m40000644000175000017500000000653111566403572013064 00000000000000# lib-ld.m4 serial 3 (gettext-0.13) dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl Subroutines of libtool.m4, dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision dnl with libtool.m4. dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. AC_DEFUN([AC_LIB_PROG_LD_GNU], [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld, [# I'd rather use --version here, but apparently some GNU ld's only accept -v. case `$LD -v 2>&1 conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by GCC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]* | [A-Za-z]:[\\/]*)] [re_direlt='/[^/][^/]*/\.\./'] # Canonicalize the path of ld ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(acl_cv_path_LD, [if test -z "$LD"; then IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then acl_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some GNU ld's only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in *GNU* | *'with BFD'*) test "$with_gnu_ld" != no && break ;; *) test "$with_gnu_ld" != yes && break ;; esac fi done IFS="$ac_save_ifs" else acl_cv_path_LD="$LD" # Let the user override the test with a path. fi]) LD="$acl_cv_path_LD" if test -n "$LD"; then AC_MSG_RESULT($LD) else AC_MSG_RESULT(no) fi test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) AC_LIB_PROG_LD_GNU ]) libquicktime-1.2.4/m4/lt~obsolete.m40000644000175000017500000001311311735135707014265 00000000000000# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 4 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us # using a macro with the same name in our local m4/libtool.m4 it'll # pull the old libtool.m4 in (it doesn't see our shiny new m4_define # and doesn't know about Autoconf macros at all.) # # So we provide this file, which has a silly filename so it's always # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until # we give up compatibility with versions before 1.7, at which point # we need to keep only those names which we still refer to. # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) libquicktime-1.2.4/m4/gettext.m40000644000175000017500000003457011566403572013411 00000000000000# gettext.m4 serial 60 (gettext-0.17) dnl Copyright (C) 1995-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl This file can can be used in projects which are not available under dnl the GNU General Public License or the GNU Library General Public dnl License but which still want to provide support for the GNU gettext dnl functionality. dnl Please note that the actual code of the GNU gettext library is covered dnl by the GNU Library General Public License, and the rest of the GNU dnl gettext package package is covered by the GNU General Public License. dnl They are *not* in the public domain. dnl Authors: dnl Ulrich Drepper , 1995-2000. dnl Bruno Haible , 2000-2006. dnl Macro to add for using GNU gettext. dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]). dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The dnl default (if it is not specified or empty) is 'no-libtool'. dnl INTLSYMBOL should be 'external' for packages with no intl directory, dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory. dnl If INTLSYMBOL is 'use-libtool', then a libtool library dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static, dnl depending on --{enable,disable}-{shared,static} and on the presence of dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library dnl $(top_builddir)/intl/libintl.a will be created. dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext dnl implementations (in libc or libintl) without the ngettext() function dnl will be ignored. If NEEDSYMBOL is specified and is dnl 'need-formatstring-macros', then GNU gettext implementations that don't dnl support the ISO C 99 formatstring macros will be ignored. dnl INTLDIR is used to find the intl libraries. If empty, dnl the value `$(top_builddir)/intl/' is used. dnl dnl The result of the configuration is one of three cases: dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled dnl and used. dnl Catalog format: GNU --> install in $(datadir) dnl Catalog extension: .mo after installation, .gmo in source tree dnl 2) GNU gettext has been found in the system's C library. dnl Catalog format: GNU --> install in $(datadir) dnl Catalog extension: .mo after installation, .gmo in source tree dnl 3) No internationalization, always use English msgid. dnl Catalog format: none dnl Catalog extension: none dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. dnl The use of .gmo is historical (it was needed to avoid overwriting the dnl GNU format catalogs when building on a platform with an X/Open gettext), dnl but we keep it in order not to force irrelevant filename changes on the dnl maintainers. dnl AC_DEFUN([AM_GNU_GETTEXT], [ dnl Argument checking. ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT ])])])])]) ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT ])])])]) define([gt_included_intl], ifelse([$1], [external], ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]), [yes])) define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], [])) gt_NEEDS_INIT AM_GNU_GETTEXT_NEED([$2]) AC_REQUIRE([AM_PO_SUBDIRS])dnl ifelse(gt_included_intl, yes, [ AC_REQUIRE([AM_INTL_SUBDIR])dnl ]) dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) dnl Sometimes libintl requires libiconv, so first search for libiconv. dnl Ideally we would do this search only after the dnl if test "$USE_NLS" = "yes"; then dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT dnl the configure script would need to contain the same shell code dnl again, outside any 'if'. There are two solutions: dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not dnl documented, we avoid it. ifelse(gt_included_intl, yes, , [ AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) ]) dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation. gt_INTL_MACOSX dnl Set USE_NLS. AC_REQUIRE([AM_NLS]) ifelse(gt_included_intl, yes, [ BUILD_INCLUDED_LIBINTL=no USE_INCLUDED_LIBINTL=no ]) LIBINTL= LTLIBINTL= POSUB= dnl Add a version number to the cache macros. case " $gt_needs " in *" need-formatstring-macros "*) gt_api_version=3 ;; *" need-ngettext "*) gt_api_version=2 ;; *) gt_api_version=1 ;; esac gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" dnl If we use NLS figure out what method if test "$USE_NLS" = "yes"; then gt_use_preinstalled_gnugettext=no ifelse(gt_included_intl, yes, [ AC_MSG_CHECKING([whether included gettext is requested]) AC_ARG_WITH(included-gettext, [ --with-included-gettext use the GNU gettext library included here], nls_cv_force_use_gnu_gettext=$withval, nls_cv_force_use_gnu_gettext=no) AC_MSG_RESULT($nls_cv_force_use_gnu_gettext) nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" if test "$nls_cv_force_use_gnu_gettext" != "yes"; then ]) dnl User does not insist on using GNU NLS library. Figure out what dnl to use. If GNU gettext is available we use this. Else we have dnl to fall back to GNU NLS library. if test $gt_api_version -ge 3; then gt_revision_test_code=' #ifndef __GNU_GETTEXT_SUPPORTED_REVISION #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) #endif changequote(,)dnl typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; changequote([,])dnl ' else gt_revision_test_code= fi if test $gt_api_version -ge 2; then gt_expression_test_code=' + * ngettext ("", "", 0)' else gt_expression_test_code= fi AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc], [AC_TRY_LINK([#include $gt_revision_test_code extern int _nl_msg_cat_cntr; extern int *_nl_domain_bindings;], [bindtextdomain ("", ""); return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings], [eval "$gt_func_gnugettext_libc=yes"], [eval "$gt_func_gnugettext_libc=no"])]) if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then dnl Sometimes libintl requires libiconv, so first search for libiconv. ifelse(gt_included_intl, yes, , [ AM_ICONV_LINK ]) dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) dnl because that would add "-liconv" to LIBINTL and LTLIBINTL dnl even if libiconv doesn't exist. AC_LIB_LINKFLAGS_BODY([intl]) AC_CACHE_CHECK([for GNU gettext in libintl], [$gt_func_gnugettext_libintl], [gt_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $INCINTL" gt_save_LIBS="$LIBS" LIBS="$LIBS $LIBINTL" dnl Now see whether libintl exists and does not depend on libiconv. AC_TRY_LINK([#include $gt_revision_test_code extern int _nl_msg_cat_cntr; extern #ifdef __cplusplus "C" #endif const char *_nl_expand_alias (const char *);], [bindtextdomain ("", ""); return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], [eval "$gt_func_gnugettext_libintl=yes"], [eval "$gt_func_gnugettext_libintl=no"]) dnl Now see whether libintl exists and depends on libiconv. if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then LIBS="$LIBS $LIBICONV" AC_TRY_LINK([#include $gt_revision_test_code extern int _nl_msg_cat_cntr; extern #ifdef __cplusplus "C" #endif const char *_nl_expand_alias (const char *);], [bindtextdomain ("", ""); return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], [LIBINTL="$LIBINTL $LIBICONV" LTLIBINTL="$LTLIBINTL $LTLIBICONV" eval "$gt_func_gnugettext_libintl=yes" ]) fi CPPFLAGS="$gt_save_CPPFLAGS" LIBS="$gt_save_LIBS"]) fi dnl If an already present or preinstalled GNU gettext() is found, dnl use it. But if this macro is used in GNU gettext, and GNU dnl gettext is already preinstalled in libintl, we update this dnl libintl. (Cf. the install rule in intl/Makefile.in.) if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ && test "$PACKAGE" != gettext-runtime \ && test "$PACKAGE" != gettext-tools; }; then gt_use_preinstalled_gnugettext=yes else dnl Reset the values set by searching for libintl. LIBINTL= LTLIBINTL= INCINTL= fi ifelse(gt_included_intl, yes, [ if test "$gt_use_preinstalled_gnugettext" != "yes"; then dnl GNU gettext is not found in the C library. dnl Fall back on included GNU gettext library. nls_cv_use_gnu_gettext=yes fi fi if test "$nls_cv_use_gnu_gettext" = "yes"; then dnl Mark actions used to generate GNU NLS library. BUILD_INCLUDED_LIBINTL=yes USE_INCLUDED_LIBINTL=yes LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD" LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD" LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` fi CATOBJEXT= if test "$gt_use_preinstalled_gnugettext" = "yes" \ || test "$nls_cv_use_gnu_gettext" = "yes"; then dnl Mark actions to use GNU gettext tools. CATOBJEXT=.gmo fi ]) if test -n "$INTL_MACOSX_LIBS"; then if test "$gt_use_preinstalled_gnugettext" = "yes" \ || test "$nls_cv_use_gnu_gettext" = "yes"; then dnl Some extra flags are needed during linking. LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" fi fi if test "$gt_use_preinstalled_gnugettext" = "yes" \ || test "$nls_cv_use_gnu_gettext" = "yes"; then AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if translation of program messages to the user's native language is requested.]) else USE_NLS=no fi fi AC_MSG_CHECKING([whether to use NLS]) AC_MSG_RESULT([$USE_NLS]) if test "$USE_NLS" = "yes"; then AC_MSG_CHECKING([where the gettext function comes from]) if test "$gt_use_preinstalled_gnugettext" = "yes"; then if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then gt_source="external libintl" else gt_source="libc" fi else gt_source="included intl directory" fi AC_MSG_RESULT([$gt_source]) fi if test "$USE_NLS" = "yes"; then if test "$gt_use_preinstalled_gnugettext" = "yes"; then if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then AC_MSG_CHECKING([how to link with libintl]) AC_MSG_RESULT([$LIBINTL]) AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) fi dnl For backward compatibility. Some packages may be using this. AC_DEFINE(HAVE_GETTEXT, 1, [Define if the GNU gettext() function is already present or preinstalled.]) AC_DEFINE(HAVE_DCGETTEXT, 1, [Define if the GNU dcgettext() function is already present or preinstalled.]) fi dnl We need to process the po/ directory. POSUB=po fi ifelse(gt_included_intl, yes, [ dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL dnl to 'yes' because some of the testsuite requires it. if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then BUILD_INCLUDED_LIBINTL=yes fi dnl Make all variables we use known to autoconf. AC_SUBST(BUILD_INCLUDED_LIBINTL) AC_SUBST(USE_INCLUDED_LIBINTL) AC_SUBST(CATOBJEXT) dnl For backward compatibility. Some configure.ins may be using this. nls_cv_header_intl= nls_cv_header_libgt= dnl For backward compatibility. Some Makefiles may be using this. DATADIRNAME=share AC_SUBST(DATADIRNAME) dnl For backward compatibility. Some Makefiles may be using this. INSTOBJEXT=.mo AC_SUBST(INSTOBJEXT) dnl For backward compatibility. Some Makefiles may be using this. GENCAT=gencat AC_SUBST(GENCAT) dnl For backward compatibility. Some Makefiles may be using this. INTLOBJS= if test "$USE_INCLUDED_LIBINTL" = yes; then INTLOBJS="\$(GETTOBJS)" fi AC_SUBST(INTLOBJS) dnl Enable libtool support if the surrounding package wishes it. INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX) ]) dnl For backward compatibility. Some Makefiles may be using this. INTLLIBS="$LIBINTL" AC_SUBST(INTLLIBS) dnl Make all documented variables known to autoconf. AC_SUBST(LIBINTL) AC_SUBST(LTLIBINTL) AC_SUBST(POSUB) ]) dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized. m4_define([gt_NEEDS_INIT], [ m4_divert_text([DEFAULTS], [gt_needs=]) m4_define([gt_NEEDS_INIT], []) ]) dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL]) AC_DEFUN([AM_GNU_GETTEXT_NEED], [ m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"]) ]) dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) libquicktime-1.2.4/m4/avcodec.m40000644000175000017500000000710511717024014013307 00000000000000# Configure paths for libavcodec # Burkhard Plaum, 2004-08-12 dnl Compile an avcodec test program and figure out the version AC_DEFUN([ACL_CHECK_AVCODEC],[ AC_MSG_CHECKING([for build ID in libavcodec, libs: $AVCODEC_LIBS]) CFLAGS_save=$CFLAGS LIBS_save=$LIBS CFLAGS="$GMERLIN_DEP_CFLAGS $CFLAGS $AVCODEC_CFLAGS" LIBS="$GMERLIN_DEP_LIBS $AVCODEC_LIBS" AVCODEC_HEADER="" dnl Look for header found_header="false" AC_TRY_COMPILE([#include ],[],[found_header="true";AVCODEC_HEADER="";VDPAU_HEADER="" ],) if test $found_header = "false"; then AC_TRY_COMPILE([#include ],[],[found_header="true";AVCODEC_HEADER="";VDPAU_HEADER=""]) fi if test $found_header = "false"; then AC_TRY_COMPILE([#include ],[], [found_header="true";AVCODEC_HEADER="";VDPAU_HEADER="" ],) fi avcodec_ok="false" AC_TRY_RUN([ #include #include $AVCODEC_HEADER int main() { FILE * output; if(LIBAVCODEC_BUILD < $1) return -1; output=fopen("avcodec_version", "w"); fprintf(output, AV_TOSTRING(LIBAVCODEC_VERSION)); fclose(output); return 0; } ], [ # program could be run if test "x$AVCODEC_VERSION" = "x"; then AVCODEC_VERSION=`cat avcodec_version` fi rm -f avcodec_version avcodec_ok="true" AC_MSG_RESULT(ok) ], [ # program could not be run AC_MSG_RESULT(failed) ]) have_avcodec_img_convert="false" if test "x$avcodec_ok" = "xtrue"; then avcodec_swscale_missing="false" dnl AC_CHECK_HEADERS([libavcore/avcore.h]) AC_MSG_CHECKING(for img_convert) AC_TRY_LINK([#include ], [img_convert(NULL, 0, NULL, 0, 0, 0); return 0;], have_avcodec_img_convert=true AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) if test "x$have_avcodec_img_convert" != "xtrue"; then if test "x$have_libswscale" != "xtrue"; then avcodec_swscale_missing="true" avcodec_ok="false" fi fi fi CFLAGS="$CFLAGS_save" LIBS="$LIBS_save" ]) dnl ACL_PATH_AVCODEC(BUILD_ID [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) dnl Test for libavcodec, and define AVCODEC_CFLAGS, AVCODEC_LIBS and dnl AVCODEC_VERSION AC_DEFUN([ACL_PATH_AVCODEC],[ AC_ARG_WITH(avcodec,[ --with-avcodec=PFX Prefix where libavcodec is installed (optional)], avcodec_prefix="$withval", avcodec_prefix="") dnl We need the _save variables because PKG_CHECK_MODULES will change dnl the other variables AVCODEC_CFLAGS_save="" AVCODEC_LIBS_save="" avcodec_done="false" AH_TEMPLATE([AVCODEC_HEADER], [Header for libavcodec]) AH_TEMPLATE([VDPAU_HEADER], [Header for vdpau]) dnl dnl First preference: configure options dnl if test "x$avcodec_prefix" != x; then AVCODEC_CFLAGS="-I$avcodec_prefix/include" AVCODEC_LIBS="-L$avcodec_prefix/lib -lavcodec" ACL_CHECK_AVCODEC([$1]) if test "x$avcodec_ok" = "xtrue"; then avcodec_done="true" fi fi dnl dnl Second Perference: Autodetect dnl if test "x$avcodec_done" = "xfalse"; then PKG_CHECK_MODULES(AVCODEC, libavcodec, avcodec_orig="true", avcodec_orig="false") dnl dnl No idea for what this is good but libavcodec is not found if this is missing dnl if test "x$os_win32" = "xyes"; then AVCODEC_LIBS="-L/usr/local/bin $AVCODEC_LIBS" fi ACL_CHECK_AVCODEC([$1]) if test "x$avcodec_ok" = "xtrue"; then avcodec_done="true" fi fi if test "x$avcodec_done" = "xtrue"; then ifelse([$2], , :, [$2]) AC_DEFINE_UNQUOTED(AVCODEC_HEADER, $AVCODEC_HEADER) AC_DEFINE_UNQUOTED(VDPAU_HEADER, $VDPAU_HEADER) else ifelse([$3], , :, [$3]) fi ]) libquicktime-1.2.4/m4/lib-prefix.m40000644000175000017500000001503611566403572013762 00000000000000# lib-prefix.m4 serial 5 (gettext-0.15) dnl Copyright (C) 2001-2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't dnl require excessive bracketing. ifdef([AC_HELP_STRING], [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], [AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed dnl to access previously installed libraries. The basic assumption is that dnl a user will want packages to use other packages he previously installed dnl with the same --prefix option. dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate dnl libraries, but is otherwise very convenient. AC_DEFUN([AC_LIB_PREFIX], [ AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) AC_LIB_ARG_WITH([lib-prefix], [ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib --without-lib-prefix don't search for libraries in includedir and libdir], [ if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" fi fi ]) if test $use_additional = yes; then dnl Potentially add $additional_includedir to $CPPFLAGS. dnl But don't add it dnl 1. if it's the standard /usr/include, dnl 2. if it's already present in $CPPFLAGS, dnl 3. if it's /usr/local/include and we are using GCC on Linux, dnl 4. if it doesn't exist as a directory. if test "X$additional_includedir" != "X/usr/include"; then haveit= for x in $CPPFLAGS; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then if test -d "$additional_includedir"; then dnl Really add $additional_includedir to $CPPFLAGS. CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" fi fi fi fi dnl Potentially add $additional_libdir to $LDFLAGS. dnl But don't add it dnl 1. if it's the standard /usr/lib, dnl 2. if it's already present in $LDFLAGS, dnl 3. if it's /usr/local/lib and we are using GCC on Linux, dnl 4. if it doesn't exist as a directory. if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then haveit= for x in $LDFLAGS; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then if test -n "$GCC"; then case $host_os in linux*) haveit=yes;; esac fi fi if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LDFLAGS. LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" fi fi fi fi fi ]) dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, dnl acl_final_exec_prefix, containing the values to which $prefix and dnl $exec_prefix will expand at the end of the configure script. AC_DEFUN([AC_LIB_PREPARE_PREFIX], [ dnl Unfortunately, prefix and exec_prefix get only finally determined dnl at the end of configure. if test "X$prefix" = "XNONE"; then acl_final_prefix="$ac_default_prefix" else acl_final_prefix="$prefix" fi if test "X$exec_prefix" = "XNONE"; then acl_final_exec_prefix='${prefix}' else acl_final_exec_prefix="$exec_prefix" fi acl_save_prefix="$prefix" prefix="$acl_final_prefix" eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" prefix="$acl_save_prefix" ]) dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the dnl variables prefix and exec_prefix bound to the values they will have dnl at the end of the configure script. AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], [ acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" $1 exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" ]) dnl AC_LIB_PREPARE_MULTILIB creates a variable acl_libdirstem, containing dnl the basename of the libdir, either "lib" or "lib64". AC_DEFUN([AC_LIB_PREPARE_MULTILIB], [ dnl There is no formal standard regarding lib and lib64. The current dnl practice is that on a system supporting 32-bit and 64-bit instruction dnl sets or ABIs, 64-bit libraries go under $prefix/lib64 and 32-bit dnl libraries go under $prefix/lib. We determine the compiler's default dnl mode by looking at the compiler's library search path. If at least dnl of its elements ends in /lib64 or points to a directory whose absolute dnl pathname ends in /lib64, we assume a 64-bit ABI. Otherwise we use the dnl default, namely "lib". acl_libdirstem=lib searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` if test -n "$searchpath"; then acl_save_IFS="${IFS= }"; IFS=":" for searchdir in $searchpath; do if test -d "$searchdir"; then case "$searchdir" in */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; *) searchdir=`cd "$searchdir" && pwd` case "$searchdir" in */lib64 ) acl_libdirstem=lib64 ;; esac ;; esac fi done IFS="$acl_save_IFS" fi ]) libquicktime-1.2.4/m4/po.m40000644000175000017500000004460611566403572012344 00000000000000# po.m4 serial 15 (gettext-0.17) dnl Copyright (C) 1995-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl This file can can be used in projects which are not available under dnl the GNU General Public License or the GNU Library General Public dnl License but which still want to provide support for the GNU gettext dnl functionality. dnl Please note that the actual code of the GNU gettext library is covered dnl by the GNU Library General Public License, and the rest of the GNU dnl gettext package package is covered by the GNU General Public License. dnl They are *not* in the public domain. dnl Authors: dnl Ulrich Drepper , 1995-2000. dnl Bruno Haible , 2000-2003. AC_PREREQ(2.50) dnl Checks for all prerequisites of the po subdirectory. AC_DEFUN([AM_PO_SUBDIRS], [ AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake AC_REQUIRE([AM_NLS])dnl dnl Release version of the gettext macros. This is used to ensure that dnl the gettext macros and po/Makefile.in.in are in sync. AC_SUBST([GETTEXT_MACRO_VERSION], [0.17]) dnl Perform the following tests also if --disable-nls has been given, dnl because they are needed for "make dist" to work. dnl Search for GNU msgfmt in the PATH. dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions. dnl The second test excludes FreeBSD msgfmt. AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], :) AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) dnl Test whether it is GNU msgfmt >= 0.15. changequote(,)dnl case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;; *) MSGFMT_015=$MSGFMT ;; esac changequote([,])dnl AC_SUBST([MSGFMT_015]) changequote(,)dnl case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;; *) GMSGFMT_015=$GMSGFMT ;; esac changequote([,])dnl AC_SUBST([GMSGFMT_015]) dnl Search for GNU xgettext 0.12 or newer in the PATH. dnl The first test excludes Solaris xgettext and early GNU xgettext versions. dnl The second test excludes FreeBSD xgettext. AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], :) dnl Remove leftover from FreeBSD xgettext call. rm -f messages.po dnl Test whether it is GNU xgettext >= 0.15. changequote(,)dnl case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;; *) XGETTEXT_015=$XGETTEXT ;; esac changequote([,])dnl AC_SUBST([XGETTEXT_015]) dnl Search for GNU msgmerge 0.11 or newer in the PATH. AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge, [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :) dnl Installation directories. dnl Autoconf >= 2.60 defines localedir. For older versions of autoconf, we dnl have to define it here, so that it can be used in po/Makefile. test -n "$localedir" || localedir='${datadir}/locale' AC_SUBST([localedir]) dnl Support for AM_XGETTEXT_OPTION. test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= AC_SUBST([XGETTEXT_EXTRA_OPTIONS]) AC_CONFIG_COMMANDS([po-directories], [[ for ac_file in $CONFIG_FILES; do # Support "outfile[:infile[:infile...]]" case "$ac_file" in *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; esac # PO directories have a Makefile.in generated from Makefile.in.in. case "$ac_file" in */Makefile.in) # Adjust a relative srcdir. ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` # In autoconf-2.13 it is called $ac_given_srcdir. # In autoconf-2.50 it is called $srcdir. test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" case "$ac_given_srcdir" in .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; /*) top_srcdir="$ac_given_srcdir" ;; *) top_srcdir="$ac_dots$ac_given_srcdir" ;; esac # Treat a directory as a PO directory if and only if it has a # POTFILES.in file. This allows packages to have multiple PO # directories under different names or in different locations. if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then rm -f "$ac_dir/POTFILES" test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" POMAKEFILEDEPS="POTFILES.in" # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend # on $ac_dir but don't depend on user-specified configuration # parameters. if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then # The LINGUAS file contains the set of available languages. if test -n "$OBSOLETE_ALL_LINGUAS"; then test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" fi ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` # Hide the ALL_LINGUAS assigment from automake < 1.5. eval 'ALL_LINGUAS''=$ALL_LINGUAS_' POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" else # The set of available languages was given in configure.in. # Hide the ALL_LINGUAS assigment from automake < 1.5. eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' fi # Compute POFILES # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) # Compute UPDATEPOFILES # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) # Compute DUMMYPOFILES # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) # Compute GMOFILES # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) case "$ac_given_srcdir" in .) srcdirpre= ;; *) srcdirpre='$(srcdir)/' ;; esac POFILES= UPDATEPOFILES= DUMMYPOFILES= GMOFILES= for lang in $ALL_LINGUAS; do POFILES="$POFILES $srcdirpre$lang.po" UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" DUMMYPOFILES="$DUMMYPOFILES $lang.nop" GMOFILES="$GMOFILES $srcdirpre$lang.gmo" done # CATALOGS depends on both $ac_dir and the user's LINGUAS # environment variable. INST_LINGUAS= if test -n "$ALL_LINGUAS"; then for presentlang in $ALL_LINGUAS; do useit=no if test "%UNSET%" != "$LINGUAS"; then desiredlanguages="$LINGUAS" else desiredlanguages="$ALL_LINGUAS" fi for desiredlang in $desiredlanguages; do # Use the presentlang catalog if desiredlang is # a. equal to presentlang, or # b. a variant of presentlang (because in this case, # presentlang can be used as a fallback for messages # which are not translated in the desiredlang catalog). case "$desiredlang" in "$presentlang"*) useit=yes;; esac done if test $useit = yes; then INST_LINGUAS="$INST_LINGUAS $presentlang" fi done fi CATALOGS= if test -n "$INST_LINGUAS"; then for lang in $INST_LINGUAS; do CATALOGS="$CATALOGS $lang.gmo" done fi test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do if test -f "$f"; then case "$f" in *.orig | *.bak | *~) ;; *) cat "$f" >> "$ac_dir/Makefile" ;; esac fi done fi ;; esac done]], [# Capture the value of obsolete ALL_LINGUAS because we need it to compute # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it # from automake < 1.5. eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' # Capture the value of LINGUAS because we need it to compute CATALOGS. LINGUAS="${LINGUAS-%UNSET%}" ]) ]) dnl Postprocesses a Makefile in a directory containing PO files. AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE], [ # When this code is run, in config.status, two variables have already been # set: # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in, # - LINGUAS is the value of the environment variable LINGUAS at configure # time. changequote(,)dnl # Adjust a relative srcdir. ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` # In autoconf-2.13 it is called $ac_given_srcdir. # In autoconf-2.50 it is called $srcdir. test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" case "$ac_given_srcdir" in .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; /*) top_srcdir="$ac_given_srcdir" ;; *) top_srcdir="$ac_dots$ac_given_srcdir" ;; esac # Find a way to echo strings without interpreting backslash. if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then gt_echo='echo' else if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then gt_echo='printf %s\n' else echo_func () { cat < "$ac_file.tmp" if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then # Add dependencies that cannot be formulated as a simple suffix rule. for lang in $ALL_LINGUAS; do frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` cat >> "$ac_file.tmp" < /dev/null; then # Add dependencies that cannot be formulated as a simple suffix rule. for lang in $ALL_LINGUAS; do frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'` cat >> "$ac_file.tmp" <> "$ac_file.tmp" <], [CFPreferencesCopyAppValue(NULL, NULL)], [gt_cv_func_CFPreferencesCopyAppValue=yes], [gt_cv_func_CFPreferencesCopyAppValue=no]) LIBS="$gt_save_LIBS"]) if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], 1, [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) fi dnl Check for API introduced in MacOS X 10.3. AC_CACHE_CHECK([for CFLocaleCopyCurrent], gt_cv_func_CFLocaleCopyCurrent, [gt_save_LIBS="$LIBS" LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" AC_TRY_LINK([#include ], [CFLocaleCopyCurrent();], [gt_cv_func_CFLocaleCopyCurrent=yes], [gt_cv_func_CFLocaleCopyCurrent=no]) LIBS="$gt_save_LIBS"]) if test $gt_cv_func_CFLocaleCopyCurrent = yes; then AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], 1, [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.]) fi INTL_MACOSX_LIBS= if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" fi AC_SUBST([INTL_MACOSX_LIBS]) ]) libquicktime-1.2.4/m4/vorbis.m40000644000175000017500000001040410541540540013204 00000000000000# Configure paths for libvorbis # Jack Moffitt 10-21-2000 # Shamelessly stolen from Owen Taylor and Manish Singh # thomasvs added check for vorbis_bitrate_addblock which is new in rc3 dnl XIPH_PATH_VORBIS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) dnl Test for libvorbis, and define VORBIS_CFLAGS and VORBIS_LIBS dnl AC_DEFUN([XIPH_PATH_VORBIS], [dnl dnl Get the cflags and libraries dnl AC_ARG_WITH(vorbis,[ --with-vorbis=PFX Prefix where libvorbis is installed (optional)], vorbis_prefix="$withval", vorbis_prefix="") AC_ARG_WITH(vorbis-libraries,[ --with-vorbis-libraries=DIR Directory where libvorbis library is installed (optional)], vorbis_libraries="$withval", vorbis_libraries="") AC_ARG_WITH(vorbis-includes,[ --with-vorbis-includes=DIR Directory where libvorbis header files are installed (optional)], vorbis_includes="$withval", vorbis_includes="") AC_ARG_ENABLE(vorbistest, [ --disable-vorbistest Do not try to compile and run a test Vorbis program],, enable_vorbistest=yes) if test "x$vorbis_libraries" != "x" ; then VORBIS_LIBS="-L$vorbis_libraries" elif test "x$vorbis_prefix" != "x" ; then VORBIS_LIBS="-L$vorbis_prefix/lib" elif test "x$prefix" != "xNONE"; then VORBIS_LIBS="-L$prefix/lib" fi VORBIS_LIBS="$VORBIS_LIBS -lvorbis -lm" VORBISFILE_LIBS="-lvorbisfile" VORBISENC_LIBS="-lvorbisenc" if test "x$vorbis_includes" != "x" ; then VORBIS_CFLAGS="-I$vorbis_includes" elif test "x$vorbis_prefix" != "x" ; then VORBIS_CFLAGS="-I$vorbis_prefix/include" elif test "x$prefix" != "xNONE"; then VORBIS_CFLAGS="-I$prefix/include" fi AC_MSG_CHECKING(for Vorbis) no_vorbis="" if test "x$enable_vorbistest" = "xyes" ; then ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $VORBIS_CFLAGS $OGG_CFLAGS" LIBS="$LIBS $VORBIS_LIBS $VORBISENC_LIBS $OGG_LIBS" dnl dnl Now check if the installed Vorbis is sufficiently new. dnl rm -f conf.vorbistest AC_TRY_RUN([ #include #include #include #include #include int main () { vorbis_block vb; vorbis_dsp_state vd; vorbis_info vi; vorbis_info_init (&vi); vorbis_encode_init (&vi, 2, 44100, -1, 128000, -1); vorbis_analysis_init (&vd, &vi); vorbis_block_init (&vd, &vb); /* this function was added in 1.0rc3, so this is what we're testing for */ vorbis_bitrate_addblock (&vb); system("touch conf.vorbistest"); return 0; } ],, no_vorbis=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi if test "x$no_vorbis" = "x" ; then AC_MSG_RESULT(yes) ifelse([$1], , :, [$1]) else AC_MSG_RESULT(no) if test -f conf.vorbistest ; then : else echo "*** Could not run Vorbis test program, checking why..." CFLAGS="$CFLAGS $VORBIS_CFLAGS" LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS" AC_TRY_LINK([ #include #include ], [ return 0; ], [ echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding Vorbis or finding the wrong" echo "*** version of Vorbis. If it is not finding Vorbis, you'll need to set your" echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" echo "*** to the installed location Also, make sure you have run ldconfig if that" echo "*** is required on your system" echo "***" echo "*** If you have an old version installed, it is best to remove it, although" echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], [ echo "*** The test program failed to compile or link. See the file config.log for the" echo "*** exact error that occured. This usually means Vorbis was incorrectly installed" echo "*** or that you have moved Vorbis since it was installed." ]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi VORBIS_CFLAGS="" VORBIS_LIBS="" VORBISFILE_LIBS="" VORBISENC_LIBS="" ifelse([$2], , :, [$2]) fi AC_SUBST(VORBIS_CFLAGS) AC_SUBST(VORBIS_LIBS) AC_SUBST(VORBISFILE_LIBS) AC_SUBST(VORBISENC_LIBS) rm -f conf.vorbistest ]) libquicktime-1.2.4/m4/ltoptions.m40000644000175000017500000002724211735135707013756 00000000000000# Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 6 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) # --------------------------------------- # Set option OPTION-NAME for macro MACRO-NAME, and if there is a # matching handler defined, dispatch to it. Other OPTION-NAMEs are # saved as a flag. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option `$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) # ------------------------------------------------------- # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME # are set. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) # ---------------------------------------- # OPTION-LIST is a space-separated list of Libtool options associated # with MACRO-NAME. If any OPTION has a matching handler declared with # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about # the unknown option and exit. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl `shared' nor `disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) ]) ])# _LT_SET_OPTIONS ## --------------------------------- ## ## Macros to handle LT_INIT options. ## ## --------------------------------- ## # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [0], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- # implement the --enable-shared flag, and supports the `shared' and # `disable-shared' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- # implement the --enable-static flag, and support the `static' and # `disable-static' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- # implement the --enable-fast-install flag, and support the `fast-install' # and `disable-fast-install' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_PIC([MODE]) # -------------------- # implement the --with-pic flag, and support the `pic-only' and `no-pic' # LT_INIT options. # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [pic_mode="$withval"], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) ## ----------------- ## ## LTDL_INIT Options ## ## ----------------- ## m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) libquicktime-1.2.4/m4/lib-link.m40000644000175000017500000007205511566403572013426 00000000000000# lib-link.m4 serial 13 (gettext-0.17) dnl Copyright (C) 2001-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. AC_PREREQ(2.54) dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and dnl the libraries corresponding to explicit and implicit dependencies. dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and dnl augments the CPPFLAGS variable. dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) define([Name],[translit([$1],[./-], [___])]) define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ AC_LIB_LINKFLAGS_BODY([$1], [$2]) ac_cv_lib[]Name[]_libs="$LIB[]NAME" ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" ac_cv_lib[]Name[]_cppflags="$INC[]NAME" ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX" ]) LIB[]NAME="$ac_cv_lib[]Name[]_libs" LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" INC[]NAME="$ac_cv_lib[]Name[]_cppflags" LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) AC_SUBST([LIB]NAME) AC_SUBST([LTLIB]NAME) AC_SUBST([LIB]NAME[_PREFIX]) dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the dnl results of this search when this library appears as a dependency. HAVE_LIB[]NAME=yes undefine([Name]) undefine([NAME]) ]) dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) dnl searches for libname and the libraries corresponding to explicit and dnl implicit dependencies, together with the specified include files and dnl the ability to compile and link the specified testcode. If found, it dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) define([Name],[translit([$1],[./-], [___])]) define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME dnl accordingly. AC_LIB_LINKFLAGS_BODY([$1], [$2]) dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, dnl because if the user has installed lib[]Name and not disabled its use dnl via --without-lib[]Name-prefix, he wants to use it. ac_save_CPPFLAGS="$CPPFLAGS" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ ac_save_LIBS="$LIBS" LIBS="$LIBS $LIB[]NAME" AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no]) LIBS="$ac_save_LIBS" ]) if test "$ac_cv_lib[]Name" = yes; then HAVE_LIB[]NAME=yes AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.]) AC_MSG_CHECKING([how to link with lib[]$1]) AC_MSG_RESULT([$LIB[]NAME]) else HAVE_LIB[]NAME=no dnl If $LIB[]NAME didn't lead to a usable library, we don't need dnl $INC[]NAME either. CPPFLAGS="$ac_save_CPPFLAGS" LIB[]NAME= LTLIB[]NAME= LIB[]NAME[]_PREFIX= fi AC_SUBST([HAVE_LIB]NAME) AC_SUBST([LIB]NAME) AC_SUBST([LTLIB]NAME) AC_SUBST([LIB]NAME[_PREFIX]) undefine([Name]) undefine([NAME]) ]) dnl Determine the platform dependent parameters needed to use rpath: dnl acl_libext, dnl acl_shlibext, dnl acl_hardcode_libdir_flag_spec, dnl acl_hardcode_libdir_separator, dnl acl_hardcode_direct, dnl acl_hardcode_minus_L. AC_DEFUN([AC_LIB_RPATH], [ dnl Tell automake >= 1.10 to complain if config.rpath is missing. m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [ CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh . ./conftest.sh rm -f ./conftest.sh acl_cv_rpath=done ]) wl="$acl_cv_wl" acl_libext="$acl_cv_libext" acl_shlibext="$acl_cv_shlibext" acl_libname_spec="$acl_cv_libname_spec" acl_library_names_spec="$acl_cv_library_names_spec" acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" acl_hardcode_direct="$acl_cv_hardcode_direct" acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" dnl Determine whether the user wants rpath handling at all. AC_ARG_ENABLE(rpath, [ --disable-rpath do not hardcode runtime library paths], :, enable_rpath=yes) ]) dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and dnl the libraries corresponding to explicit and implicit dependencies. dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_LINKFLAGS_BODY], [ AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) dnl Autoconf >= 2.61 supports dots in --with options. define([N_A_M_E],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit([$1],[.],[_])],[$1])]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) AC_LIB_ARG_WITH([lib]N_A_M_E[-prefix], [ --with-lib]N_A_M_E[-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib --without-lib]N_A_M_E[-prefix don't search for lib$1 in includedir and libdir], [ if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" fi fi ]) dnl Search the library and its dependencies in $additional_libdir and dnl $LDFLAGS. Using breadth-first-seach. LIB[]NAME= LTLIB[]NAME= INC[]NAME= LIB[]NAME[]_PREFIX= rpathdirs= ltrpathdirs= names_already_handled= names_next_round='$1 $2' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= for name in $names_this_round; do already_handled= for n in $names_already_handled; do if test "$n" = "$name"; then already_handled=yes break fi done if test -z "$already_handled"; then names_already_handled="$names_already_handled $name" dnl See if it was already located by an earlier AC_LIB_LINKFLAGS dnl or AC_LIB_HAVE_LINKFLAGS call. uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" eval value=\"\$LTLIB$uppername\" test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" else dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined dnl that this library doesn't exist. So just drop it. : fi else dnl Search the library lib$name in $additional_libdir and $LDFLAGS dnl and the already constructed $LIBNAME/$LTLIBNAME. found_dir= found_la= found_so= found_a= eval libname=\"$acl_libname_spec\" # typically: libname=lib$name if test -n "$acl_shlibext"; then shrext=".$acl_shlibext" # typically: shrext=.so else shrext= fi if test $use_additional = yes; then dir="$additional_libdir" dnl The same code as in the loop below: dnl First look for a shared library. if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi dnl Then look for a static library. if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` dnl First look for a shared library. if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi dnl Then look for a static library. if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi ;; esac if test "X$found_dir" != "X"; then break fi done fi if test "X$found_dir" != "X"; then dnl Found the library. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then dnl Linking with a shared library. We attempt to hardcode its dnl directory into the executable's runpath, unless it's the dnl standard /usr/lib. if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then dnl No hardcoding is needed. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else dnl Use an explicit option to hardcode DIR into the resulting dnl binary. dnl Potentially add DIR to ltrpathdirs. dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. haveit= for x in $ltrpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $found_dir" fi dnl The hardcoding into $LIBNAME is system dependent. if test "$acl_hardcode_direct" = yes; then dnl Using DIR/libNAME.so during linking hardcodes DIR into the dnl resulting binary. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then dnl Use an explicit option to hardcode DIR into the resulting dnl binary. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" dnl Potentially add DIR to rpathdirs. dnl The rpathdirs will be appended to $LIBNAME at the end. haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $found_dir" fi else dnl Rely on "-L$found_dir". dnl But don't add it if it's already contained in the LDFLAGS dnl or the already constructed $LIBNAME haveit= for x in $LDFLAGS $LIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" fi if test "$acl_hardcode_minus_L" != no; then dnl FIXME: Not sure whether we should use dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" dnl here. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH dnl here, because this doesn't fit in flags passed to the dnl compiler. So give up. No hardcoding. This affects only dnl very old systems. dnl FIXME: Not sure whether we should use dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" dnl here. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then dnl Linking with a static library. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" else dnl We shouldn't come here, but anyway it's good to have a dnl fallback. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" fi fi dnl Assume the include files are nearby. additional_includedir= case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` LIB[]NAME[]_PREFIX="$basedir" additional_includedir="$basedir/include" ;; esac if test "X$additional_includedir" != "X"; then dnl Potentially add $additional_includedir to $INCNAME. dnl But don't add it dnl 1. if it's the standard /usr/include, dnl 2. if it's /usr/local/include and we are using GCC on Linux, dnl 3. if it's already present in $CPPFLAGS or the already dnl constructed $INCNAME, dnl 4. if it doesn't exist as a directory. if test "X$additional_includedir" != "X/usr/include"; then haveit= if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then for x in $CPPFLAGS $INC[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_includedir"; then dnl Really add $additional_includedir to $INCNAME. INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" fi fi fi fi fi dnl Look for dependencies. if test -n "$found_la"; then dnl Read the .la file. It defines the variables dnl dlname, library_names, old_library, dependency_libs, current, dnl age, revision, installed, dlopen, dlpreopen, libdir. save_libdir="$libdir" case "$found_la" in */* | *\\*) . "$found_la" ;; *) . "./$found_la" ;; esac libdir="$save_libdir" dnl We use only dependency_libs. for dep in $dependency_libs; do case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. dnl But don't add it dnl 1. if it's the standard /usr/lib, dnl 2. if it's /usr/local/lib and we are using GCC on Linux, dnl 3. if it's already present in $LDFLAGS or the already dnl constructed $LIBNAME, dnl 4. if it doesn't exist as a directory. if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then haveit= if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then haveit= for x in $LDFLAGS $LIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LIBNAME. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" fi fi haveit= for x in $LDFLAGS $LTLIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LTLIBNAME. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then dnl Potentially add DIR to rpathdirs. dnl The rpathdirs will be appended to $LIBNAME at the end. haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi dnl Potentially add DIR to ltrpathdirs. dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) dnl Handle this in the next round. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) dnl Handle this in the next round. Throw away the .la's dnl directory; it is already contained in a preceding -L dnl option. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) dnl Most likely an immediate library name. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" ;; esac done fi else dnl Didn't find the library; assume it is in the system directories dnl known to the linker and runtime loader. (All the system dnl directories known to the linker should also be known to the dnl runtime loader, otherwise the system is severely misconfigured.) LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$acl_hardcode_libdir_separator"; then dnl Weird platform: only the last -rpath option counts, the user must dnl pass all path elements in one option. We can arrange that for a dnl single library, but not when more than one $LIBNAMEs are used. alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" done dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" else dnl The -rpath options are cumulative. for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then dnl When using libtool, the option that works for both libraries and dnl executables is -R. The -R options are cumulative. for found_dir in $ltrpathdirs; do LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" done fi ]) dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, dnl unless already present in VAR. dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes dnl contains two or three consecutive elements that belong together. AC_DEFUN([AC_LIB_APPENDTOVAR], [ for element in [$2]; do haveit= for x in $[$1]; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then [$1]="${[$1]}${[$1]:+ }$element" fi done ]) dnl For those cases where a variable contains several -L and -l options dnl referring to unknown libraries and directories, this macro determines the dnl necessary additional linker options for the runtime path. dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) dnl sets LDADDVAR to linker options needed together with LIBSVALUE. dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, dnl otherwise linking without libtool is assumed. AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], [ AC_REQUIRE([AC_LIB_RPATH]) AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) $1= if test "$enable_rpath" != no; then if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then dnl Use an explicit option to hardcode directories into the resulting dnl binary. rpathdirs= next= for opt in $2; do if test -n "$next"; then dir="$next" dnl No need to hardcode the standard /usr/lib. if test "X$dir" != "X/usr/$acl_libdirstem"; then rpathdirs="$rpathdirs $dir" fi next= else case $opt in -L) next=yes ;; -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` dnl No need to hardcode the standard /usr/lib. if test "X$dir" != "X/usr/$acl_libdirstem"; then rpathdirs="$rpathdirs $dir" fi next= ;; *) next= ;; esac fi done if test "X$rpathdirs" != "X"; then if test -n ""$3""; then dnl libtool is used for linking. Use -R options. for dir in $rpathdirs; do $1="${$1}${$1:+ }-R$dir" done else dnl The linker is used for linking directly. if test -n "$acl_hardcode_libdir_separator"; then dnl Weird platform: only the last -rpath option counts, the user dnl must pass all path elements in one option. alldirs= for dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" done acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" $1="$flag" else dnl The -rpath options are cumulative. for dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" $1="${$1}${$1:+ }$flag" done fi fi fi fi fi AC_SUBST([$1]) ]) libquicktime-1.2.4/m4/progtest.m40000644000175000017500000000555011566403572013570 00000000000000# progtest.m4 serial 4 (gettext-0.14.2) dnl Copyright (C) 1996-2003, 2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl This file can can be used in projects which are not available under dnl the GNU General Public License or the GNU Library General Public dnl License but which still want to provide support for the GNU gettext dnl functionality. dnl Please note that the actual code of the GNU gettext library is covered dnl by the GNU Library General Public License, and the rest of the GNU dnl gettext package package is covered by the GNU General Public License. dnl They are *not* in the public domain. dnl Authors: dnl Ulrich Drepper , 1996. AC_PREREQ(2.50) # Search path for a program which passes the given test. dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) AC_DEFUN([AM_PATH_PROG_WITH_TEST], [ # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi # Find out how to test for executable files. Don't use a zero-byte file, # as systems may use methods other than mode bits to determine executability. cat >conf$$.file <<_ASEOF #! /bin/sh exit 0 _ASEOF chmod +x conf$$.file if test -x conf$$.file >/dev/null 2>&1; then ac_executable_p="test -x" else ac_executable_p="test -f" fi rm -f conf$$.file # Extract the first word of "$2", so it can be a program name with args. set dummy $2; ac_word=[$]2 AC_MSG_CHECKING([for $ac_word]) AC_CACHE_VAL(ac_cv_path_$1, [case "[$]$1" in [[\\/]]* | ?:[[\\/]]*) ac_cv_path_$1="[$]$1" # Let the user override the test with a path. ;; *) ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in ifelse([$5], , $PATH, [$5]); do IFS="$ac_save_IFS" test -z "$ac_dir" && ac_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD if [$3]; then ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext" break 2 fi fi done done IFS="$ac_save_IFS" dnl If no 4th arg is given, leave the cache variable unset, dnl so AC_PATH_PROGS will keep looking. ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" ])dnl ;; esac])dnl $1="$ac_cv_path_$1" if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then AC_MSG_RESULT([$]$1) else AC_MSG_RESULT(no) fi AC_SUBST($1)dnl ]) libquicktime-1.2.4/TODO0000644000175000017500000000020410540605475011613 00000000000000- Read/write quicktime text subtitles - Set compatibility flags for all encoders - Maybe more steps towards proper mp4 encoding? libquicktime-1.2.4/COPYING0000644000175000017500000006364407434011500012163 00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. ^L 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. ^L 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. ^L 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. ^L 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. ^L 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. ^L 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. ^L 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 ^L 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. Copyright (C) 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! libquicktime-1.2.4/config.sub0000755000175000017500000010242511735135714013117 00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 # Free Software Foundation, Inc. timestamp='2009-06-11' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nios | nios2 \ | ns16k | ns32k \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | v850 | v850e \ | we32k \ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tic55x | c55x*) basic_machine=tic55x-unknown os=-coff ;; tic6x | c6x*) basic_machine=tic6x-unknown os=-coff ;; tile*) basic_machine=tile-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: libquicktime-1.2.4/libquicktime.pc.in0000644000175000017500000000042310240175413014530 00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@/lqt plugindir=@PLUGIN_DIR@ Name: libquicktime Description: library for reading and writing Quicktime files Version: @VERSION@ Libs: -L${libdir} @LQT_LIBS@ Cflags: -I${includedir} @LQT_CFLAGS@ libquicktime-1.2.4/src/0000755000175000017500000000000011735135732011777 500000000000000libquicktime-1.2.4/src/frma.c0000644000175000017500000000400111511622756013002 00000000000000/******************************************************************************* frma.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include void quicktime_read_frma(quicktime_t *file, quicktime_frma_t *frma, quicktime_atom_t *frma_atom) { quicktime_read_data(file, (uint8_t*)frma->codec, 4); } void quicktime_write_frma(quicktime_t *file, quicktime_frma_t *frma) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "frma"); quicktime_write_data(file, (uint8_t*)frma->codec, 4); quicktime_atom_write_footer(file, &atom); } void quicktime_frma_dump(quicktime_frma_t *frma) { lqt_dump(" frma: \n"); lqt_dump(" codec: %c%c%c%c\n", frma->codec[0], frma->codec[1], frma->codec[2], frma->codec[3]); } void quicktime_set_frma(quicktime_trak_t * trak, char * codec) { quicktime_wave_t * wave = &trak->mdia.minf.stbl.stsd.table[0].wave; memcpy(wave->frma.codec, codec, 4); wave->has_frma = 1; trak->mdia.minf.stbl.stsd.table[0].has_wave = 1; } libquicktime-1.2.4/src/tmcd.c0000644000175000017500000000416211511622757013015 00000000000000/******************************************************************************* tmcd.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include void quicktime_tmcd_init(quicktime_tmcd_t *tmcd) { quicktime_tcmi_init(&tmcd->tcmi); } void quicktime_tmcd_delete(quicktime_tmcd_t *tmcd) { quicktime_tcmi_delete(&tmcd->tcmi); } void quicktime_tmcd_dump(quicktime_tmcd_t *tmcd) { lqt_dump(" tmcd\n"); quicktime_tcmi_dump(&tmcd->tcmi); } void quicktime_read_tmcd(quicktime_t *file, quicktime_tmcd_t *tmcd, quicktime_atom_t *parent_atom) { quicktime_atom_t leaf_atom; do { quicktime_atom_read_header(file, &leaf_atom); if(quicktime_atom_is(&leaf_atom, "tcmi")) { quicktime_read_tcmi(file, &tmcd->tcmi); } else quicktime_atom_skip(file, &leaf_atom); }while(quicktime_position(file) < parent_atom->end); } void quicktime_write_tmcd(quicktime_t *file, quicktime_tmcd_t *tmcd) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "tmcd"); quicktime_write_tcmi(file, &tmcd->tcmi); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/mdat.c0000644000175000017500000000257611511622756013021 00000000000000/******************************************************************************* mdat.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" void quicktime_mdat_delete(quicktime_mdat_t *mdat) { } void quicktime_read_mdat(quicktime_t *file, quicktime_mdat_t *mdat, quicktime_atom_t *parent_atom) { mdat->atom.size = parent_atom->size; mdat->atom.start = parent_atom->start; quicktime_atom_skip(file, parent_atom); } libquicktime-1.2.4/src/fiel.c0000644000175000017500000000615211511622756013005 00000000000000/******************************************************************************* fiel.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include void quicktime_fiel_init(quicktime_fiel_t *fiel) { memset(fiel, 0, sizeof (*fiel)); } void quicktime_fiel_delete(quicktime_fiel_t *fiel) { } void quicktime_fiel_dump(quicktime_fiel_t *fiel) { lqt_dump(" fields (fiel)\n"); lqt_dump(" fields: %d\n", fiel->fields); lqt_dump(" dominance: %d\n", fiel->dominance); } void quicktime_read_fiel(quicktime_t *file, quicktime_fiel_t *fiel) { fiel->fields = quicktime_read_char(file); fiel->dominance = quicktime_read_char(file); } void quicktime_write_fiel(quicktime_t *file, quicktime_fiel_t *fiel) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "fiel"); quicktime_write_char(file, fiel->fields); quicktime_write_char(file, fiel->dominance); quicktime_atom_write_footer(file, &atom); } int lqt_get_fiel(quicktime_t *file, int track, int *nfields, int *dominance) { quicktime_stsd_table_t *stsdt_p; if ((track < 0) || (track >= file->total_vtracks)) return 0; stsdt_p = file->vtracks[track].track->mdia.minf.stbl.stsd.table; if (!stsdt_p->has_fiel) return 0; if (nfields != NULL) *nfields = stsdt_p->fiel.fields; if (dominance != NULL) *dominance = stsdt_p->fiel.dominance; return 1; } int lqt_set_fiel(quicktime_t *file, int track, int nfields, int dominance) { quicktime_stsd_table_t *stsdt_p; if ((track < 0) || (track >= file->total_vtracks)) return 0; if (nfields !=1 && nfields != 2) return 0; /* * http://developer.apple.com/quicktime/icefloe/dispatch019.html#fiel * * "dominance" is what Apple calls "detail". From what I can figure out * the term "bottom field first" corresponds to a "detail" setting of 14 and * "top field first" is a "detail" setting of 9. */ switch (dominance) { case 0: case 1: case 6: case 9: case 14: break; default: return 0; } stsdt_p = file->vtracks[track].track->mdia.minf.stbl.stsd.table; stsdt_p->fiel.fields = nfields; stsdt_p->fiel.dominance = dominance; stsdt_p->has_fiel = 1; return 1; } libquicktime-1.2.4/src/avi_ix.c0000644000175000017500000001232111511622756013340 00000000000000/******************************************************************************* avi_ix.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include static char* make_tag(int number, char *tag) { tag[0] = 'i'; tag[1] = 'x'; tag[2] = '0' + (number / 10); tag[3] = '0' + (number % 10); return tag; } quicktime_ix_t* quicktime_new_ix(quicktime_t *file, quicktime_trak_t *trak, quicktime_strl_t *strl) { quicktime_ix_t *ix = calloc(1, sizeof(quicktime_ix_t)); ix->base_offset = quicktime_position(file); make_tag(trak->tkhd.track_id - 1, ix->tag); ix->longs_per_entry = 2; ix->index_type = AVI_INDEX_OF_CHUNKS; memcpy(ix->chunk_id, strl->tag, 4); return ix; } void quicktime_delete_ix(quicktime_ix_t *ix) { if(ix->table) free(ix->table); free(ix); } void quicktime_update_ixtable(quicktime_t *file, quicktime_trak_t *trak, int64_t offset, int size) { quicktime_indx_t *indx = &trak->strl->indx; quicktime_ix_t *ix = indx->table[indx->table_size-1].ix; quicktime_ixtable_t *ix_table; /* Allocation */ if(ix->table_size >= ix->table_allocation) { int new_allocation = ix->table_allocation * 2; if(new_allocation < 1) new_allocation = 1; ix->table = realloc(ix->table, sizeof(quicktime_ixtable_t) * new_allocation); memset(ix->table + ix->table_size, 0, sizeof(quicktime_ixtable_t)*(new_allocation - ix->table_size)); ix->table_allocation = new_allocation; } /* Appendage */ ix_table = &ix->table[ix->table_size++]; ix_table->relative_offset = offset - ix->base_offset; ix_table->size = size; if(!trak->mdia.minf.is_audio && trak->mdia.minf.stbl.stss.total_entries) { /* If bit 31 of the size is set, we have *no* keyframe */ ix_table->size |= 0x80000000; } } void quicktime_write_ix(quicktime_t *file, quicktime_trak_t * trak) { int i; quicktime_strl_t *strl; quicktime_indx_t *indx; quicktime_ix_t *ix; strl = trak->strl; indx = &strl->indx; ix = indx->table[indx->table_size-1].ix; quicktime_atom_write_header(file, &ix->atom, ix->tag); /* longs per entry */ quicktime_write_int16_le(file, ix->longs_per_entry); /* index sub type */ quicktime_write_char(file, 0); /* index type */ quicktime_write_char(file, ix->index_type); /* entries in use */ quicktime_write_int32_le(file, ix->table_size); /* chunk ID */ quicktime_write_char32(file, ix->chunk_id); /* base offset */ quicktime_write_int64_le(file, ix->base_offset); /* reserved */ quicktime_write_int32_le(file, 0); /* table */ for(i = 0; i < ix->table_size; i++) { quicktime_ixtable_t *table = &ix->table[i]; quicktime_write_int32_le(file, table->relative_offset); quicktime_write_int32_le(file, table->size); } quicktime_atom_write_footer(file, &ix->atom); } void quicktime_read_ix(quicktime_t *file, quicktime_ix_t *ix) { int i; quicktime_atom_t leaf_atom; quicktime_atom_read_header(file, &leaf_atom); ix->longs_per_entry = quicktime_read_int16_le(file); /* sub type */ quicktime_read_char(file); ix->index_type = quicktime_read_char(file); ix->table_size = quicktime_read_int32_le(file); quicktime_read_char32(file, ix->chunk_id); ix->base_offset = quicktime_read_int64_le(file); /* reserved */ quicktime_read_int32_le(file); ix->table = calloc(ix->table_size, sizeof(quicktime_ixtable_t)); for(i = 0; i < ix->table_size; i++) { quicktime_ixtable_t *ixtable = &ix->table[i]; ixtable->relative_offset = quicktime_read_int32_le(file); ixtable->size = quicktime_read_int32_le(file); } } void quicktime_ix_dump(quicktime_ix_t *ix) { int i; lqt_dump(" table_size: %d\n", ix->table_size); lqt_dump(" longs_per_entry: %d\n", ix->longs_per_entry); lqt_dump(" index_type: %d\n", ix->index_type); lqt_dump(" base_offset: %"PRId64"\n", ix->base_offset); lqt_dump(" tag: %s\n", ix->tag); lqt_dump(" chunk_id: %s\n", ix->chunk_id); for(i = 0; i < ix->table_size; i++) { lqt_dump(" off: %d, size: %d, k: %d\n", ix->table[i].relative_offset, (ix->table[i].size & 0x7FFFFFFF), !(ix->table[i].size & 0x80000000)); } } libquicktime-1.2.4/src/stsc.c0000644000175000017500000001255711511622757013051 00000000000000/******************************************************************************* stsc.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include void quicktime_stsc_init(quicktime_stsc_t *stsc) { stsc->version = 0; stsc->flags = 0; stsc->total_entries = 0; stsc->entries_allocated = 0; } void quicktime_stsc_init_table(quicktime_t *file, quicktime_stsc_t *stsc) { if(!stsc->entries_allocated) { stsc->total_entries = 1; stsc->entries_allocated = 2048; stsc->table = (quicktime_stsc_table_t*)calloc(1, sizeof(quicktime_stsc_table_t) * stsc->entries_allocated); } } void quicktime_stsc_init_video(quicktime_t *file, quicktime_stsc_t *stsc) { quicktime_stsc_table_t *table; quicktime_stsc_init_table(file, stsc); table = &stsc->table[0]; table->chunk = 1; table->samples = 1; table->id = 1; } void quicktime_stsc_init_audio(quicktime_t *file, quicktime_stsc_t *stsc, int sample_rate) { quicktime_stsc_table_t *table; quicktime_stsc_init_table(file, stsc); table = &stsc->table[0]; table->chunk = 1; table->samples = 0; /* set this after completion or after every audio chunk is written */ table->id = 1; } void quicktime_stsc_delete(quicktime_stsc_t *stsc) { if(stsc->total_entries) free(stsc->table); stsc->total_entries = 0; } void quicktime_stsc_dump(quicktime_stsc_t *stsc) { int i; lqt_dump(" sample to chunk (stsc)\n"); lqt_dump(" version %d\n", stsc->version); lqt_dump(" flags %ld\n", stsc->flags); lqt_dump(" total_entries %ld\n", stsc->total_entries); for(i = 0; i < stsc->total_entries; i++) { lqt_dump(" chunk %ld samples %lx id %ld\n", stsc->table[i].chunk, stsc->table[i].samples, stsc->table[i].id); } } void quicktime_read_stsc(quicktime_t *file, quicktime_stsc_t *stsc) { int i; stsc->version = quicktime_read_char(file); stsc->flags = quicktime_read_int24(file); stsc->total_entries = quicktime_read_int32(file); stsc->entries_allocated = stsc->total_entries; stsc->table = (quicktime_stsc_table_t*)malloc(sizeof(quicktime_stsc_table_t) * stsc->total_entries); for(i = 0; i < stsc->total_entries; i++) { stsc->table[i].chunk = quicktime_read_int32(file); stsc->table[i].samples = quicktime_read_int32(file); stsc->table[i].id = quicktime_read_int32(file); } } void quicktime_compress_stsc(quicktime_stsc_t *stsc) { int i, last_same; /* This can happen, if a stream was created, but no samples have been written. The resulting file will be invalid anyway, just don't let us crash */ if(!stsc->table) return; for(i = 1, last_same = 0; i < stsc->total_entries; i++) { if(stsc->table[i].samples != stsc->table[last_same].samples) { /* An entry has a different sample count. */ last_same++; if(last_same < i) { /* Move it up the list. */ stsc->table[last_same] = stsc->table[i]; } } } last_same++; stsc->total_entries = last_same; } void quicktime_write_stsc(quicktime_t *file, quicktime_stsc_t *stsc) { int i; quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "stsc"); quicktime_write_char(file, stsc->version); quicktime_write_int24(file, stsc->flags); quicktime_write_int32(file, stsc->total_entries); for(i = 0; i < stsc->total_entries; i++) { quicktime_write_int32(file, stsc->table[i].chunk); quicktime_write_int32(file, stsc->table[i].samples); quicktime_write_int32(file, stsc->table[i].id); } quicktime_atom_write_footer(file, &atom); } int quicktime_update_stsc(quicktime_stsc_t *stsc, long chunk, long samples) { chunk++; if(chunk > stsc->entries_allocated) { stsc->entries_allocated = chunk * 2; stsc->table =(quicktime_stsc_table_t*)realloc(stsc->table, sizeof(quicktime_stsc_table_t) * stsc->entries_allocated); } stsc->table[chunk - 1].samples = samples; stsc->table[chunk - 1].chunk = chunk; stsc->table[chunk - 1].id = 1; if(chunk > stsc->total_entries) stsc->total_entries = chunk; return 0; } /* Optimizing while writing doesn't allow seeks during recording so */ /* entries are created for every chunk and only optimized during */ /* writeout. Unfortunately there's no way to keep audio synchronized */ /* after overwriting a recording as the fractional audio chunk in the */ /* middle always overwrites the previous location of a larger chunk. On */ /* writing, the table must be optimized. RealProducer requires an */ /* optimized table. */ libquicktime-1.2.4/src/enda.c0000644000175000017500000000416111511622756012773 00000000000000/******************************************************************************* enda.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" void quicktime_read_enda(quicktime_t *file, quicktime_enda_t *enda, quicktime_atom_t *enda_atom) { enda->littleEndian = quicktime_read_int16(file); } void quicktime_write_enda(quicktime_t *file, quicktime_enda_t *enda) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "enda"); quicktime_write_int16(file, !!enda->littleEndian); quicktime_atom_write_footer(file, &atom); } void quicktime_set_enda(quicktime_stsd_table_t *table, int little_endian) { quicktime_wave_t * wave = &table->wave; wave->enda.littleEndian = little_endian; wave->has_enda = 1; table->has_wave = 1; } void quicktime_enda_dump(quicktime_enda_t *enda) { lqt_dump(" enda: \n"); lqt_dump(" littleEndian: %d\n", enda->littleEndian); } /* Returns TRUE if little endian */ int quicktime_get_enda(quicktime_stsd_table_t *table) { quicktime_wave_t * wave = &table->wave; if(wave->has_enda) { return wave->enda.littleEndian; } else return 0; } libquicktime-1.2.4/src/avi_strh.c0000644000175000017500000001116211511622756013702 00000000000000/******************************************************************************* avi_strh.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" /* * char fccType[4]; char fccHandler[4]; uint32_t dwFlags; uint32_t dwReserved1; uint32_t dwInitialFrames; uint32_t dwScale; uint32_t dwRate; uint32_t dwStart; uint32_t dwLength; uint32_t dwSuggestedBufferSize; uint32_t dwQuality; uint32_t dwSampleSize; * */ void quicktime_read_strh(quicktime_t *file, quicktime_strh_t *strh, quicktime_atom_t *parent_atom) { quicktime_read_data(file, (uint8_t*)(strh->fccType), 4); quicktime_read_data(file, (uint8_t*)(strh->fccHandler), 4); strh->dwFlags = quicktime_read_int32_le(file); strh->dwReserved1 = quicktime_read_int32_le(file); strh->dwInitialFrames = quicktime_read_int32_le(file); strh->dwScale = quicktime_read_int32_le(file); strh->dwRate = quicktime_read_int32_le(file); strh->dwStart = quicktime_read_int32_le(file); strh->dwLength = quicktime_read_int32_le(file); strh->dwSuggestedBufferSize = quicktime_read_int32_le(file); strh->dwQuality = quicktime_read_int32_le(file); strh->dwSampleSize = quicktime_read_int32_le(file); strh->rcFrame.left = quicktime_read_int16_le(file); strh->rcFrame.top = quicktime_read_int16_le(file); strh->rcFrame.right = quicktime_read_int16_le(file); strh->rcFrame.bottom = quicktime_read_int16_le(file); } void quicktime_write_strh(quicktime_t *file, quicktime_strh_t *strh) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "strh"); quicktime_write_data(file, (uint8_t*)(strh->fccType), 4); quicktime_write_data(file, (uint8_t*)(strh->fccHandler), 4); quicktime_write_int32_le(file, strh->dwFlags); quicktime_write_int32_le(file, strh->dwReserved1); quicktime_write_int32_le(file, strh->dwInitialFrames); quicktime_write_int32_le(file, strh->dwScale); quicktime_write_int32_le(file, strh->dwRate); quicktime_write_int32_le(file, strh->dwStart); quicktime_write_int32_le(file, strh->dwLength); quicktime_write_int32_le(file, strh->dwSuggestedBufferSize); quicktime_write_int32_le(file, strh->dwQuality); quicktime_write_int32_le(file, strh->dwSampleSize); quicktime_write_int16_le(file, strh->rcFrame.left); quicktime_write_int16_le(file, strh->rcFrame.top); quicktime_write_int16_le(file, strh->rcFrame.right); quicktime_write_int16_le(file, strh->rcFrame.bottom); quicktime_atom_write_footer(file, &atom); } void quicktime_strh_dump(quicktime_strh_t *strh) { lqt_dump(" strh\n"); lqt_dump(" fccType: %.4s\n", strh->fccType); lqt_dump(" fccHandler: %.4s\n", strh->fccHandler); lqt_dump(" dwFlags: %08x\n", strh->dwFlags); lqt_dump(" dwReserved1: %08x\n", strh->dwReserved1); lqt_dump(" dwInitialFrames: %d\n", strh->dwInitialFrames); lqt_dump(" dwScale: %d\n", strh->dwScale); lqt_dump(" dwRate: %d\n", strh->dwRate); lqt_dump(" dwStart: %d\n", strh->dwStart); lqt_dump(" dwLength: %d\n", strh->dwLength); lqt_dump(" dwSuggestedBufferSize: %d\n", strh->dwSuggestedBufferSize); lqt_dump(" dwQuality: %d\n", strh->dwQuality); lqt_dump(" dwSampleSize: %d\n", strh->dwSampleSize); lqt_dump(" rcFrame: l: %d t: %d r: %d b: %d\n", strh->rcFrame.left, strh->rcFrame.top, strh->rcFrame.right, strh->rcFrame.bottom); } libquicktime-1.2.4/src/nloc.c0000644000175000017500000000553111511622757013022 00000000000000/******************************************************************************* nloc.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" int quicktime_nloc_init(quicktime_nloc_t *nloc) { nloc->version = 2; nloc->revision = 0; nloc->locationFlags = 0; nloc->locationData = 0; nloc->nodeType[0] = 'o'; nloc->nodeType[1] = 'b'; nloc->nodeType[2] = 'j'; nloc->nodeType[3] = 'e'; return 0; } int quicktime_nloc_delete(quicktime_nloc_t *nloc) { return 0; } void quicktime_nloc_dump(quicktime_nloc_t *nloc) { lqt_dump(" node location (nloc)\n"); lqt_dump(" version %i\n", nloc->version); lqt_dump(" revision %i\n", nloc->revision); lqt_dump(" node type %c%c%c%c\n", nloc->nodeType[0], nloc->nodeType[1], nloc->nodeType[2], nloc->nodeType[3]); lqt_dump(" location flags %ld\n", nloc->locationFlags); lqt_dump(" location data %ld\n", nloc->locationData); } int quicktime_read_nloc(quicktime_t *file, quicktime_nloc_t *nloc, quicktime_qtatom_t *nloc_atom) { nloc->version = quicktime_read_int16(file); nloc->revision = quicktime_read_int16(file); quicktime_read_char32(file, nloc->nodeType); nloc->locationFlags = quicktime_read_int32(file); nloc->locationData = quicktime_read_int32(file); nloc->reserved1 = quicktime_read_int32(file); nloc->reserved2 = quicktime_read_int32(file); return 0; } void quicktime_write_nloc(quicktime_t *file, quicktime_nloc_t *nloc) { quicktime_qtatom_t atom; quicktime_qtatom_write_header(file, &atom, "nloc", 1); quicktime_write_int16(file, nloc->version); quicktime_write_int16(file, nloc->revision); quicktime_write_char32(file, nloc->nodeType); quicktime_write_int32(file, nloc->locationFlags); quicktime_write_int32(file, nloc->locationData); quicktime_write_int32(file, nloc->reserved1); quicktime_write_int32(file, nloc->reserved2); quicktime_qtatom_write_footer(file, &atom); } libquicktime-1.2.4/src/gama.c0000644000175000017500000000334611511622756012775 00000000000000/******************************************************************************* gama.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include void quicktime_gama_init(quicktime_gama_t *gama) { memset(gama, 0, sizeof (*gama)); } void quicktime_gama_delete(quicktime_gama_t *gama) { } void quicktime_gama_dump(quicktime_gama_t *gama) { lqt_dump(" Gamma value (gama): %f\n", gama->gamma); } void quicktime_read_gama(quicktime_t *file, quicktime_gama_t *gama) { gama->gamma = quicktime_read_fixed32(file); } void quicktime_write_gama(quicktime_t *file, quicktime_gama_t *gama) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "gama"); quicktime_write_fixed32(file, gama->gamma); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/avi_movi.c0000644000175000017500000000343711511622756013702 00000000000000/******************************************************************************* avi_movi.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" void quicktime_delete_movi(quicktime_t *file, quicktime_movi_t *movi) { } void quicktime_init_movi(quicktime_t *file, quicktime_riff_t *riff) { quicktime_movi_t *movi = &riff->movi; quicktime_atom_write_header(file, &movi->atom, "LIST"); quicktime_write_char32(file, "movi"); } void quicktime_read_movi(quicktime_t *file, quicktime_atom_t *parent_atom, quicktime_movi_t *movi) { movi->atom.size = parent_atom->size; // Relative to start of the movi string movi->atom.start = parent_atom->start + 8; quicktime_atom_skip(file, parent_atom); } void quicktime_finalize_movi(quicktime_t *file, quicktime_movi_t *movi) { quicktime_atom_write_footer(file, &movi->atom); } libquicktime-1.2.4/src/texttrack.c0000644000175000017500000003647311511622757014111 00000000000000/******************************************************************************* texttrack.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include "charset.h" #include #include #define LOG_DOMAIN "texttrack" /* Common functions */ void lqt_init_text_map(quicktime_t * file, quicktime_text_map_t * map, quicktime_trak_t * trak, int encode) { const char * charset; const char * charset_fallback; map->track = trak; map->cur_chunk = 0; if(!encode) { charset = lqt_get_charset(trak->mdia.mdhd.language, file->file_type); charset_fallback = lqt_get_charset_fallback(trak->mdia.mdhd.language, file->file_type); if(!charset && !charset_fallback) { lqt_log(file, LQT_LOG_WARNING, LOG_DOMAIN, "Cannot determine character set of text track, will copy the strings verbatim"); return; } else { if(charset) map->cnv = lqt_charset_converter_create(file, charset, "UTF-8"); if(!map->cnv && charset_fallback) map->cnv = lqt_charset_converter_create(file, charset_fallback, "UTF-8"); } if(!map->cnv) lqt_log(file, LQT_LOG_WARNING, LOG_DOMAIN, "Unsupported charset in text track, will copy the strings verbatim"); } } void lqt_delete_text_map(quicktime_t * file, quicktime_text_map_t * map) { if(map->text_buffer) free(map->text_buffer); if(map->cnv) lqt_charset_converter_destroy(map->cnv); } /* Decoding */ int lqt_text_tracks(quicktime_t * file) { int i, result = 0; quicktime_minf_t *minf; for(i = 0; i < file->moov.total_tracks; i++) { minf = &file->moov.trak[i]->mdia.minf; if(minf->is_text) result++; } return result; } int lqt_text_time_scale(quicktime_t * file, int track) { return file->ttracks[track].track->mdia.mdhd.time_scale; } int lqt_read_text(quicktime_t * file, int track, char ** text, int * text_alloc, int64_t * timestamp, int64_t * duration) { int64_t file_position, stts_index = 0, stts_count = 0; char * ptr; int string_length; quicktime_text_map_t * ttrack = &file->ttracks[track]; quicktime_trak_t * trak = ttrack->track; quicktime_stts_t * stts = &trak->mdia.minf.stbl.stts; if(ttrack->current_position >= quicktime_track_samples(file, trak)) return 0; // EOF /* Get the file position */ file_position = quicktime_sample_to_offset(file, trak, ttrack->current_position); quicktime_set_position(file, file_position); string_length = quicktime_read_int16(file); if(string_length) { /* Read whole sample */ if(ttrack->text_buffer_alloc < string_length) { ttrack->text_buffer_alloc = string_length + 128; ttrack->text_buffer = realloc(ttrack->text_buffer, ttrack->text_buffer_alloc); } quicktime_read_data(file, (uint8_t*)ttrack->text_buffer, string_length); if(ttrack->cnv) { /* Convert character set */ lqt_charset_convert_realloc(ttrack->cnv, ttrack->text_buffer, string_length, text, text_alloc, (int*)0); } else /* Copy verbatim */ { if(*text_alloc < string_length) { *text_alloc = string_length + 64; *text = realloc(*text, *text_alloc); memcpy(*text, ttrack->text_buffer, string_length); } } } else /* Empty string */ { if(*text_alloc < 1) { *text_alloc = 1; *text = realloc(*text, 1); } (*text)[0] = '\0'; } *timestamp = quicktime_sample_to_time(stts, ttrack->current_position, &stts_index, &stts_count); *duration = stts->table[stts_index].sample_duration; /* de-macify linebreaks */ ptr = *text; while(*ptr != '\0') { if(*ptr == '\r') *ptr = '\n'; ptr++; } ttrack->current_position++; return 1; } int lqt_is_chapter_track(quicktime_t * file, int track) { int i, j, k; quicktime_trak_t * trak = file->ttracks[track].track; for(i = 0; i < file->moov.total_tracks; i++) { if(file->moov.trak[i] == trak) continue; /* Track reference present */ if(file->moov.trak[i]->has_tref) { for(j = 0; j < file->moov.trak[i]->tref.num_references; j++) { /* Track reference has type chap */ if(quicktime_match_32(file->moov.trak[i]->tref.references[j].type, "chap")) { for(k = 0; k < file->moov.trak[i]->tref.references[j].num_tracks; k++) { /* Track reference points to us */ if(file->moov.trak[i]->tref.references[j].tracks[k] == trak->tkhd.track_id) return 1; } } } } } return 0; } int64_t lqt_text_samples(quicktime_t * file, int track) { return quicktime_track_samples(file, file->ttracks[track].track); } void lqt_set_text_position(quicktime_t * file, int track, int64_t position) { file->ttracks[track].current_position = position; } void lqt_set_text_time(quicktime_t * file, int track, int64_t time) { int64_t stts_index, stts_count; quicktime_text_map_t * ttrack = &file->ttracks[track]; quicktime_trak_t * trak = ttrack->track; file->ttracks[track].current_position = quicktime_time_to_sample(&trak->mdia.minf.stbl.stts, &time, &stts_index, &stts_count); } /* Encoding */ int lqt_add_text_track(quicktime_t * file, int timescale) { quicktime_trak_t * trak; file->ttracks = realloc(file->ttracks, (file->total_ttracks+1)*sizeof(quicktime_text_map_t)); memset(&file->ttracks[file->total_ttracks], 0, sizeof(quicktime_text_map_t)); trak = quicktime_add_track(file); if(IS_MP4(file->file_type)) quicktime_trak_init_tx3g(file, trak, timescale); else if(file->file_type & (LQT_FILE_QT | LQT_FILE_QT_OLD)) quicktime_trak_init_text(file, trak, timescale); else lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "Text track not supported for this file"); lqt_init_text_map(file, &file->ttracks[file->total_ttracks], trak, 1); file->total_ttracks++; return 0; } void lqt_set_chapter_track(quicktime_t * file, int track) { file->ttracks[track].is_chapter_track = 1; } static void make_chapter_track(quicktime_t * file, quicktime_trak_t * trak) { quicktime_trak_t * ref_track; /* We create one "chap" reference in one other track. Choose the first video track if possible */ if(file->total_vtracks) ref_track = file->vtracks[0].track; else if(file->total_atracks) ref_track = file->atracks[0].track; else { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "Need at least one audio or video stream for chapters"); return; } quicktime_tref_init_chap(&ref_track->tref, trak->tkhd.track_id); ref_track->has_tref = 1; } int lqt_write_text(quicktime_t * file, int track, const char * text, int64_t duration) { const char * charset; const char * charset_fallback; quicktime_text_map_t * ttrack; quicktime_trak_t * trak; int out_len; ttrack = &file->ttracks[track]; trak = ttrack->track; /* Issue a warning for AVI files (No subitles are supported here) */ if(file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML)) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "Subtitles are not supported in AVI files"); return 1; } if(!ttrack->initialized) { /* Create character set converter */ if(file->file_type & (LQT_FILE_QT_OLD|LQT_FILE_QT)) { charset = lqt_get_charset(trak->mdia.mdhd.language, file->file_type); charset_fallback = lqt_get_charset_fallback(trak->mdia.mdhd.language, file->file_type); if(!charset && !charset_fallback) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "Subtitles character set could not be determined, string will be copied verbatim"); } else { if(charset) ttrack->cnv = lqt_charset_converter_create(file, "UTF-8", charset); if(!ttrack->cnv && charset_fallback) ttrack->cnv = lqt_charset_converter_create(file, "UTF-8", charset_fallback); if(!ttrack->cnv) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "Unsupported character set in text track, string will be copied verbatim"); } } } /* Set up chapter track */ if(ttrack->is_chapter_track) make_chapter_track(file, trak); ttrack->initialized = 1; } quicktime_write_chunk_header(file, trak); if(text) { if(ttrack->cnv) { lqt_charset_convert_realloc(ttrack->cnv, text, -1, &ttrack->text_buffer, &ttrack->text_buffer_alloc, &out_len); quicktime_write_int16(file, out_len); quicktime_write_data(file, (uint8_t*)ttrack->text_buffer, out_len); } else { out_len = strlen(text); quicktime_write_int16(file, out_len); quicktime_write_data(file, (uint8_t*)text, out_len); } } else { quicktime_write_int16(file, 0); } trak->chunk_samples = 1; quicktime_write_chunk_footer(file, trak); quicktime_update_stts(&trak->mdia.minf.stbl.stts, ttrack->current_position, duration); ttrack->cur_chunk++; ttrack->current_position++; return 0; } /* Rectangle */ void lqt_set_text_box(quicktime_t * file, int track, uint16_t top, uint16_t left, uint16_t bottom, uint16_t right) { quicktime_trak_t * trak; quicktime_stsd_table_t * stsd; trak = file->ttracks[track].track; stsd = &trak->mdia.minf.stbl.stsd.table[0]; if(quicktime_match_32(stsd->format, "text")) { trak->tkhd.matrix.values[6] += (float)left; trak->tkhd.matrix.values[7] += (float)top; trak->tkhd.track_width = right - left; trak->tkhd.track_height = bottom - top; } else if(quicktime_match_32(stsd->format, "tx3g")) { trak->tkhd.track_width = right - left; trak->tkhd.track_height = bottom - top; stsd->tx3g.defaultTextBox[0] = top; stsd->tx3g.defaultTextBox[1] = left; stsd->tx3g.defaultTextBox[2] = bottom; stsd->tx3g.defaultTextBox[3] = right; } } void lqt_get_text_box(quicktime_t * file, int track, uint16_t * top, uint16_t * left, uint16_t * bottom, uint16_t * right) { quicktime_trak_t * trak; quicktime_stsd_table_t * stsd; trak = file->ttracks[track].track; stsd = &trak->mdia.minf.stbl.stsd.table[0]; if(quicktime_match_32(stsd->format, "text")) { *top = stsd->text.defaultTextBox[0]; *left = stsd->text.defaultTextBox[1]; *bottom = stsd->text.defaultTextBox[2]; *right = stsd->text.defaultTextBox[3]; } else if(quicktime_match_32(stsd->format, "tx3g")) { *top = stsd->tx3g.defaultTextBox[0]; *left = stsd->tx3g.defaultTextBox[1]; *bottom = stsd->tx3g.defaultTextBox[2]; *right = stsd->tx3g.defaultTextBox[3]; } } void lqt_set_text_fg_color(quicktime_t * file, int track, uint16_t r, uint16_t g, uint16_t b, uint16_t a) { quicktime_trak_t * trak; quicktime_stsd_table_t * stsd; trak = file->ttracks[track].track; stsd = &trak->mdia.minf.stbl.stsd.table[0]; if(quicktime_match_32(stsd->format, "text")) { stsd->text.scrpColor[0] = r; stsd->text.scrpColor[1] = g; stsd->text.scrpColor[2] = b; } else if(quicktime_match_32(stsd->format, "tx3g")) { stsd->tx3g.text_color[0] = r >> 8; stsd->tx3g.text_color[1] = g >> 8; stsd->tx3g.text_color[2] = b >> 8; stsd->tx3g.text_color[3] = a >> 8; } } void lqt_set_text_bg_color(quicktime_t * file, int track, uint16_t r, uint16_t g, uint16_t b, uint16_t a) { quicktime_trak_t * trak; quicktime_stsd_table_t * stsd; trak = file->ttracks[track].track; stsd = &trak->mdia.minf.stbl.stsd.table[0]; if(quicktime_match_32(stsd->format, "text")) { stsd->text.bgColor[0] = r; stsd->text.bgColor[1] = g; stsd->text.bgColor[2] = b; if(a < 0x8000) stsd->text.displayFlags |= 0x4000; } else if(quicktime_match_32(stsd->format, "tx3g")) { stsd->tx3g.back_color[0] = r >> 8; stsd->tx3g.back_color[1] = g >> 8; stsd->tx3g.back_color[2] = b >> 8; stsd->tx3g.back_color[3] = a >> 8; } } void lqt_get_text_fg_color(quicktime_t * file, int track, uint16_t * r, uint16_t * g, uint16_t * b, uint16_t * a) { quicktime_trak_t * trak; quicktime_stsd_table_t * stsd; trak = file->ttracks[track].track; stsd = &trak->mdia.minf.stbl.stsd.table[0]; if(quicktime_match_32(stsd->format, "text")) { *r = stsd->text.scrpColor[0]; *g = stsd->text.scrpColor[1]; *b = stsd->text.scrpColor[2]; *a = 0xffff; } else if(quicktime_match_32(stsd->format, "tx3g")) { *r = (stsd->tx3g.text_color[0] << 8) | stsd->tx3g.text_color[0]; *g = (stsd->tx3g.text_color[1] << 8) | stsd->tx3g.text_color[1]; *b = (stsd->tx3g.text_color[2] << 8) | stsd->tx3g.text_color[2]; *a = (stsd->tx3g.text_color[3] << 8) | stsd->tx3g.text_color[3]; } } void lqt_get_text_bg_color(quicktime_t * file, int track, uint16_t * r, uint16_t * g, uint16_t * b, uint16_t * a) { quicktime_trak_t * trak; quicktime_stsd_table_t * stsd; trak = file->ttracks[track].track; stsd = &trak->mdia.minf.stbl.stsd.table[0]; if(quicktime_match_32(stsd->format, "text")) { *r = stsd->text.bgColor[0]; *g = stsd->text.bgColor[1]; *b = stsd->text.bgColor[2]; if(stsd->text.displayFlags & 0x4000) *a = 0x0000; else *a = 0xFFFF; } else if(quicktime_match_32(stsd->format, "tx3g")) { *r = (stsd->tx3g.back_color[0] << 8) | stsd->tx3g.back_color[0]; *g = (stsd->tx3g.back_color[1] << 8) | stsd->tx3g.back_color[1]; *b = (stsd->tx3g.back_color[2] << 8) | stsd->tx3g.back_color[2]; *a = (stsd->tx3g.back_color[3] << 8) | stsd->tx3g.back_color[3]; } } libquicktime-1.2.4/src/stco.c0000644000175000017500000001110411511622757013030 00000000000000/******************************************************************************* stco.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #define LOG_DOMAIN "stco" void quicktime_stco_init(quicktime_stco_t *stco) { stco->version = 0; stco->flags = 0; stco->total_entries = 0; stco->entries_allocated = 0; } void quicktime_stco_delete(quicktime_stco_t *stco) { if(stco->table) free(stco->table); stco->total_entries = 0; stco->entries_allocated = 0; } void quicktime_stco_init_common(quicktime_t *file, quicktime_stco_t *stco) { if(!stco->entries_allocated) { stco->entries_allocated = 2048; stco->total_entries = 0; stco->table = (quicktime_stco_table_t*)malloc(sizeof(quicktime_stco_table_t) * stco->entries_allocated); } } void quicktime_stco_dump(quicktime_stco_t *stco) { int i; if(stco->co64) lqt_dump(" chunk offset (co64)\n"); else lqt_dump(" chunk offset (stco)\n"); lqt_dump(" version %d\n", stco->version); lqt_dump(" flags %ld\n", stco->flags); lqt_dump(" total_entries %ld\n", stco->total_entries); for(i = 0; i < stco->total_entries; i++) { lqt_dump(" offset %d %"PRId64" (%"PRIx64")\n", i, stco->table[i].offset, stco->table[i].offset); } } void quicktime_read_stco(quicktime_t *file, quicktime_stco_t *stco) { int i; stco->version = quicktime_read_char(file); stco->flags = quicktime_read_int24(file); stco->total_entries = quicktime_read_int32(file); stco->entries_allocated = stco->total_entries; stco->table = (quicktime_stco_table_t*)calloc(1, sizeof(quicktime_stco_table_t) * stco->entries_allocated); for(i = 0; i < stco->total_entries; i++) { stco->table[i].offset = quicktime_read_uint32(file); } } void quicktime_read_stco64(quicktime_t *file, quicktime_stco_t *stco) { int i; stco->version = quicktime_read_char(file); stco->flags = quicktime_read_int24(file); stco->total_entries = quicktime_read_int32(file); stco->entries_allocated = stco->total_entries; stco->table = (quicktime_stco_table_t*)calloc(1, sizeof(quicktime_stco_table_t) * stco->entries_allocated); for(i = 0; i < stco->total_entries; i++) { stco->table[i].offset = quicktime_read_int64(file); } stco->co64 = 1; } void quicktime_write_stco(quicktime_t *file, quicktime_stco_t *stco) { int i; quicktime_atom_t atom; if(stco->co64) quicktime_atom_write_header(file, &atom, "co64"); else quicktime_atom_write_header(file, &atom, "stco"); quicktime_write_char(file, stco->version); quicktime_write_int24(file, stco->flags); quicktime_write_int32(file, stco->total_entries); if(stco->co64) { for(i = 0; i < stco->total_entries; i++) quicktime_write_int64(file, stco->table[i].offset); } else { for(i = 0; i < stco->total_entries; i++) quicktime_write_int32(file, stco->table[i].offset); } quicktime_atom_write_footer(file, &atom); } void quicktime_update_stco(quicktime_stco_t *stco, long chunk, int64_t offset) { // Chunk starts at 1 chunk++; if(chunk <= 0) lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "quicktime_update_stco chunk must start at 1. chunk=%ld\n", chunk); if(chunk > stco->entries_allocated) { stco->entries_allocated = chunk * 2; stco->table = (quicktime_stco_table_t*)realloc(stco->table, sizeof(quicktime_stco_table_t) * stco->entries_allocated); } stco->table[chunk - 1].offset = offset; if(chunk > stco->total_entries) stco->total_entries = chunk; if(offset >= 0x100000000LL) stco->co64 = 1; } libquicktime-1.2.4/src/qtatom.c0000644000175000017500000001333411511622757013374 00000000000000/******************************************************************************* qtatom.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include static int read_type(uint8_t *data, uint8_t *type) { type[0] = data[4]; type[1] = data[5]; type[2] = data[6]; type[3] = data[7]; /* need this for quicktime_check_sig */ if(isalpha(type[0]) && isalpha(type[1]) && isalpha(type[2]) && isalpha(type[3])) return 0; else return 1; } static unsigned long read_size(uint8_t *data) { unsigned long result; unsigned long a, b, c, d; a = data[0]; b = data[1]; c = data[2]; d = data[3]; result = (a << 24) | (b << 16) | (c << 8) | d; // extended header is size 1 // if(result < HEADER_LENGTH) result = HEADER_LENGTH; return result; } static int64_t read_size64(uint8_t *data) { uint64_t result, a, b, c, d, e, f, g, h; a = data[0]; b = data[1]; c = data[2]; d = data[3]; e = data[4]; f = data[5]; g = data[6]; h = data[7]; result = (a << 56) | (b << 48) | (c << 40) | (d << 32) | (e << 24) | (f << 16) | (g << 8) | h; if(result < HEADER_LENGTH) result = HEADER_LENGTH; return (int64_t)result; } static unsigned long read_ID(uint8_t *data) { unsigned long result; unsigned long a, b, c, d; a = data[0]; b = data[1]; c = data[2]; d = data[3]; result = (a << 24) | (b << 16) | (c << 8) | d; return result; } static uint16_t read_childcount(uint8_t *data) { uint16_t result, a, b; a = data[0]; b = data[1]; result = (a << 8) | b; return (uint16_t)result; } static int reset_qtatom(quicktime_qtatom_t *atom) { atom->end = 0; atom->type[0] = atom->type[1] = atom->type[2] = atom->type[3] = 0; return 0; } int quicktime_qtatom_read_header(quicktime_t *file, quicktime_qtatom_t *atom) { int result = 0; uint8_t header[10]; reset_qtatom(atom); atom->start = quicktime_position(file); if(!quicktime_read_data(file, header, HEADER_LENGTH)) return 1; result = read_type(header, atom->type); atom->size = read_size(header); atom->end = atom->start + atom->size; /* Skip placeholder atom */ if(quicktime_match_32(atom->type, "wide")) { atom->start = quicktime_position(file); reset_qtatom(atom); if(!quicktime_read_data(file, header, HEADER_LENGTH)) return 1; result = read_type(header, atom->type); atom->size -= 8; if(atom->size <= 0) { /* Wrapper ended. Get new atom size */ atom->size = read_size(header); } atom->end = atom->start + atom->size; } else /* Get extended size */ if(atom->size == 1) { if(!quicktime_read_data(file, header, HEADER_LENGTH)) return 1; atom->size = read_size64(header); atom->end = atom->start + atom->size; } quicktime_read_data(file, header, 4); atom->ID = read_ID(header); quicktime_set_position(file, quicktime_position(file) + 2); quicktime_read_data(file, header, 2); atom->child_count = read_childcount(header); quicktime_set_position(file, quicktime_position(file) + 4); return result; } int quicktime_qtatom_write_header(quicktime_t *file, quicktime_qtatom_t *atom, char *text, long ID) { int result = 0; atom->start = quicktime_position(file); result = !quicktime_write_int32(file, 0); if(!result) result = !quicktime_write_char32(file, text); if(!result) result = !quicktime_write_int32(file, ID); if(!result) result = !quicktime_write_int32(file, 0); if(!result) result = !quicktime_write_int32(file, 0); atom->child_count = 0; atom->use_64 = 0; return result; } void quicktime_qtatom_write_footer(quicktime_t *file, quicktime_qtatom_t *atom) { atom->end = quicktime_position(file); if(atom->use_64) { quicktime_set_position(file, atom->start + 8); quicktime_write_int64(file, atom->end - atom->start); } else { quicktime_set_position(file, atom->start); quicktime_write_int32(file, atom->end - atom->start); quicktime_set_position(file, atom->start + 14); if (atom->end - atom->start <= 20) { atom->child_count = 0; } else { quicktime_set_position(file, atom->start + 14); quicktime_write_int16(file, atom->child_count); } } quicktime_set_position(file, atom->end); } int quicktime_qtatom_is(quicktime_qtatom_t *atom, char *type) { if(atom->type[0] == (uint8_t)type[0] && atom->type[1] == (uint8_t)type[1] && atom->type[2] == (uint8_t)type[2] && atom->type[3] == (uint8_t)type[3]) return 1; else return 0; } void quicktime_qtatom_read_container_header(quicktime_t *file) { uint8_t data[12]; quicktime_read_data(file, data, 12); return; } void quicktime_qtatom_write_container_header(quicktime_t *file) { uint8_t data[12]; memset(data, 0, sizeof(data)); quicktime_write_data(file, data, 12); return; } int quicktime_qtatom_skip(quicktime_t *file, quicktime_qtatom_t *atom) { if(atom->start == atom->end) atom->end++; return quicktime_set_position(file, atom->end); } libquicktime-1.2.4/src/ftyp.c0000644000175000017500000001406411511622756013051 00000000000000/******************************************************************************* ftyp.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include #define MK_FOURCC(a, b, c, d) \ (((uint32_t)a << 24) | \ ((uint32_t)b << 16) | \ ((uint32_t)c << 8) | \ ((uint32_t)d)) #if 0 uint32_t major_brand; uint32_t minor_version; int num_compatible_brands; uint32_t * compatible_brands; #endif static quicktime_ftyp_t ftyp_qt = { .major_brand = MK_FOURCC('q','t',' ',' '), .minor_version = 0x20050300, .num_compatible_brands = 4, .compatible_brands = (uint32_t[]){ MK_FOURCC('q','t',' ',' '),0,0,0 }, }; static quicktime_ftyp_t ftyp_mp4 = { .major_brand = MK_FOURCC('m','p','4','2'), .minor_version = 0x0, .num_compatible_brands = 2, .compatible_brands = (uint32_t[]){MK_FOURCC('m','p','4','2'), MK_FOURCC('i','s','o','m')}, }; static quicktime_ftyp_t ftyp_3gp = { .major_brand = MK_FOURCC('3','g','p','5'), .minor_version = 0x00000200, .num_compatible_brands = 5, .compatible_brands = (uint32_t[]){MK_FOURCC('i','s','o','m'), MK_FOURCC('3','g','p','5'), MK_FOURCC('3','g','p','4'), MK_FOURCC('m','p','4','1'), MK_FOURCC('m','p','4','2')}, }; static quicktime_ftyp_t ftyp_m4a = { .major_brand = MK_FOURCC('M','4','A',' '), .minor_version = 0x0, .num_compatible_brands = 4, .compatible_brands = (uint32_t[]){MK_FOURCC('M','4','A',' '), MK_FOURCC('m','p','4','2'), MK_FOURCC('i','s','o','m'), 0}, }; static void copy_ftyp(quicktime_ftyp_t * dst, quicktime_ftyp_t * src) { dst->major_brand = src->major_brand; dst->minor_version = src->minor_version; dst->num_compatible_brands = src->num_compatible_brands; dst->compatible_brands = malloc(dst->num_compatible_brands * sizeof(*dst->compatible_brands)); memcpy(dst->compatible_brands, src->compatible_brands, dst->num_compatible_brands * sizeof(*dst->compatible_brands)); } void quicktime_ftyp_init(quicktime_ftyp_t * ftyp, lqt_file_type_t type) { memset(ftyp, 0, sizeof(*ftyp)); switch(type) { case LQT_FILE_NONE: case LQT_FILE_QT_OLD: case LQT_FILE_AVI: case LQT_FILE_AVI_ODML: return; case LQT_FILE_QT: copy_ftyp(ftyp, &ftyp_qt); return; case LQT_FILE_MP4: copy_ftyp(ftyp, &ftyp_mp4); return; case LQT_FILE_M4A: copy_ftyp(ftyp, &ftyp_m4a); return; case LQT_FILE_3GP: copy_ftyp(ftyp, &ftyp_3gp); return; } } lqt_file_type_t quicktime_ftyp_get_file_type(quicktime_ftyp_t * ftyp) { switch(ftyp->major_brand) { case MK_FOURCC('i','s','o','m'): case MK_FOURCC('m','p','4','1'): case MK_FOURCC('m','p','4','2'): return LQT_FILE_MP4; break; case MK_FOURCC('M','4','A',' '): return LQT_FILE_M4A; break; case MK_FOURCC('q','t',' ',' '): return LQT_FILE_QT; break; case MK_FOURCC('3','g','p','4'): case MK_FOURCC('3','g','p','5'): return LQT_FILE_3GP; } return 0; } void quicktime_read_ftyp(quicktime_t *file, quicktime_ftyp_t *ftyp, quicktime_atom_t *parent_atom) { int i; ftyp->major_brand = quicktime_read_int32(file); ftyp->minor_version = quicktime_read_int32(file); ftyp->num_compatible_brands = (parent_atom->end - quicktime_position(file)) / 4; ftyp->compatible_brands = malloc(ftyp->num_compatible_brands * sizeof(ftyp->compatible_brands)); for(i = 0; i < ftyp->num_compatible_brands; i++) { ftyp->compatible_brands[i] = quicktime_read_int32(file); } } void quicktime_write_ftyp(quicktime_t *file, quicktime_ftyp_t *ftyp) { int i; quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "ftyp"); quicktime_write_int32(file, ftyp->major_brand); quicktime_write_int32(file, ftyp->minor_version); for(i = 0; i < ftyp->num_compatible_brands; i++) quicktime_write_int32(file, ftyp->compatible_brands[i]); quicktime_atom_write_footer(file, &atom); } static void dump_fourcc(uint32_t f) { lqt_dump("%c%c%c%c", (f >> 24) & 0xff, (f >> 16) & 0xff, (f >> 8) & 0xff, f & 0xff); } void quicktime_ftyp_dump(quicktime_ftyp_t *ftyp) { int i; lqt_dump("ftyp\n"); lqt_dump(" major brand: "); dump_fourcc(ftyp->major_brand); lqt_dump("\n minor version: %08x\n", ftyp->minor_version); lqt_dump(" compatible brands: "); for(i = 0; i < ftyp->num_compatible_brands; i++) { dump_fourcc(ftyp->compatible_brands[i]); lqt_dump(" "); } lqt_dump("\n"); } void quicktime_ftyp_delete(quicktime_ftyp_t *ftyp) { if(ftyp->compatible_brands) free(ftyp->compatible_brands); } libquicktime-1.2.4/src/pHdr.c0000644000175000017500000000362211511622757012763 00000000000000/******************************************************************************* pHdr.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" int quicktime_pHdr_init(quicktime_pHdr_t *pHdr) { pHdr->nodeID = 1; pHdr->defHPan = 0; pHdr->defVPan = 0; pHdr->defZoom = 0; // constraints for this node; use zero for default pHdr->minHPan = 0; pHdr->minVPan = 0; pHdr->minZoom = 0; pHdr->maxHPan = 0; pHdr->maxVPan = 0; pHdr->maxZoom = 0; pHdr->nameStrOffset = 0; // offset into string table atom pHdr->commentStrOffset = 0; // offset into string table atom return 0; } int quicktime_pHdr_delete(quicktime_pHdr_t *pHdr) { return 0; } void quicktime_pHdr_dump(quicktime_pHdr_t *pHdr) { } int quicktime_read_pHdr(quicktime_t *file, quicktime_pHdr_t *pHdr, quicktime_atom_t *pHdr_atom) { return 0; } void quicktime_write_pHdr(quicktime_t *file, quicktime_pHdr_t *pHdr) { } libquicktime-1.2.4/src/tref.c0000644000175000017500000001224511511622757013027 00000000000000/******************************************************************************* tref.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include int quicktime_tref_init(quicktime_tref_t *tref) { // tref->trackIndex = 1; return 0; } static quicktime_track_reference_t * add_reference(quicktime_tref_t *tref) { tref->num_references++; tref->references = realloc(tref->references, tref->num_references * sizeof(*(tref->references))); memset(&tref->references[tref->num_references-1], 0, sizeof(tref->references[tref->num_references-1])); return &tref->references[tref->num_references-1]; } static void add_track(quicktime_track_reference_t * ref, int track_id) { ref->num_tracks++; ref->tracks = realloc(ref->tracks, ref->num_tracks * sizeof(*ref->tracks)); ref->tracks[ref->num_tracks-1] = track_id; } int quicktime_tref_init_qtvr(quicktime_tref_t *tref, int track_type) { quicktime_track_reference_t * ref = add_reference(tref); switch(track_type) { case QTVR_OBJ: case QTVR_PAN: ref->type[0] = 'i'; ref->type[1] = 'm'; ref->type[2] = 'g'; ref->type[3] = 't'; break; case QTVR_QTVR_OBJ: ref->type[0] = 'o'; ref->type[1] = 'b'; ref->type[2] = 'j'; ref->type[3] = 'e'; break; case QTVR_QTVR_PAN: ref->type[0] = 'p'; ref->type[1] = 'a'; ref->type[2] = 'n'; ref->type[3] = 'o'; break; default: // lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, // "quicktime_tref_init_qtvr invalid track type supplied"); return -1; } add_track(ref, 1); return 0; } int quicktime_tref_init_chap(quicktime_tref_t * tref, int track_id) { quicktime_track_reference_t * ref = add_reference(tref); ref->type[0] = 'c'; ref->type[1] = 'h'; ref->type[2] = 'a'; ref->type[3] = 'p'; add_track(ref, track_id); return 0; } int quicktime_tref_init_tmcd(quicktime_tref_t * tref, int track_id) { quicktime_track_reference_t * ref = add_reference(tref); ref->type[0] = 't'; ref->type[1] = 'm'; ref->type[2] = 'c'; ref->type[3] = 'd'; add_track(ref, track_id); return 0; } int quicktime_tref_delete(quicktime_tref_t *tref) { int i; for(i = 0; i < tref->num_references; i++) { if(tref->references[i].tracks) free(tref->references[i].tracks); } if(tref->references) free(tref->references); return 0; } void quicktime_tref_dump(quicktime_tref_t *tref) { int i, j; quicktime_track_reference_t * ref; lqt_dump(" track reference (tref)\n"); for(i = 0; i < tref->num_references; i++) { ref = &tref->references[i]; lqt_dump(" reference type %d type: %c%c%c%c\n", i+1, ref->type[0], ref->type[1], ref->type[2], ref->type[3]); lqt_dump(" track indices: %d\n", ref->num_tracks); for(j = 0; j < ref->num_tracks; j++) { lqt_dump(" track_index %d: %d\n", j, ref->tracks[j]); } } } int quicktime_read_tref(quicktime_t *file, quicktime_tref_t *tref, quicktime_atom_t *tref_atom) { int i; quicktime_atom_t atom; quicktime_track_reference_t * ref; while(quicktime_position(file) < tref_atom->end) { ref = add_reference(tref); quicktime_atom_read_header(file, &atom); ref->type[0] = atom.type[0]; ref->type[1] = atom.type[1]; ref->type[2] = atom.type[2]; ref->type[3] = atom.type[3]; ref->num_tracks = (atom.end - quicktime_position(file)) / 4; ref->tracks = calloc(ref->num_tracks, sizeof(*ref->tracks)); for(i = 0; i < ref->num_tracks; i++) ref->tracks[i] = quicktime_read_int32(file); } return 0; } void quicktime_write_tref(quicktime_t *file, quicktime_tref_t *tref ) { int i, j; quicktime_atom_t atom, subatom; quicktime_atom_write_header(file, &atom, "tref"); for(i = 0; i < tref->num_references; i++) { quicktime_atom_write_header(file, &subatom, tref->references[i].type); for(j = 0; j < tref->references[i].num_tracks; j++) quicktime_write_int32(file, tref->references[i].tracks[j]); quicktime_atom_write_footer(file, &subatom); } quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/impn.c0000644000175000017500000001037311511622756013031 00000000000000/******************************************************************************* impn.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" int quicktime_impn_init(quicktime_impn_t *impn) { impn->version = 2; impn->revision = 0; impn->imagingMode = 2; impn->imagingValidFlags = 7; impn->correction = 2; impn->quality = 256; impn->directdraw = 1; return 0; } int quicktime_impn_delete(quicktime_impn_t *impn) { return 0; } void quicktime_impn_dump(quicktime_impn_t *impn) { lqt_dump(" Panorama Imaging Atom (impn)\n"); lqt_dump(" Version %i\n", impn->version); lqt_dump(" Revision %i\n", impn->revision); lqt_dump(" imagingMode %d\n", impn->imagingMode); lqt_dump(" imagingValidFlags %d\n", impn->imagingValidFlags); lqt_dump(" Correction %d\n", impn->correction); lqt_dump(" Quality %d\n", impn->quality); lqt_dump(" directdraw %d\n", impn->directdraw); lqt_dump(" Imaging Properties %d %d %d %d %d %d \n", impn->imagingProperties[0], impn->imagingProperties[1], impn->imagingProperties[2], impn->imagingProperties[3], impn->imagingProperties[4], impn->imagingProperties[5]); } int quicktime_read_impn(quicktime_t *file, quicktime_impn_t *impn, quicktime_qtatom_t *impn_atom) { impn->version = quicktime_read_int16(file); impn->revision = quicktime_read_int16(file); impn->imagingMode = quicktime_read_int32(file); impn->imagingValidFlags = quicktime_read_int32(file); impn->correction = quicktime_read_int32(file); impn->quality = quicktime_read_int32(file); impn->directdraw = quicktime_read_int32(file); impn->imagingProperties[0] = quicktime_read_int32(file); impn->imagingProperties[1] = quicktime_read_int32(file); impn->imagingProperties[2] = quicktime_read_int32(file); impn->imagingProperties[3] = quicktime_read_int32(file); impn->imagingProperties[4] = quicktime_read_int32(file); impn->imagingProperties[5] = quicktime_read_int32(file); impn->reserved1 = quicktime_read_int32(file); impn->reserved2 = quicktime_read_int32(file); return 0; } void quicktime_write_impn(quicktime_t *file, quicktime_impn_t *impn) { quicktime_qtatom_t atom; quicktime_qtatom_write_header(file, &atom, "impn", 1); quicktime_write_int16(file, impn->version); quicktime_write_int16(file, impn->revision); quicktime_write_int32(file, impn->imagingMode); quicktime_write_int32(file, impn->imagingValidFlags); quicktime_write_int32(file, impn->correction); quicktime_write_int32(file, impn->quality); quicktime_write_int32(file, impn->directdraw); quicktime_write_int32(file, impn->imagingProperties[0]); quicktime_write_int32(file, impn->imagingProperties[1]); quicktime_write_int32(file, impn->imagingProperties[2]); quicktime_write_int32(file, impn->imagingProperties[3]); quicktime_write_int32(file, impn->imagingProperties[4]); quicktime_write_int32(file, impn->imagingProperties[5]); quicktime_write_int32(file, impn->reserved1); quicktime_write_int32(file, impn->reserved2); quicktime_qtatom_write_footer(file, &atom); } libquicktime-1.2.4/src/lqt_codecinfo.c0000644000175000017500000013075211511622756014703 00000000000000/******************************************************************************* lqt_codecinfo.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include "lqt_codecinfo_private.h" #define LQT_LIBQUICKTIME #include #include #include #include #include #include #include #include #include #include #define LOG_DOMAIN "codecinfo" /* Public function (lqt.h) */ int lqt_get_codec_api_version() { return LQT_CODEC_API_VERSION; } /* Forward declaration */ static lqt_codec_info_t * sort_codecs_internal(lqt_codec_info_t * original, char * names); /* * Quick and dirty strdup function for the case it's not there */ static char * __lqt_strdup(const char * string) { char * ret = malloc(strlen(string)+1); strcpy(ret, string); return ret; } static char * __lqt_fourccdup(const char * fourcc) { char * ret = malloc(5); memcpy(ret, fourcc, 5); return ret; }; /* * Codec Registry */ int lqt_num_audio_codecs = 0; int lqt_num_video_codecs = 0; lqt_codec_info_t * lqt_audio_codecs = (lqt_codec_info_t*)0; lqt_codec_info_t * lqt_video_codecs = (lqt_codec_info_t*)0; static int registry_init_done = 0; pthread_mutex_t codecs_mutex = PTHREAD_MUTEX_INITIALIZER; /* * Lock and unlock the codec registry */ void lqt_registry_lock() { pthread_mutex_lock(&codecs_mutex); } void lqt_registry_unlock() { pthread_mutex_unlock(&codecs_mutex); } /* Free memory of parameter info */ static void destroy_parameter_info(lqt_parameter_info_t * p) { int i; if(p->name) free(p->name); if(p->real_name) free(p->real_name); if(p->help_string) free(p->help_string); switch(p->type) { case LQT_PARAMETER_STRING: if(p->val_default.val_string) free(p->val_default.val_string); break; case LQT_PARAMETER_STRINGLIST: if(p->val_default.val_string) free(p->val_default.val_string); if(p->stringlist_options) { for(i = 0; i < p->num_stringlist_options; i++) free(p->stringlist_options[i]); free(p->stringlist_options); } if(p->stringlist_labels) { for(i = 0; i < p->num_stringlist_options; i++) free(p->stringlist_labels[i]); free(p->stringlist_labels); } break; default: /* Keep gcc quiet */ break; } } /* Free memory of codec info (public) */ void lqt_codec_info_destroy_single(lqt_codec_info_t * ptr) { int i; if(ptr->fourccs) { for(i = 0; i < ptr->num_fourccs; i++) free(ptr->fourccs[i]); free(ptr->fourccs); } if(ptr->wav_ids) free(ptr->wav_ids); if(ptr->name) free(ptr->name); /* Name of the codec */ if(ptr->long_name) /* Long name of the codec */ free(ptr->long_name); if(ptr->description) /* Long name of the codec */ free(ptr->description); if(ptr->module_filename) /* Module filename */ free(ptr->module_filename); if(ptr->gettext_domain) free(ptr->gettext_domain); if(ptr->gettext_directory) free(ptr->gettext_directory); if(ptr->encoding_colormodels) free(ptr->encoding_colormodels); if(ptr->encoding_parameters) { for(i = 0; i < ptr->num_encoding_parameters; i++) destroy_parameter_info(&ptr->encoding_parameters[i]); free(ptr->encoding_parameters); } if(ptr->decoding_parameters) { for(i = 0; i < ptr->num_decoding_parameters; i++) destroy_parameter_info(&ptr->decoding_parameters[i]); free(ptr->decoding_parameters); } if(ptr->image_sizes) free(ptr->image_sizes); free(ptr); } static void copy_parameter_value(lqt_parameter_value_t * dst, const lqt_parameter_value_t * src, lqt_parameter_type_t type) { switch(type) { case LQT_PARAMETER_INT: dst->val_int = src->val_int; break; case LQT_PARAMETER_FLOAT: dst->val_float = src->val_float; break; case LQT_PARAMETER_STRING: case LQT_PARAMETER_STRINGLIST: /* String with options */ if(dst->val_string) free(dst->val_string); if(src->val_string) dst->val_string = __lqt_strdup(src->val_string); else dst->val_string = (char*)0; break; case LQT_PARAMETER_SECTION: break; } } static void copy_parameter_info(lqt_parameter_info_t * ret, const lqt_parameter_info_t * info) { int i; if(info->name) ret->name = __lqt_strdup(info->name); if(info->real_name) ret->real_name = __lqt_strdup(info->real_name); if(info->help_string) ret->help_string = __lqt_strdup(info->help_string); ret->type = info->type; switch(ret->type) { case LQT_PARAMETER_INT: ret->val_min.val_int = info->val_min.val_int; ret->val_max.val_int = info->val_max.val_int; break; case LQT_PARAMETER_FLOAT: ret->val_min.val_float = info->val_min.val_float; ret->val_max.val_float = info->val_max.val_float; ret->num_digits = info->num_digits; break; case LQT_PARAMETER_STRING: break; case LQT_PARAMETER_STRINGLIST: /* String with options */ ret->num_stringlist_options = info->num_stringlist_options; ret->stringlist_options = calloc(ret->num_stringlist_options, sizeof(char*)); ret->stringlist_labels = calloc(ret->num_stringlist_options, sizeof(char*)); for(i = 0; i < ret->num_stringlist_options; i++) { ret->stringlist_options[i] = __lqt_strdup(info->stringlist_options[i]); ret->stringlist_labels[i] = __lqt_strdup(info->stringlist_labels[i]); } break; case LQT_PARAMETER_SECTION: /* String with options */ break; } copy_parameter_value(&ret->val_default, &info->val_default, info->type); } /* * Copy codec Info */ lqt_codec_info_t * lqt_codec_info_copy_single(const lqt_codec_info_t * info) { int i, len; lqt_codec_info_t * ret = calloc(1, sizeof(*ret)); // fprintf(stderr, "lqt_codec_info_copy_single %s\n", info->name); ret->compatibility_flags = info->compatibility_flags; if(info->name) ret->name = __lqt_strdup(info->name); if(info->long_name) ret->long_name = __lqt_strdup(info->long_name); if(info->description) ret->description = __lqt_strdup(info->description); if(info->gettext_domain) ret->gettext_domain = __lqt_strdup(info->gettext_domain); else ret->gettext_domain = __lqt_strdup(PACKAGE); if(info->gettext_directory) ret->gettext_directory = __lqt_strdup(info->gettext_directory); else ret->gettext_directory = __lqt_strdup(LOCALE_DIR); if(info->module_filename) ret->module_filename = __lqt_strdup(info->module_filename); ret->module_index = info->module_index; ret->type = info->type; ret->direction = info->direction; ret->num_fourccs = info->num_fourccs; if(ret->num_fourccs) { ret->fourccs = malloc(ret->num_fourccs * sizeof(char*)); for(i = 0; i < ret->num_fourccs; i++) ret->fourccs[i] = __lqt_fourccdup(info->fourccs[i]); } ret->num_encoding_colormodels = info->num_encoding_colormodels; if(ret->num_encoding_colormodels) { /* +1 to copy the terminating LQT_COLORMODEL_NODE */ len = (ret->num_encoding_colormodels + 1) * sizeof(*ret->encoding_colormodels); ret->encoding_colormodels = malloc(len); memcpy(ret->encoding_colormodels, info->encoding_colormodels, len); } ret->num_wav_ids = info->num_wav_ids; if(ret->num_wav_ids) { len = ret->num_wav_ids * sizeof(*ret->wav_ids); ret->wav_ids = malloc(len); memcpy(ret->wav_ids, info->wav_ids, len); } ret->num_image_sizes = info->num_image_sizes; if(ret->num_image_sizes) { len = ret->num_image_sizes * sizeof(*ret->image_sizes); ret->image_sizes = malloc(len); memcpy(ret->image_sizes, info->image_sizes, len); } ret->num_encoding_parameters = info->num_encoding_parameters; if(ret->num_encoding_parameters) { ret->encoding_parameters = calloc(ret->num_encoding_parameters+1, sizeof(lqt_parameter_info_t)); for(i = 0; i < ret->num_encoding_parameters; i++) copy_parameter_info(&ret->encoding_parameters[i], &info->encoding_parameters[i]); } ret->num_decoding_parameters = info->num_decoding_parameters; if(ret->num_decoding_parameters) { ret->decoding_parameters = calloc(ret->num_decoding_parameters, sizeof(lqt_parameter_info_t)); for(i = 0; i < ret->num_decoding_parameters; i++) copy_parameter_info(&ret->decoding_parameters[i], &info->decoding_parameters[i]); } ret->compression_id = info->compression_id; return ret; } /* * Seek a codec in the database */ static lqt_codec_info_t * find_codec_by_filename(lqt_codec_info_t ** list, const char * filename, uint32_t time) { lqt_codec_info_t * new_list = (lqt_codec_info_t*)0; lqt_codec_info_t * new_list_end = (lqt_codec_info_t*)0; lqt_codec_info_t * ret = (lqt_codec_info_t*)0; lqt_codec_info_t * ret_end = (lqt_codec_info_t*)0; lqt_codec_info_t * tmp_ptr; lqt_codec_info_t * ptr = *list; if(!ptr) return (lqt_codec_info_t*)0; while(ptr) { if(!strcmp(ptr->module_filename, filename)) { /* * File is there, but newer than our database entry * -> Remove from the list */ if(ptr->file_time < time) { tmp_ptr = ptr->next; lqt_codec_info_destroy_single(ptr); ptr = tmp_ptr; } else { if(ret) { ret_end->next = ptr; ret_end = ret_end->next; } else { ret = ptr; ret_end = ptr; } ptr = ptr->next; } } else /* Not our file, return to database */ { if(new_list) { new_list_end->next = ptr; new_list_end = new_list_end->next; } else { new_list = ptr; new_list_end = ptr; } ptr = ptr->next; } } /* Prepare for returning */ if(new_list) { new_list_end->next = (lqt_codec_info_t*)0; } *list = new_list; if(ret_end) ret_end->next = (lqt_codec_info_t*)0; return ret; } static lqt_codec_info_t * load_codec_info_from_plugin(char * plugin_filename, uint32_t time) { void * module; lqt_codec_info_t * ret_end; int i; int num_codecs; int codec_api_version_module; int codec_api_version_us = lqt_get_codec_api_version(); int (*get_num_codecs)(); int (*get_codec_api_version)(); lqt_codec_info_static_t * (*get_codec_info)(int); lqt_codec_info_t * ret = (lqt_codec_info_t*)0; module = dlopen(plugin_filename, RTLD_NOW); if(!module) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "dlopen failed for %s: %s", plugin_filename, dlerror()); return ret; } /* Now, get the codec parameters */ /* Check the api version */ get_codec_api_version = (int (*)())(dlsym(module, "get_codec_api_version")); if(!get_codec_api_version) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "Module %s has no API version and is thus terribly old", plugin_filename); dlclose(module); return ret; } codec_api_version_module = get_codec_api_version(); if(codec_api_version_module != codec_api_version_us) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "Codec interface version mismatch of module %s: %d [module] != %d [lqt]", plugin_filename, codec_api_version_module, codec_api_version_us); dlclose(module); return ret; } get_num_codecs = (int (*)())(dlsym(module, "get_num_codecs")); if(!get_num_codecs) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "Symbol get_num_codecs not found in %s", plugin_filename); dlclose(module); return ret; } get_codec_info = (lqt_codec_info_static_t*(*)(int))(dlsym(module, "get_codec_info")); if(!get_codec_info) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "Symbol get_codec_info not found in %s", plugin_filename); dlclose(module); return ret; } /* Now, create the structure */ num_codecs = get_num_codecs(); if(!num_codecs) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "No codecs found in %s", plugin_filename); dlclose(module); return ret; } ret = lqt_create_codec_info(get_codec_info(0)); /* Complete the structure */ ret_end = ret; ret_end->module_index = 0; /* Filename of the module */ ret_end->module_filename = __lqt_strdup(plugin_filename); ret_end->file_time = time; /* File modification time */ for(i = 1; i < num_codecs; i++) { ret_end->next = lqt_create_codec_info(get_codec_info(i)); ret_end = ret_end->next; ret_end->module_index = i; /* Filename of the module */ ret_end->module_filename = __lqt_strdup(plugin_filename); /* File modification time */ ret_end->file_time = time; } ret_end->next = (lqt_codec_info_t*)0; dlclose(module); return ret; } /* * Register all codecs found in list */ static void register_codecs(lqt_codec_info_t * list, lqt_codec_info_t ** audio_codecs_end, lqt_codec_info_t ** video_codecs_end) { lqt_codec_info_t * tmp_ptr; while(list) { if(list->type == LQT_CODEC_AUDIO) { if(*audio_codecs_end) { (*audio_codecs_end)->next = list; *audio_codecs_end = (*audio_codecs_end)->next; } else { lqt_audio_codecs = list; (*audio_codecs_end) = lqt_audio_codecs; } lqt_num_audio_codecs++; } if(list->type == LQT_CODEC_VIDEO) { if((*video_codecs_end)) { (*video_codecs_end)->next = list; (*video_codecs_end) = (*video_codecs_end)->next; } else { lqt_video_codecs = list; (*video_codecs_end) = lqt_video_codecs; } lqt_num_video_codecs++; } tmp_ptr = list; list = list->next; tmp_ptr->next = (lqt_codec_info_t*)0; } } static int scan_for_plugins(const char * plugin_dir, lqt_codec_info_t ** database) { char * pos; int ret; char * filename; DIR * directory; struct dirent * directory_entry; struct stat status; lqt_codec_info_t * codecs; lqt_codec_info_t * video_codecs_end; lqt_codec_info_t * audio_codecs_end; filename = malloc(PATH_MAX * sizeof(char)); /* Set the end pointers so we can quickly add codecs after */ audio_codecs_end = lqt_audio_codecs; if(audio_codecs_end) while(audio_codecs_end->next) audio_codecs_end = audio_codecs_end->next; video_codecs_end = lqt_video_codecs; if(video_codecs_end) while(video_codecs_end->next) video_codecs_end = video_codecs_end->next; directory = opendir(plugin_dir); if(!directory) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "Cannot open plugin directory %s (forgot make install?)", plugin_dir); return 0; } ret = 0; while(1) { directory_entry = readdir(directory); if(!directory_entry) /* We're done */ break; /* Check the beginning of the filename */ if(strncmp(directory_entry->d_name, "lqt_", 4)) continue; /* Check the end of the filename -> filter out .la files */ pos = strchr(directory_entry->d_name, '.'); if(!pos) continue; if(strcmp(pos, MODULE_EXT)) continue; /* Now, the file should be a valid plugin, construct the filename */ strcpy(filename, plugin_dir); strcat(filename, "/"); strcat(filename, directory_entry->d_name); stat(filename, &status); if(!S_ISREG(status.st_mode)) continue; codecs = find_codec_by_filename(database, filename, status.st_ctime); if(codecs) /* Codec information found in database */ { register_codecs(codecs, &audio_codecs_end, &video_codecs_end); } else /* Load the informations from the module */ { codecs = load_codec_info_from_plugin(filename, status.st_ctime); register_codecs(codecs, &audio_codecs_end, &video_codecs_end); ret = 1; } } free(filename); closedir(directory); return ret; } void lqt_registry_destroy() { lqt_codec_info_t * tmp; while(lqt_audio_codecs) { tmp = lqt_audio_codecs->next; lqt_codec_info_destroy_single(lqt_audio_codecs); lqt_audio_codecs = tmp; } while(lqt_video_codecs) { tmp = lqt_video_codecs->next; lqt_codec_info_destroy_single(lqt_video_codecs); lqt_video_codecs = tmp; } lqt_num_video_codecs = 0; lqt_num_audio_codecs = 0; } void lqt_registry_init() { int do_write = 0; char * audio_order = (char*)0; char * video_order = (char*)0; lqt_codec_info_t * file_codecs; lqt_codec_info_t * tmp_file_codecs; const char* plugin_dir = PLUGIN_DIR; lqt_registry_lock(); if(registry_init_done) { lqt_registry_unlock(); return; } registry_init_done = 1; /* Check for environment variable for plugin dir */ if(getenv("LIBQUICKTIME_PLUGIN_DIR")) { plugin_dir = getenv("LIBQUICKTIME_PLUGIN_DIR"); } if(lqt_audio_codecs || lqt_video_codecs) { lqt_registry_unlock(); return; } file_codecs = lqt_registry_read(&audio_order, &video_order); /* Scan for the plugins, use cached values if possible */ if(scan_for_plugins(plugin_dir, &file_codecs)) do_write = 1; /* * If there were codecs in the database, which have * disappeared, they must be deleted now */ while(file_codecs) { tmp_file_codecs = file_codecs; file_codecs = file_codecs->next; lqt_codec_info_destroy_single(tmp_file_codecs); do_write = 1; } /* * Write the file again, so we can use it the next time */ /* Sort the codecs */ if(audio_order) { lqt_audio_codecs = sort_codecs_internal(lqt_audio_codecs, audio_order); free(audio_order); } if(video_order) { lqt_video_codecs = sort_codecs_internal(lqt_video_codecs, video_order); free(video_order); } lqt_registry_unlock(); if(do_write) lqt_registry_write(); } /* * Get the numbers of codecs */ int lqt_get_num_audio_codecs() { return lqt_num_audio_codecs; } int lqt_get_num_video_codecs() { return lqt_num_video_codecs; } /* * Get corresponding info structures * These point to the original database entries, * so they are returned as const here */ const lqt_codec_info_t * lqt_get_audio_codec_info(int index) { const lqt_codec_info_t * ret; int i; if((index < 0) || (index >= lqt_num_audio_codecs)) return (lqt_codec_info_t *)0; ret = lqt_audio_codecs; for(i = 0; i < index; i++) ret = ret->next; return ret; } const lqt_codec_info_t * lqt_get_video_codec_info(int index) { const lqt_codec_info_t * ret; int i; if((index < 0) || (index >= lqt_num_video_codecs)) return (lqt_codec_info_t *)0; ret = lqt_video_codecs; for(i = 0; i < index; i++) ret = ret->next; return ret; } /* Thread save methods of getting codec infos */ static void create_parameter_info(lqt_parameter_info_t * ret, const lqt_parameter_info_static_t * info) { int i; ret->name = __lqt_strdup(info->name); /* Parameter name */ ret->real_name = __lqt_strdup(info->real_name); /* Parameter name */ if(info->help_string) ret->help_string = __lqt_strdup(info->help_string); ret->type = info->type; switch(ret->type) { case LQT_PARAMETER_INT: ret->val_default.val_int = info->val_default.val_int; ret->val_min.val_int = info->val_min.val_int; ret->val_max.val_int = info->val_max.val_int; break; case LQT_PARAMETER_FLOAT: ret->val_default.val_float = info->val_default.val_float; ret->val_min.val_float = info->val_min.val_float; ret->val_max.val_float = info->val_max.val_float; ret->num_digits = info->num_digits; break; case LQT_PARAMETER_STRING: ret->val_default.val_string = __lqt_strdup(info->val_default.val_string); break; case LQT_PARAMETER_STRINGLIST: ret->val_default.val_string = __lqt_strdup(info->val_default.val_string); if(!info->stringlist_options) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "Stringlist parameter %s has NULL options", info->name); return; } /* Count the options */ ret->num_stringlist_options = 0; while(1) { if(info->stringlist_options[ret->num_stringlist_options]) ret->num_stringlist_options++; else break; } /* Now, copy them */ ret->stringlist_options = malloc(ret->num_stringlist_options * sizeof(char *)); for(i = 0; i < ret->num_stringlist_options; i++) { ret->stringlist_options[i] = __lqt_strdup(info->stringlist_options[i]); } /* Labels */ ret->stringlist_labels = malloc(ret->num_stringlist_options * sizeof(char *)); if(info->stringlist_labels) { for(i = 0; i < ret->num_stringlist_options; i++) { ret->stringlist_labels[i] = __lqt_strdup(info->stringlist_labels[i]); } } else { for(i = 0; i < ret->num_stringlist_options; i++) { ret->stringlist_labels[i] = __lqt_strdup(info->stringlist_options[i]); } } break; default: break; } } lqt_codec_info_t * lqt_create_codec_info(const lqt_codec_info_static_t * template) { int i; lqt_codec_info_t * ret; if(!template->fourccs) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "Codec %s has no fourccs defined", template->name); return (lqt_codec_info_t*)0; } ret = calloc(1, sizeof(lqt_codec_info_t)); ret->compatibility_flags = template->compatibility_flags; ret->name = __lqt_strdup(template->name); ret->long_name = __lqt_strdup(template->long_name); ret->description = __lqt_strdup(template->description); if(template->gettext_domain) ret->gettext_domain = __lqt_strdup(template->gettext_domain); if(template->gettext_directory) ret->gettext_directory = __lqt_strdup(template->gettext_directory); ret->type = template->type; ret->direction = template->direction; /* Copy fourccs */ ret->num_fourccs = 0; while(1) { if(template->fourccs[ret->num_fourccs]) ret->num_fourccs++; else break; } ret->fourccs = malloc(ret->num_fourccs * sizeof(char*)); for(i = 0; i < ret->num_fourccs; i++) ret->fourccs[i] = __lqt_fourccdup(template->fourccs[i]); /* Copy supported encoding colormodels */ ret->num_encoding_colormodels = 0; if(template->encoding_colormodels) { while(1) { if(template->encoding_colormodels[ret->num_encoding_colormodels] != LQT_COLORMODEL_NONE) ret->num_encoding_colormodels++; else break; } ret->encoding_colormodels = malloc((ret->num_encoding_colormodels+1) * sizeof(*ret->encoding_colormodels)); for(i = 0; i < ret->num_encoding_colormodels; i++) ret->encoding_colormodels[i] = template->encoding_colormodels[i]; ret->encoding_colormodels[ret->num_encoding_colormodels] = LQT_COLORMODEL_NONE; } /* Copy wav_ids */ ret->num_wav_ids = 0; if(template->wav_ids) { while(1) { if(template->wav_ids[ret->num_wav_ids] != LQT_WAV_ID_NONE) ret->num_wav_ids++; else break; } ret->wav_ids = malloc(ret->num_wav_ids * sizeof(int)); for(i = 0; i < ret->num_wav_ids; i++) ret->wav_ids[i] = template->wav_ids[i]; } /* Copy image_sizes */ ret->num_image_sizes = 0; if(template->image_sizes) { while(template->image_sizes[ret->num_image_sizes].width) ret->num_image_sizes++; if(ret->num_image_sizes) { ret->image_sizes = malloc(ret->num_image_sizes * sizeof(*ret->image_sizes)); for(i = 0; i < ret->num_image_sizes; i++) { ret->image_sizes[i].width = template->image_sizes[i].width; ret->image_sizes[i].height = template->image_sizes[i].height; } } } /* Copy encoding parameters */ if(template->encoding_parameters) { ret->num_encoding_parameters = 0; while(1) { if(template->encoding_parameters[ret->num_encoding_parameters].name) ret->num_encoding_parameters++; else break; } } if(ret->num_encoding_parameters) { ret->encoding_parameters = calloc(ret->num_encoding_parameters, sizeof(lqt_parameter_info_t)); for(i = 0; i < ret->num_encoding_parameters; i++) { /* Copy parameter info */ create_parameter_info(&ret->encoding_parameters[i], &template->encoding_parameters[i]); } } else { ret->encoding_parameters = (lqt_parameter_info_t*)0; } if(template->decoding_parameters) { ret->num_decoding_parameters = 0; while(1) { if(template->decoding_parameters[ret->num_decoding_parameters].name) ret->num_decoding_parameters++; else break; } } if(ret->num_decoding_parameters) { ret->decoding_parameters = calloc(ret->num_decoding_parameters, sizeof(lqt_parameter_info_t)); for(i = 0; i < ret->num_decoding_parameters; i++) { /* Copy parameter info */ create_parameter_info(&ret->decoding_parameters[i], &template->decoding_parameters[i]); } } else { ret->decoding_parameters = (lqt_parameter_info_t*)0; } ret->compression_id = template->compression_id; return ret; } static void dump_codec_parameter(lqt_parameter_info_t * p) { int i; lqt_dump("Parameter: %s (%s) ", p->name, p->real_name); lqt_dump("Type: "); switch(p->type) { case LQT_PARAMETER_INT: lqt_dump("Integer, Default Value: %d ", p->val_default.val_int); if(p->val_min.val_int < p->val_max.val_int) lqt_dump("(%d..%d)\n", p->val_min.val_int, p->val_max.val_int); else lqt_dump("(unlimited)\n"); break; case LQT_PARAMETER_FLOAT: lqt_dump("Float, Default Value: %f ", p->val_default.val_float); if(p->val_min.val_float < p->val_max.val_float) lqt_dump("(%f..%f)\n", p->val_min.val_float, p->val_max.val_float); else lqt_dump("(unlimited)\n"); break; case LQT_PARAMETER_STRING: lqt_dump("String, Default Value : %s\n", (p->val_default.val_string ? p->val_default.val_string : "NULL")); break; case LQT_PARAMETER_STRINGLIST: lqt_dump("Stringlist, Default Value : %s\n", (p->val_default.val_string ? p->val_default.val_string : "NULL")); lqt_dump("Options: "); for(i = 0; i < p->num_stringlist_options; i++) lqt_dump("%s ", p->stringlist_options[i]); lqt_dump("\n"); break; case LQT_PARAMETER_SECTION: lqt_dump("Section"); } if(p->help_string) lqt_dump("Help string: %s\n", p->help_string); } void lqt_dump_codec_info(const lqt_codec_info_t * info) { int i; lqt_dump("Codec: %s (%s)\n", info->long_name, info->name); lqt_dump("Type: %s Direction: ", (info->type == LQT_CODEC_AUDIO ? "Audio, " : "Video, ") ); switch(info->direction) { case LQT_DIRECTION_ENCODE: lqt_dump("Encode\n"); break; case LQT_DIRECTION_DECODE: lqt_dump("Decode\n"); break; case LQT_DIRECTION_BOTH: lqt_dump("Encode/Decode\n"); break; } lqt_dump("Description:\n%s\n", info->description); lqt_dump("Four character codes: (fourccs)\n"); for(i = 0; i < info->num_fourccs; i++) lqt_dump("%s (0x%08x)\n", info->fourccs[i], LQT_STRING_2_FOURCC(info->fourccs[i])); if(info->compression_id != LQT_COMPRESSION_NONE) lqt_dump("Compression ID: %s\n", lqt_compression_id_to_string(info->compression_id)); if(!info->num_encoding_parameters) { lqt_dump("No settable parameters for encoding\n"); } else { for(i = 0; i < info->num_encoding_parameters; i++) dump_codec_parameter(&info->encoding_parameters[i]); } if(!info->num_encoding_parameters) { lqt_dump("No settable parameters for decoding\n"); } else { for(i = 0; i < info->num_decoding_parameters; i++) dump_codec_parameter(&info->decoding_parameters[i]); } lqt_dump("Module filename: %s\nIndex inside module: %d\n", info->module_filename, info->module_index); } #define MATCH_FOURCC(a, b) \ ( ( a[0]==b[0] ) && \ ( a[1]==b[1] ) &&\ ( a[2]==b[2] ) &&\ ( a[3]==b[3] ) ) /* * Find codecs: These replace get_acodec_index() and get_vcodec_index() * This returns a pointer to the codec info or NULL if there is none. */ lqt_codec_info_t ** lqt_find_audio_codec(char * fourcc, int encode) { int j; lqt_codec_info_t * tmp_ptr = (lqt_codec_info_t*)0; lqt_codec_info_t * ptr; lqt_codec_info_t ** ret = (lqt_codec_info_t **)0; /* also init registry */ lqt_registry_init(); lqt_registry_lock(); ptr = lqt_audio_codecs; while(ptr) { for(j = 0; j < ptr->num_fourccs; j++) { if(MATCH_FOURCC(ptr->fourccs[j], fourcc)) { if((encode && (ptr->direction != LQT_DIRECTION_DECODE)) || (!encode && (ptr->direction != LQT_DIRECTION_ENCODE))) { tmp_ptr = ptr; break; } } } if(tmp_ptr) break; ptr = ptr->next; } if(tmp_ptr) { ret = calloc(2, sizeof(lqt_codec_info_t*)); *ret = lqt_codec_info_copy_single(tmp_ptr); } lqt_registry_unlock(); return ret; } lqt_codec_info_t ** lqt_find_audio_codec_by_wav_id(int wav_id, int encode) { int j; lqt_codec_info_t * tmp_ptr = (lqt_codec_info_t*)0; lqt_codec_info_t * ptr; lqt_codec_info_t ** ret = (lqt_codec_info_t **)0; /* also init registry */ lqt_registry_init(); lqt_registry_lock(); ptr = lqt_audio_codecs; while(ptr) { for(j = 0; j < ptr->num_wav_ids; j++) { if(ptr->wav_ids[j] == wav_id) { if((encode && (ptr->direction != LQT_DIRECTION_DECODE)) || (!encode && (ptr->direction != LQT_DIRECTION_ENCODE))) { tmp_ptr = ptr; break; } } } if(tmp_ptr) break; ptr = ptr->next; } if(tmp_ptr) { ret = calloc(2, sizeof(lqt_codec_info_t*)); *ret = lqt_codec_info_copy_single(tmp_ptr); } lqt_registry_unlock(); return ret; } lqt_codec_info_t ** lqt_find_video_codec(char * fourcc, int encode) { int j; lqt_codec_info_t * tmp_ptr = (lqt_codec_info_t*)0; lqt_codec_info_t * ptr; lqt_codec_info_t ** ret = (lqt_codec_info_t **)0; /* also init registry */ lqt_registry_init(); lqt_registry_lock(); ptr = lqt_video_codecs; while(ptr) { for(j = 0; j < ptr->num_fourccs; j++) { if(MATCH_FOURCC(ptr->fourccs[j], fourcc)) { if((encode && (ptr->direction != LQT_DIRECTION_DECODE)) || (!encode && (ptr->direction != LQT_DIRECTION_ENCODE))) { tmp_ptr = ptr; break; } } } if(tmp_ptr) break; ptr = ptr->next; } if(tmp_ptr) { ret = calloc(2, sizeof(lqt_codec_info_t*)); *ret = lqt_codec_info_copy_single(tmp_ptr); } lqt_registry_unlock(); return ret; } /* * Query codec registry */ lqt_codec_info_t ** lqt_query_registry(int audio, int video, int encode, int decode) { lqt_codec_info_t ** ret; const lqt_codec_info_t * info; int num_codecs = 0, num_added = 0, i; /* also init registry */ lqt_registry_init(); lqt_registry_lock(); if(audio) { for(i = 0; i < lqt_num_audio_codecs; i++) { info = lqt_get_audio_codec_info(i); if((encode && (info->direction != LQT_DIRECTION_DECODE)) || (decode && (info->direction != LQT_DIRECTION_ENCODE))) num_codecs++; } } if(video) { for(i = 0; i < lqt_num_video_codecs; i++) { info = lqt_get_video_codec_info(i); if((encode && (info->direction != LQT_DIRECTION_DECODE)) || (decode && (info->direction != LQT_DIRECTION_ENCODE))) num_codecs++; } } ret = calloc(num_codecs+1, sizeof(lqt_codec_info_t*)); if(audio) { for(i = 0; i < lqt_num_audio_codecs; i++) { info = lqt_get_audio_codec_info(i); if((encode && (info->direction != LQT_DIRECTION_DECODE)) || (decode && (info->direction != LQT_DIRECTION_ENCODE))) { ret[num_added] = lqt_codec_info_copy_single(info); num_added++; } } } if(video) { for(i = 0; i < lqt_num_video_codecs; i++) { info = lqt_get_video_codec_info(i); if((encode && (info->direction != LQT_DIRECTION_DECODE)) || (decode && (info->direction != LQT_DIRECTION_ENCODE))) { ret[num_added] = lqt_codec_info_copy_single(info); num_added++; } } } lqt_registry_unlock(); return ret; } /* * Find a codec by it's unique (short) name */ lqt_codec_info_t ** lqt_find_audio_codec_by_name(const char * name) { const lqt_codec_info_t * info; int i; lqt_codec_info_t ** ret = (lqt_codec_info_t**)0; if(!name) return ret; /* also init registry */ lqt_registry_init(); lqt_registry_lock(); info = lqt_get_audio_codec_info(0); for(i = 0; i < lqt_num_audio_codecs; i++) { if(!strcmp(info->name, name)) { ret = calloc(2, sizeof(lqt_codec_info_t*)); *ret = lqt_codec_info_copy_single(info); break; } else info = info->next; } lqt_registry_unlock(); return ret; } lqt_codec_info_t ** lqt_find_video_codec_by_name(const char * name) { const lqt_codec_info_t * info; int i; lqt_codec_info_t ** ret = (lqt_codec_info_t**)0; if(!name) return ret; /* also init registry */ lqt_registry_init(); lqt_registry_lock(); info = lqt_get_video_codec_info(0); for(i = 0; i < lqt_num_video_codecs; i++) { if(!strcmp(info->name, name)) { ret = calloc(2, sizeof(lqt_codec_info_t*)); *ret = lqt_codec_info_copy_single(info); break; } else info = info->next; } lqt_registry_unlock(); return ret; } /* * Get infos about the codecs of a file * To be called after quicktime_open() when reading * or quicktime_set_audio()/quicktime_set_video() when writing */ lqt_codec_info_t ** lqt_audio_codec_from_file(quicktime_t * file, int track) { char * name = file->atracks[track].codec->info->name; return lqt_find_audio_codec_by_name(name); } lqt_codec_info_t ** lqt_video_codec_from_file(quicktime_t * file, int track) { char * name = file->vtracks[track].codec->info->name; return lqt_find_video_codec_by_name(name); } /* * Destroys the codec info structure returned by the functions * above */ void lqt_destroy_codec_info(lqt_codec_info_t ** info) { lqt_codec_info_t ** ptr = info; if(!ptr) return; while(*ptr) { lqt_codec_info_destroy_single(*ptr); ptr++; } free(info); } void lqt_set_default_parameter(lqt_codec_type type, int encode, const char * codec_name, const char * parameter_name, lqt_parameter_value_t * val) { int i, imax, parameter_found = 0; lqt_codec_info_t * codec_info; lqt_parameter_info_t * parameter_info; /* also init registry */ lqt_registry_init(); lqt_registry_lock(); if(type == LQT_CODEC_AUDIO) codec_info = lqt_audio_codecs; else codec_info = lqt_video_codecs; /* Search codec */ while(codec_info) { if(!strcmp(codec_name, codec_info->name)) break; codec_info = codec_info->next; } if(!codec_info) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "lqt_set_default_parameter: No %s codec %s found", ((type == LQT_CODEC_AUDIO) ? "audio" : "video"), codec_name); lqt_registry_unlock(); return; } /* Search parameter */ if(encode) { imax = codec_info->num_encoding_parameters; parameter_info = codec_info->encoding_parameters; } else { imax = codec_info->num_decoding_parameters; parameter_info = codec_info->decoding_parameters; } for(i = 0; i < imax; i++) { if(!strcmp(parameter_info[i].name, parameter_name)) { parameter_found = 1; break; } } if(!parameter_found) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "lqt_set_default_parameter: No parameter %s for codec %s found", parameter_name, codec_name); lqt_registry_unlock(); return; } /* Set the value */ switch(parameter_info[i].type) { case LQT_PARAMETER_INT: parameter_info[i].val_default.val_int = val->val_int; break; case LQT_PARAMETER_FLOAT: parameter_info[i].val_default.val_float = val->val_float; break; case LQT_PARAMETER_STRING: case LQT_PARAMETER_STRINGLIST: if(parameter_info[i].val_default.val_string) free(parameter_info[i].val_default.val_string); parameter_info[i].val_default.val_string = __lqt_strdup(val->val_string); break; case LQT_PARAMETER_SECTION: break; } lqt_registry_unlock(); return; } /* * I don't want to depend on one of the 1000s of MIN MAX macros out * there */ #define __LQT_MIN(a, b) ((amodule_filename, RTLD_NOW); if(!module) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "lqt_restore_default_parameters: dlopen failed for %s: %s", codec_info->module_filename, dlerror()); return; } get_codec_info = (lqt_codec_info_static_t*(*)(int))(dlsym(module, "get_codec_info")); if(!get_codec_info) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "Symbol %s not found in %s", "get_codec_info", codec_info->module_filename); return; } info_from_module = lqt_create_codec_info(get_codec_info(codec_info->module_index)); if(!info_from_module) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "Couldn't get codec info for %s from_module %s", codec_info->long_name, codec_info->module_filename); return; } if(encode) { imax = __LQT_MIN(info_from_module->num_encoding_parameters, codec_info->num_encoding_parameters); for(i = 0; i < imax; i++) { /* Small check prevents evil bugs in ill conditioned applications */ if(!strcmp(codec_info->encoding_parameters[i].name, info_from_module->encoding_parameters[i].name)) { copy_parameter_value(&codec_info->encoding_parameters[i].val_default, &info_from_module->encoding_parameters[i].val_default, codec_info->encoding_parameters[i].type); } } } if(decode) { imax = __LQT_MIN(info_from_module->num_decoding_parameters, codec_info->num_decoding_parameters); for(i = 0; i < imax; i++) { if(!strcmp(codec_info->decoding_parameters[i].name, info_from_module->decoding_parameters[i].name)) { copy_parameter_value(&codec_info->decoding_parameters[i].val_default, &info_from_module->decoding_parameters[i].val_default, codec_info->decoding_parameters[i].type); } } } if(module) dlclose(module); if(info_from_module) lqt_codec_info_destroy_single(info_from_module); } /* * Sort audio and video codecs */ /* * This is the actual sort function: It takes the original chained list * of the codecs and a string containing a comma separated list of the * codecs as arguments. It returns the newly sorted list. * * This string will also be saved in the codec file. */ static lqt_codec_info_t * sort_codecs_internal(lqt_codec_info_t * original, char * names) { char * pos; char * end_pos; int len; lqt_codec_info_t * before; lqt_codec_info_t * ptr; lqt_codec_info_t * start = original; lqt_codec_info_t * ret = (lqt_codec_info_t*)0; lqt_codec_info_t * ret_end = (lqt_codec_info_t*)0; pos = names; end_pos = strchr(pos, ','); if(!end_pos) end_pos = pos + strlen(pos); while(1) { /* Seek the codec in the list */ ptr = start; before = ptr; len = end_pos - pos; while(ptr) { if(!strncmp(pos, ptr->name, len)) /* Found the codec */ break; before = ptr; ptr = ptr->next; } if(ptr) { /* Remove codec from the list */ if(ptr == start) start = start->next; else before->next = ptr->next; ptr->next = (lqt_codec_info_t*)0; /* Append it to the returned list */ if(!ret) { ret = ptr; ret_end = ret; } else { ret_end->next = ptr; ret_end = ret_end->next; } } /* Get the next codec name */ pos = end_pos; if(*pos == '\0') break; pos++; end_pos = strchr(pos, ','); if(!end_pos) end_pos = pos + strlen(pos); } /* Append the rest of the list */ if(start) ret_end->next = start; return ret; } static char * create_seek_string(lqt_codec_info_t ** info) { int i; int num_codecs = 0; int string_length = 0; char * ret; while(info[num_codecs]) { string_length += strlen(info[num_codecs]->name) + 1; num_codecs++; } ret = malloc(string_length); *ret = '\0'; for(i = 0; i < num_codecs; i++) { strcat(ret, info[i]->name); if(i != num_codecs - 1) strcat(ret, ","); } return ret; } void lqt_reorder_audio_codecs(lqt_codec_info_t ** info) { char * seek_string = create_seek_string(info); lqt_registry_lock(); lqt_audio_codecs = sort_codecs_internal(lqt_audio_codecs, seek_string); lqt_registry_unlock(); free(seek_string); } void lqt_reorder_video_codecs(lqt_codec_info_t ** info) { char * seek_string = create_seek_string(info); lqt_registry_lock(); lqt_video_codecs = sort_codecs_internal(lqt_video_codecs, seek_string); lqt_registry_unlock(); free(seek_string); } /*************************************************************** * This will hopefully make the destruction for dynamic loading * (Trick comes from a 1995 version of the ELF Howto, so it * should work everywhere now) ***************************************************************/ #if defined(__GNUC__) static void __lqt_cleanup_codecinfo() __attribute__ ((destructor)); static void __lqt_cleanup_codecinfo() { lqt_registry_destroy(); } #endif libquicktime-1.2.4/src/stsdtable.c0000644000175000017500000010212711511622757014053 00000000000000/******************************************************************************* stsdtable.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include #include #define LOG_DOMAIN "stsdtable" static void quicktime_stsdtable_read_text(quicktime_t *file, quicktime_stsd_table_t *table, quicktime_atom_t *parent_atom) { table->text.displayFlags = quicktime_read_int32(file); table->text.textJustification = quicktime_read_int32(file); table->text.bgColor[0] = quicktime_read_int16(file); table->text.bgColor[1] = quicktime_read_int16(file); table->text.bgColor[2] = quicktime_read_int16(file); table->text.defaultTextBox[0] = quicktime_read_int16(file); table->text.defaultTextBox[1] = quicktime_read_int16(file); table->text.defaultTextBox[2] = quicktime_read_int16(file); table->text.defaultTextBox[3] = quicktime_read_int16(file); table->text.scrpStartChar = quicktime_read_int32(file); table->text.scrpHeight = quicktime_read_int16(file); table->text.scrpAscent = quicktime_read_int16(file); table->text.scrpFont = quicktime_read_int16(file); table->text.scrpFace = quicktime_read_int16(file); table->text.scrpSize = quicktime_read_int16(file); table->text.scrpColor[0] = quicktime_read_int16(file); table->text.scrpColor[1] = quicktime_read_int16(file); table->text.scrpColor[2] = quicktime_read_int16(file); quicktime_read_pascal(file, table->text.font_name); } static void quicktime_write_stsd_text(quicktime_t *file, quicktime_stsd_table_t *table) { quicktime_write_int32(file, table->text.displayFlags); quicktime_write_int32(file, table->text.textJustification); quicktime_write_int16(file, table->text.bgColor[0]); quicktime_write_int16(file, table->text.bgColor[1]); quicktime_write_int16(file, table->text.bgColor[2]); quicktime_write_int16(file, table->text.defaultTextBox[0]); quicktime_write_int16(file, table->text.defaultTextBox[1]); quicktime_write_int16(file, table->text.defaultTextBox[2]); quicktime_write_int16(file, table->text.defaultTextBox[3]); quicktime_write_int32(file, table->text.scrpStartChar); quicktime_write_int16(file, table->text.scrpHeight); quicktime_write_int16(file, table->text.scrpAscent); quicktime_write_int16(file, table->text.scrpFont); quicktime_write_int16(file, table->text.scrpFace); quicktime_write_int16(file, table->text.scrpSize); quicktime_write_int16(file, table->text.scrpColor[0]); quicktime_write_int16(file, table->text.scrpColor[1]); quicktime_write_int16(file, table->text.scrpColor[2]); quicktime_write_pascal(file, table->text.font_name); } static void quicktime_stsdtable_dump_text(quicktime_stsd_table_t *table) { lqt_dump(" displayFlags %08x\n", table->text.displayFlags); lqt_dump(" textJustification %d\n", table->text.textJustification); lqt_dump(" bgColor: [%d,%d,%d]\n", table->text.bgColor[0], table->text.bgColor[1],table->text.bgColor[2]); lqt_dump(" defaultTextBox: [%d,%d,%d,%d]\n", table->text.defaultTextBox[0], table->text.defaultTextBox[1], table->text.defaultTextBox[2], table->text.defaultTextBox[3]); lqt_dump(" scrpStartChar: %d\n", table->text.scrpStartChar); lqt_dump(" scrpHeight: %d\n", table->text.scrpHeight); lqt_dump(" scrpFont: %d\n", table->text.scrpFont); lqt_dump(" scrpFace: %d\n", table->text.scrpFace); lqt_dump(" scrpSize: %d\n", table->text.scrpSize); lqt_dump(" scrpColor: [%d,%d,%d]\n", table->text.scrpColor[0], table->text.scrpColor[1], table->text.scrpColor[2]); lqt_dump(" Font: %s\n", table->text.font_name); } static void quicktime_stsdtable_read_tx3g(quicktime_t *file, quicktime_stsd_table_t *table, quicktime_atom_t *parent_atom) { quicktime_atom_t leaf_atom; table->tx3g.display_flags = quicktime_read_int32(file); quicktime_read_data(file, &table->tx3g.horizontal_justification, 1); quicktime_read_data(file, &table->tx3g.vertical_justification, 1); quicktime_read_data(file, table->tx3g.back_color, 4); table->tx3g.defaultTextBox[0] = quicktime_read_int16(file); table->tx3g.defaultTextBox[1] = quicktime_read_int16(file); table->tx3g.defaultTextBox[2] = quicktime_read_int16(file); table->tx3g.defaultTextBox[3] = quicktime_read_int16(file); table->tx3g.start_char_offset = quicktime_read_int16(file); table->tx3g.end_char_offset = quicktime_read_int16(file); table->tx3g.font_id = quicktime_read_int16(file); quicktime_read_data(file, &table->tx3g.style_flags, 1); quicktime_read_data(file, &table->tx3g.font_size, 1); quicktime_read_data(file, table->tx3g.text_color, 4); while(quicktime_position(file) < parent_atom->end) { quicktime_atom_read_header(file, &leaf_atom); if(quicktime_atom_is(&leaf_atom, "ftab")) { quicktime_read_ftab(file, &table->tx3g.ftab); table->tx3g.has_ftab = 1; } else quicktime_atom_skip(file, &leaf_atom); } } static void quicktime_write_stsd_tx3g(quicktime_t *file, quicktime_stsd_table_t *table) { quicktime_write_int32(file, table->tx3g.display_flags); quicktime_write_data(file, &table->tx3g.horizontal_justification, 1); quicktime_write_data(file, &table->tx3g.vertical_justification, 1); quicktime_write_data(file, table->tx3g.back_color, 4); quicktime_write_int16(file, table->tx3g.defaultTextBox[0]); quicktime_write_int16(file, table->tx3g.defaultTextBox[1]); quicktime_write_int16(file, table->tx3g.defaultTextBox[2]); quicktime_write_int16(file, table->tx3g.defaultTextBox[3]); quicktime_write_int16(file, table->tx3g.start_char_offset); quicktime_write_int16(file, table->tx3g.end_char_offset); quicktime_write_int16(file, table->tx3g.font_id); quicktime_write_data(file, &table->tx3g.style_flags, 1); quicktime_write_data(file, &table->tx3g.font_size, 1); quicktime_write_data(file, table->tx3g.text_color, 4); if(table->tx3g.has_ftab) quicktime_write_ftab(file, &table->tx3g.ftab); } static void quicktime_stsdtable_dump_tx3g(quicktime_stsd_table_t *table) { lqt_dump(" display_flags: %08x\n", table->tx3g.display_flags); lqt_dump(" horizontal_justification: %d\n", table->tx3g.horizontal_justification); lqt_dump(" vertical_justification: %d\n", table->tx3g.vertical_justification); lqt_dump(" back_color: [%d,%d,%d,%d]\n", table->tx3g.back_color[0], table->tx3g.back_color[1], table->tx3g.back_color[2], table->tx3g.back_color[3]); lqt_dump(" defaultTextBox: [%d,%d,%d,%d]\n", table->tx3g.defaultTextBox[0], table->tx3g.defaultTextBox[1], table->tx3g.defaultTextBox[2], table->tx3g.defaultTextBox[3]); lqt_dump(" start_char_offset: %d\n", table->tx3g.start_char_offset); lqt_dump(" end_char_offset: %d\n", table->tx3g.end_char_offset); lqt_dump(" font_id: %d\n", table->tx3g.font_id); lqt_dump(" style_flags: %02x\n", table->tx3g.style_flags); lqt_dump(" font_size: %d\n", table->tx3g.font_size); lqt_dump(" text_color: [%d,%d,%d,%d]\n", table->tx3g.text_color[0], table->tx3g.text_color[1], table->tx3g.text_color[2], table->tx3g.text_color[3]); if(table->tx3g.has_ftab) { quicktime_ftab_dump(&table->tx3g.ftab); } } /* Timecode */ static void quicktime_stsdtable_read_timecode(quicktime_t *file, quicktime_stsd_table_t *table, quicktime_atom_t *parent_atom) { quicktime_atom_t leaf_atom; table->tmcd.reserved2 = quicktime_read_int32(file); table->tmcd.flags = quicktime_read_int32(file); table->tmcd.timescale = quicktime_read_int32(file); table->tmcd.frameduration = quicktime_read_int32(file); table->tmcd.numframes = quicktime_read_char(file); table->tmcd.reserved3 = quicktime_read_char(file); // table->tmcd.reserved3[1] = quicktime_read_char(file); // table->tmcd.reserved3[2] = quicktime_read_char(file); while(quicktime_position(file) < parent_atom->end) { quicktime_atom_read_header(file, &leaf_atom); if(quicktime_atom_is(&leaf_atom, "name")) { int len = 0; quicktime_read_udta_string(file, &table->tmcd.name, &len, 0); } else quicktime_atom_skip(file, &leaf_atom); } quicktime_atom_skip(file, parent_atom); } static void quicktime_write_stsd_timecode(quicktime_t *file, quicktime_stsd_table_t *table) { lqt_charset_converter_t * cnv = (lqt_charset_converter_t *)0; quicktime_atom_t child_atom; quicktime_write_int32(file, table->tmcd.reserved2); quicktime_write_int32(file, table->tmcd.flags); quicktime_write_int32(file, table->tmcd.timescale); quicktime_write_int32(file, table->tmcd.frameduration); quicktime_write_char(file, table->tmcd.numframes); quicktime_write_char(file, table->tmcd.reserved3); quicktime_atom_write_header(file, &child_atom, "name"); quicktime_write_udta_string(file, table->tmcd.name, 0, &cnv); quicktime_atom_write_footer(file, &child_atom); if(cnv) lqt_charset_converter_destroy(cnv); } static void quicktime_stsdtable_dump_timecode(quicktime_stsd_table_t *table) { printf(" reserved2 %d\n", table->tmcd.reserved2); printf(" flags %d\n", table->tmcd.flags); printf(" timescale %d\n", table->tmcd.timescale); printf(" frameduration %d\n", table->tmcd.frameduration); printf(" numframes %d\n", table->tmcd.numframes); printf(" reserved3 %02x\n", table->tmcd.reserved3); printf(" name: %s\n", table->tmcd.name); } /* Audio */ void quicktime_read_stsd_audio(quicktime_t *file, quicktime_stsd_table_t *table, quicktime_atom_t *parent_atom) { quicktime_atom_t leaf_atom; table->version = quicktime_read_int16(file); table->revision = quicktime_read_int16(file); quicktime_read_data(file, (uint8_t*)(table->vendor), 4); if(table->version < 2) { table->channels = quicktime_read_int16(file); table->sample_size = quicktime_read_int16(file); table->compression_id = quicktime_read_int16(file); table->packet_size = quicktime_read_int16(file); table->samplerate = quicktime_read_fixed32(file); // Kluge for fixed32 limitation if(table->samplerate + 65536 == 96000 || table->samplerate + 65536 == 88200) table->samplerate += 65536; if(table->version == 1) { table->audio_samples_per_packet = quicktime_read_int32(file); table->audio_bytes_per_packet = quicktime_read_int32(file); table->audio_bytes_per_frame = quicktime_read_int32(file); table->audio_bytes_per_sample = quicktime_read_int32(file); if(table->version == 2) // Skip another 20 bytes quicktime_set_position(file, quicktime_position(file) + 20); } } else /* SoundDescriptionV2 */ { /* * SInt16 always3; * SInt16 always16; * SInt16 alwaysMinus2; * SInt16 always0; * UInt32 always65536; * UInt32 sizeOfStructOnly; */ quicktime_set_position(file, quicktime_position(file) + 16); // quicktime_set_position(file, quicktime_position(file) + 12); /* * Float64 audioSampleRate; */ table->samplerate = quicktime_read_double64(file); /* * UInt32 numAudioChannels; */ table->channels = quicktime_read_int32(file); /* * SInt32 always7F000000; */ quicktime_set_position(file, quicktime_position(file) + 4); table->sample_size = quicktime_read_int32(file); table->formatSpecificFlags = quicktime_read_int32(file); /* The following 2 are (hopefully) unused */ table->constBytesPerAudioPacket = quicktime_read_int32(file); table->constLPCMFramesPerAudioPacket = quicktime_read_int32(file); // quicktime_set_position(file, quicktime_position(file) + 8); } /* Read additional atoms */ while(quicktime_position(file) < parent_atom->end) { quicktime_atom_read_header(file, &leaf_atom); if(quicktime_atom_is(&leaf_atom, "wave")) { quicktime_read_wave(file, &table->wave, &leaf_atom); table->has_wave = 1; } else if(quicktime_atom_is(&leaf_atom, "esds")) { quicktime_read_esds(file, &table->esds); table->has_esds = 1; quicktime_atom_skip(file, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "chan")) { quicktime_read_chan(file, &table->chan); table->has_chan = 1; quicktime_atom_skip(file, &leaf_atom); } else { lqt_log(file, LQT_LOG_INFO, LOG_DOMAIN, "Skipping unknown atom \"%4s\" inside audio stsd", leaf_atom.type); quicktime_atom_skip(file, &leaf_atom); } } } void quicktime_write_stsd_audio(quicktime_t *file, quicktime_stsd_table_t *table) { int tmp_version = file->file_type & (LQT_FILE_QT|LQT_FILE_QT_OLD) ? table->version : 0; if(IS_MP4(file->file_type)) { quicktime_write_int32(file, 0); quicktime_write_int32(file, 0); } else { quicktime_write_int16(file, tmp_version); quicktime_write_int16(file, table->revision); quicktime_write_data(file, (uint8_t*)(table->vendor), 4); } if(tmp_version < 2) { quicktime_write_int16(file, table->channels); quicktime_write_int16(file, (file->file_type & (LQT_FILE_QT|LQT_FILE_QT_OLD)) ? table->sample_size : 16); quicktime_write_int16(file, (file->file_type & (LQT_FILE_QT|LQT_FILE_QT_OLD)) ? table->compression_id : 0); quicktime_write_int16(file, table->packet_size); quicktime_write_fixed32(file, table->samplerate); if(tmp_version == 1) { quicktime_write_int32(file, table->audio_samples_per_packet); quicktime_write_int32(file, table->audio_bytes_per_packet); quicktime_write_int32(file, table->audio_bytes_per_frame); quicktime_write_int32(file, table->audio_bytes_per_sample); } } else { quicktime_write_int16(file, 0x0003); // SInt16 always3; quicktime_write_int16(file, 0x0010); // SInt16 always16; quicktime_write_int16(file, 0xFFFE); // SInt16 alwaysMinus2; quicktime_write_int16(file, 0x0000); // SInt16 always0; quicktime_write_int32(file, 0x00010000); // UInt32 always65536; quicktime_write_int32(file, 0x00000048); // UInt32 sizeOfStructOnly; quicktime_write_double64(file, table->samplerate); // Float64 audioSampleRate; quicktime_write_int32(file, table->channels); // UInt32 numAudioChannels; quicktime_write_int32(file, 0x7F000000); // SInt32 always7F000000; quicktime_write_int32(file, table->sample_size); // UInt32 constBitsPerChannel; quicktime_write_int32(file, table->formatSpecificFlags); // UInt32 formatSpecificFlags; quicktime_write_int32(file, table->constBytesPerAudioPacket); // UInt32 constBytesPerAudioPacket; quicktime_write_int32(file, table->constLPCMFramesPerAudioPacket); // UInt32 constLPCMFramesPerAudioPacket; } if(file->file_type & (LQT_FILE_QT|LQT_FILE_QT_OLD)) { if(table->has_wave) { /* For quicktime, we must put the esds atom into the wave atom */ if(table->has_esds) { memcpy(&table->wave.esds, &table->esds, sizeof(table->wave.esds)); table->wave.has_esds = 1; } quicktime_write_wave(file, &table->wave); if(table->has_esds) { memset(&table->wave.esds, 0, sizeof(table->wave.esds)); table->wave.has_esds = 0; } } if(table->has_chan) quicktime_write_chan(file, &table->chan); } else { if(table->has_esds) quicktime_write_esds(file, &table->esds); } quicktime_write_user_atoms(file, &table->user_atoms); } void quicktime_read_stsd_table_raw(quicktime_t *file, quicktime_stsd_table_t *table) { quicktime_atom_t leaf_atom; int64_t old_position; old_position = quicktime_position(file); quicktime_atom_read_header(file, &leaf_atom); /* We write the raw atom verbatim into the raw table */ table->table_raw_size = leaf_atom.size; table->table_raw = malloc(table->table_raw_size); quicktime_set_position(file, leaf_atom.start); quicktime_read_data(file, table->table_raw, table->table_raw_size); } void quicktime_read_stsd_video(quicktime_t *file, quicktime_stsd_table_t *table, quicktime_atom_t *parent_atom) { quicktime_atom_t leaf_atom; int len, bits_per_pixel; table->version = quicktime_read_int16(file); table->revision = quicktime_read_int16(file); quicktime_read_data(file, (uint8_t*)table->vendor, 4); table->temporal_quality = quicktime_read_int32(file); table->spatial_quality = quicktime_read_int32(file); table->width = quicktime_read_int16(file); table->height = quicktime_read_int16(file); table->dpi_horizontal = quicktime_read_fixed32(file); table->dpi_vertical = quicktime_read_fixed32(file); table->data_size = quicktime_read_int32(file); table->frames_per_sample = quicktime_read_int16(file); len = quicktime_read_char(file); quicktime_read_data(file, (uint8_t*)table->compressor_name, 31); table->depth = quicktime_read_int16(file); table->ctab_id = quicktime_read_int16(file); /* If ctab_id is zero, the colortable follows immediately * after the ctab ID */ bits_per_pixel = table->depth & 0x1f; if(!table->ctab_id && ((bits_per_pixel == 1) || (bits_per_pixel == 2) || (bits_per_pixel == 4) || (bits_per_pixel == 8))) { quicktime_read_ctab(file, &table->ctab); table->has_ctab = 1; } else quicktime_default_ctab(&table->ctab, table->depth); while(quicktime_position(file) + 8 < parent_atom->end) { quicktime_atom_read_header(file, &leaf_atom); if(quicktime_atom_is(&leaf_atom, "ctab")) { quicktime_read_ctab(file, &table->ctab); table->has_ctab = 1; } else if(quicktime_atom_is(&leaf_atom, "gama")) { quicktime_read_gama(file, &table->gama); table->has_gama = 1; } else if(quicktime_atom_is(&leaf_atom, "fiel")) { quicktime_read_fiel(file, &table->fiel); table->has_fiel = 1; } else if(quicktime_atom_is(&leaf_atom, "pasp")) { quicktime_read_pasp(file, &table->pasp); table->has_pasp = 1; } else if(quicktime_atom_is(&leaf_atom, "clap")) { quicktime_read_clap(file, &table->clap); table->has_clap = 1; } else if (quicktime_atom_is(&leaf_atom, "colr")) { quicktime_read_colr(file, &table->colr); table->has_colr = 1; } else if(quicktime_atom_is(&leaf_atom, "esds")) { // printf("esds: %"PRId64" bytes\n", leaf_atom.size); quicktime_read_esds(file, &table->esds); table->has_esds = 1; quicktime_atom_skip(file, &leaf_atom); } else { quicktime_user_atoms_read_atom(file, &table->user_atoms, &leaf_atom); } quicktime_atom_skip(file, &leaf_atom); } } void quicktime_write_stsd_video(quicktime_t *file, quicktime_stsd_table_t *table) { int compressor_name_len, i; int terminate = 0; compressor_name_len = strlen(table->compressor_name); if(file->file_type & (LQT_FILE_QT|LQT_FILE_QT_OLD)) { quicktime_write_int16(file, table->version); quicktime_write_int16(file, table->revision); quicktime_write_data(file, (uint8_t*)table->vendor, 4); quicktime_write_int32(file, table->temporal_quality); quicktime_write_int32(file, table->spatial_quality); quicktime_write_int16(file, table->width); quicktime_write_int16(file, table->height); quicktime_write_fixed32(file, table->dpi_horizontal); quicktime_write_fixed32(file, table->dpi_vertical); quicktime_write_int32(file, table->data_size); quicktime_write_int16(file, table->frames_per_sample); quicktime_write_char(file, compressor_name_len); quicktime_write_data(file, (uint8_t*)table->compressor_name, 31); quicktime_write_int16(file, table->depth); quicktime_write_int16(file, table->ctab_id); if (table->has_pasp) { quicktime_write_pasp(file, &table->pasp); terminate = 1; } if (table->has_clap) { quicktime_write_clap(file, &table->clap); terminate = 1; } if (table->has_colr) { quicktime_write_colr(file, &table->colr); terminate = 1; } if (table->has_fiel) { quicktime_write_fiel(file, &table->fiel); terminate = 1; } if (table->has_gama) { quicktime_write_gama(file, &table->gama); terminate = 1; } } else /* Different stsd formats for mp4 variants */ { quicktime_write_int16(file, 0); quicktime_write_int16(file, 0); quicktime_write_int32(file, 0); quicktime_write_int32(file, 0); quicktime_write_int32(file, 0); quicktime_write_int16(file, table->width); quicktime_write_int16(file, table->height); quicktime_write_fixed32(file, 0x00480000); quicktime_write_fixed32(file, 0x00480000); quicktime_write_int32(file, 0); quicktime_write_int16(file, 1); quicktime_write_data(file, (uint8_t*)table->compressor_name, compressor_name_len); for(i = 0; i < 32 - compressor_name_len; i++) quicktime_write_char(file, 0); quicktime_write_int16(file, 24); quicktime_write_int16(file, -1); } quicktime_write_user_atoms(file, &table->user_atoms); if(table->has_esds) quicktime_write_esds(file, &table->esds); if(terminate) quicktime_write_int32(file, 0); } void quicktime_read_stsd_table(quicktime_t *file, quicktime_minf_t *minf, quicktime_stsd_table_t *table) { quicktime_atom_t leaf_atom; quicktime_atom_read_header(file, &leaf_atom); table->format[0] = leaf_atom.type[0]; table->format[1] = leaf_atom.type[1]; table->format[2] = leaf_atom.type[2]; table->format[3] = leaf_atom.type[3]; quicktime_read_data(file, table->reserved, 6); table->data_reference = quicktime_read_int16(file); /* Panoramas are neither audio nor video */ if (quicktime_match_32(leaf_atom.type, "pano")) { minf->is_panorama = 1; quicktime_read_pano(file, &table->pano, &leaf_atom); } else if (quicktime_match_32(leaf_atom.type, "qtvr")) { minf->is_qtvr = 1; quicktime_read_qtvr(file, &table->qtvr, &leaf_atom); } else if (quicktime_match_32(leaf_atom.type, "\0\0\0\0") && file->moov.udta.is_qtvr) { minf->is_object = 1; } else if (quicktime_match_32(leaf_atom.type, "text")) { quicktime_stsdtable_read_text(file, table, &leaf_atom); minf->is_text = 1; } else if (quicktime_match_32(leaf_atom.type, "tx3g")) { quicktime_stsdtable_read_tx3g(file, table, &leaf_atom); minf->is_text = 1; } else if (quicktime_match_32(leaf_atom.type, "tmcd")) { quicktime_stsdtable_read_timecode(file, table, &leaf_atom); minf->is_timecode = 1; } else { if(minf->is_audio) quicktime_read_stsd_audio(file, table, &leaf_atom); if(minf->is_video) quicktime_read_stsd_video(file, table, &leaf_atom); } } void quicktime_stsd_table_init(quicktime_stsd_table_t *table) { int i; table->format[0] = 'y'; table->format[1] = 'u'; table->format[2] = 'v'; table->format[3] = '2'; for(i = 0; i < 6; i++) table->reserved[i] = 0; table->data_reference = 1; table->version = 0; table->revision = 0; table->vendor[0] = 'l'; table->vendor[1] = 'q'; table->vendor[2] = 't'; table->vendor[3] = ' '; table->temporal_quality = 100; table->spatial_quality = 258; table->width = 0; table->height = 0; table->dpi_horizontal = 72; table->dpi_vertical = 72; table->data_size = 0; table->frames_per_sample = 1; for(i = 0; i < 32; i++) table->compressor_name[i] = 0; sprintf(table->compressor_name, "%s-%s", PACKAGE, VERSION); table->depth = 24; table->ctab_id = 65535; quicktime_ctab_init(&table->ctab); quicktime_pasp_init(&table->pasp); quicktime_gama_init(&table->gama); quicktime_fiel_init(&table->fiel); quicktime_clap_init(&table->clap); quicktime_colr_init(&table->colr); quicktime_pano_init(&table->pano); quicktime_qtvr_init(&table->qtvr); quicktime_chan_init(&table->chan); table->channels = 0; table->sample_size = 0; table->compression_id = 0; table->packet_size = 0; table->samplerate = 0.0; } void quicktime_stsd_table_delete(quicktime_stsd_table_t *table) { /* LQT: Delete table_raw as well */ if(table->table_raw) free(table->table_raw); quicktime_ctab_delete(&table->ctab); quicktime_wave_delete(&table->wave); quicktime_esds_delete(&table->esds); quicktime_ftab_delete(&table->tx3g.ftab); quicktime_user_atoms_delete(&table->user_atoms); if(table->tmcd.name) free(table->tmcd.name); } void quicktime_stsd_video_dump(quicktime_stsd_table_t *table) { lqt_dump(" version %d\n", table->version); lqt_dump(" revision %d\n", table->revision); lqt_dump(" vendor %c%c%c%c\n", table->vendor[0], table->vendor[1], table->vendor[2], table->vendor[3]); lqt_dump(" temporal_quality %ld\n", table->temporal_quality); lqt_dump(" spatial_quality %ld\n", table->spatial_quality); lqt_dump(" width %d\n", table->width); lqt_dump(" height %d\n", table->height); lqt_dump(" dpi_horizontal %f\n", table->dpi_horizontal); lqt_dump(" dpi_vertical %f\n", table->dpi_vertical); lqt_dump(" data_size %"PRId64"\n", table->data_size); lqt_dump(" frames_per_sample %d\n", table->frames_per_sample); lqt_dump(" compressor_name %s\n", table->compressor_name); lqt_dump(" depth %d\n", table->depth); lqt_dump(" ctab_id %d\n", table->ctab_id); if (table->has_pasp) quicktime_pasp_dump(&table->pasp); if (table->has_clap) quicktime_clap_dump(&table->clap); if (table->has_colr) quicktime_colr_dump(&table->colr); if (table->has_fiel) quicktime_fiel_dump(&table->fiel); if (table->has_gama) quicktime_gama_dump(&table->gama); if(table->has_ctab) quicktime_ctab_dump(&table->ctab); if(table->has_esds) quicktime_esds_dump(&table->esds); quicktime_user_atoms_dump(&table->user_atoms); } void quicktime_stsd_audio_dump(quicktime_stsd_table_t *table) { lqt_dump(" version %d\n", table->version); lqt_dump(" revision %d\n", table->revision); lqt_dump(" vendor %c%c%c%c\n", table->vendor[0], table->vendor[1], table->vendor[2], table->vendor[3]); lqt_dump(" channels %d\n", table->channels); lqt_dump(" sample_size %d\n", table->sample_size); if(table->version < 2) { lqt_dump(" compression_id %d\n", table->compression_id); lqt_dump(" packet_size %d\n", table->packet_size); lqt_dump(" samplerate %f\n", table->samplerate); if(table->version == 1) { lqt_dump(" samples_per_packet: %d\n", table->audio_samples_per_packet); lqt_dump(" bytes_per_packet: %d\n", table->audio_bytes_per_packet); lqt_dump(" bytes_per_frame: %d\n", table->audio_bytes_per_frame); lqt_dump(" bytes_per_samples: %d\n", table->audio_bytes_per_sample); } } else if(table->version == 2) { lqt_dump(" samplerate %f\n", table->samplerate); lqt_dump(" formatSpecificFlags: %08x\n", table->formatSpecificFlags); lqt_dump(" constBytesPerAudioPacket: %d\n", table->constBytesPerAudioPacket); lqt_dump(" constLPCMFramesPerAudioPacket: %d\n", table->constLPCMFramesPerAudioPacket); } if(table->has_wave) quicktime_wave_dump(&table->wave); if(table->has_esds) quicktime_esds_dump(&table->esds); if(table->has_chan) quicktime_chan_dump(&table->chan); quicktime_user_atoms_dump(&table->user_atoms); } void quicktime_stsd_table_dump(void *minf_ptr, quicktime_stsd_table_t *table) { quicktime_minf_t *minf = minf_ptr; lqt_dump(" format %c%c%c%c\n", table->format[0], table->format[1], table->format[2], table->format[3]); quicktime_print_chars(" reserved ", table->reserved, 6); lqt_dump(" data_reference %d\n", table->data_reference); if(minf->is_audio) quicktime_stsd_audio_dump(table); else if(minf->is_video) quicktime_stsd_video_dump(table); else if (quicktime_match_32(table->format, "pano")) quicktime_pano_dump(&table->pano); else if (quicktime_match_32(table->format, "qtvr")) quicktime_qtvr_dump(&table->qtvr); else if(quicktime_match_32(table->format, "text")) quicktime_stsdtable_dump_text(table); else if(quicktime_match_32(table->format, "tx3g")) quicktime_stsdtable_dump_tx3g(table); else if(quicktime_match_32(table->format, "tx3g")) quicktime_stsdtable_dump_tx3g(table); else if(quicktime_match_32(table->format, "tmcd")) quicktime_stsdtable_dump_timecode(table); } void quicktime_write_stsd_table(quicktime_t *file, quicktime_minf_t *minf, quicktime_stsd_table_t *table) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, table->format); quicktime_write_data(file, table->reserved, 6); quicktime_write_int16(file, table->data_reference); if(minf->is_audio) quicktime_write_stsd_audio(file, table); if(minf->is_video) quicktime_write_stsd_video(file, table); if(minf->is_qtvr == QTVR_QTVR_PAN) quicktime_write_qtvr(file, &table->qtvr); if(minf->is_qtvr == QTVR_QTVR_OBJ) quicktime_write_qtvr(file, &table->qtvr); if(minf->is_timecode) quicktime_write_stsd_timecode(file, table); if(minf->is_text) { if(quicktime_match_32(table->format, "text")) quicktime_write_stsd_text(file, table); else if(quicktime_match_32(table->format, "tx3g")) quicktime_write_stsd_tx3g(file, table); } quicktime_atom_write_footer(file, &atom); } void quicktime_set_stsd_audio_v1(quicktime_stsd_table_t *table, uint32_t samples_per_packet, uint32_t bytes_per_packet, uint32_t bytes_per_frame, uint32_t bytes_per_sample) { table->version = 1; table->audio_samples_per_packet = samples_per_packet; table->audio_bytes_per_packet = bytes_per_packet; table->audio_bytes_per_frame = bytes_per_frame; table->audio_bytes_per_sample = bytes_per_sample; } #if 1 void quicktime_set_stsd_audio_v2(quicktime_stsd_table_t *table, uint32_t formatSpecificFlags, uint32_t constBytesPerAudioPacket, uint32_t constLPCMFramesPerAudioPacket) { table->version = 2; table->formatSpecificFlags = formatSpecificFlags; table->constBytesPerAudioPacket = constBytesPerAudioPacket; table->constLPCMFramesPerAudioPacket = constLPCMFramesPerAudioPacket; } #endif uint8_t * quicktime_stsd_get_user_atom(quicktime_trak_t * trak, char * name, uint32_t * len) { quicktime_stsd_table_t *table = &trak->mdia.minf.stbl.stsd.table[0]; return(quicktime_user_atoms_get_atom(&table->user_atoms, name, len)); } void quicktime_stsd_set_user_atom(quicktime_trak_t * trak, char * name, uint8_t * data, uint32_t len) { quicktime_stsd_table_t *table = &trak->mdia.minf.stbl.stsd.table[0]; quicktime_user_atoms_add_atom(&table->user_atoms, name, data, len); } libquicktime-1.2.4/src/obji.c0000644000175000017500000001431611511622757013013 00000000000000/******************************************************************************* obji.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" int quicktime_obji_init(quicktime_obji_t *obji) { obji->version = 2; obji->revision = 0; obji->movieType = 1; obji->viewStateCount = 1; obji->defaultViewState = 1; obji->mouseDownViewState = 1; obji->viewDuration = 600; obji->mouseMotionScale = 180; obji->minPan = 0; obji->maxPan = 360; obji->defaultPan = 0; obji->minTilt = 72; obji->maxTilt = -72; obji->defaultTilt = 0; obji->minFOV = 0; obji->FOV = 64; obji->defaultFOV = 64; obji->defaultViewCenterH = 120; obji->defaultViewCenterV = 160; obji->viewRate = 1; obji->frameRate = 1; obji->controlSettings = 69; return 0; } int quicktime_obji_delete(quicktime_obji_t *obji) { return 0; } void quicktime_obji_dump(quicktime_obji_t *obji) { lqt_dump("object node (obji)\n"); lqt_dump(" version %i\n", obji->version ); lqt_dump(" revision %i\n", obji->revision ); lqt_dump(" movie type %i\n", obji->movieType ); lqt_dump(" view state count %i\n", obji->viewStateCount ); lqt_dump(" default viewstate %i\n", obji->defaultViewState ); lqt_dump(" mousedown viewstate %i\n", obji->mouseDownViewState ); lqt_dump(" view duration %ld\n", obji->viewDuration ); lqt_dump(" columns %ld\n", obji->columns ); lqt_dump(" rows %ld\n", obji->rows ); lqt_dump(" mouse motion scale %f\n", obji->mouseMotionScale); lqt_dump(" minimum pan %f\n", obji->minPan ); lqt_dump(" maximum pan %f\n", obji->maxPan ); lqt_dump(" default pan %f\n", obji->defaultPan ); lqt_dump(" minimum tilt %f\n", obji->minTilt ); lqt_dump(" maximum tilt %f\n", obji->maxTilt ); lqt_dump(" default tilt %f\n", obji->defaultTilt ); lqt_dump(" minimum fov %f\n", obji->minFOV ); lqt_dump(" fov %f\n", obji->FOV ); lqt_dump(" default fov %f\n", obji->defaultFOV ); lqt_dump(" default horizontal viewcenter %f\n", obji->defaultViewCenterH ); lqt_dump(" default vertical viewcenter %f\n", obji->defaultViewCenterV ); lqt_dump(" view rate %f\n", obji->viewRate ); lqt_dump(" frame rate %f\n", obji->frameRate ); lqt_dump(" animation settings %ld\n", obji->animSettings ); lqt_dump(" control settings %ld\n", obji->controlSettings ); } int quicktime_read_obji(quicktime_t *file, quicktime_obji_t *obji) { obji->version = quicktime_read_int16(file); obji->revision = quicktime_read_int16(file); obji->movieType = quicktime_read_int16(file); obji->viewStateCount = quicktime_read_int16(file); obji->defaultViewState = quicktime_read_int16(file); obji->mouseDownViewState = quicktime_read_int16(file); obji->viewDuration = quicktime_read_int32(file); obji->columns = quicktime_read_int32(file); obji->rows = quicktime_read_int32(file); obji->mouseMotionScale = quicktime_read_float32(file); obji->minPan = quicktime_read_float32(file); obji->maxPan = quicktime_read_float32(file); obji->defaultPan = quicktime_read_float32(file); obji->minTilt = quicktime_read_float32(file); obji->maxTilt = quicktime_read_float32(file); obji->defaultTilt = quicktime_read_float32(file); obji->minFOV = quicktime_read_float32(file); obji->FOV = quicktime_read_float32(file); obji->defaultFOV = quicktime_read_float32(file); obji->defaultViewCenterH = quicktime_read_float32(file); obji->defaultViewCenterV = quicktime_read_float32(file); obji->viewRate = quicktime_read_float32(file); obji->frameRate = quicktime_read_float32(file); obji->animSettings = quicktime_read_int32(file); obji->controlSettings = quicktime_read_int32(file); return 0; } void quicktime_write_obji(quicktime_t *file, quicktime_obji_t *obji) { quicktime_write_int16(file, obji->version); quicktime_write_int16(file, obji->revision); quicktime_write_int16(file, obji->movieType); quicktime_write_int16(file, obji->viewStateCount); quicktime_write_int16(file, obji->defaultViewState); quicktime_write_int16(file, obji->mouseDownViewState); quicktime_write_int32(file, obji->viewDuration); quicktime_write_int32(file, obji->columns); quicktime_write_int32(file, obji->rows); quicktime_write_float32(file, obji->mouseMotionScale); quicktime_write_float32(file, obji->minPan); quicktime_write_float32(file, obji->maxPan); quicktime_write_float32(file, obji->defaultPan); quicktime_write_float32(file, obji->minTilt); quicktime_write_float32(file, obji->maxTilt); quicktime_write_float32(file, obji->defaultTilt); quicktime_write_float32(file, obji->minFOV); quicktime_write_float32(file, obji->FOV); quicktime_write_float32(file, obji->defaultFOV); quicktime_write_float32(file, obji->defaultViewCenterH); quicktime_write_float32(file, obji->defaultViewCenterV); quicktime_write_float32(file, obji->viewRate); quicktime_write_float32(file, obji->frameRate); quicktime_write_int32(file, obji->animSettings); quicktime_write_int32(file, obji->controlSettings); return; } libquicktime-1.2.4/src/stss.c0000644000175000017500000000564111511622757013065 00000000000000/******************************************************************************* stss.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include void quicktime_stss_init(quicktime_stss_t *stss) { stss->version = 0; stss->flags = 0; stss->total_entries = 0; stss->entries_allocated = 0; stss->table = NULL; } void quicktime_stss_delete(quicktime_stss_t *stss) { if(stss->table) free(stss->table); stss->total_entries = 0; stss->entries_allocated = 0; stss->table = 0; } void quicktime_stss_dump(quicktime_stss_t *stss) { int i; lqt_dump(" sync sample (stss)\n"); lqt_dump(" version %d\n", stss->version); lqt_dump(" flags %ld\n", stss->flags); lqt_dump(" total_entries %ld\n", stss->total_entries); for(i = 0; i < stss->total_entries; i++) { lqt_dump(" sample %lx\n", stss->table[i].sample); } } void quicktime_read_stss(quicktime_t *file, quicktime_stss_t *stss) { int i; stss->version = quicktime_read_char(file); stss->flags = quicktime_read_int24(file); stss->total_entries = quicktime_read_int32(file); if(stss->entries_allocated < stss->total_entries) { stss->entries_allocated = stss->total_entries; stss->table = (quicktime_stss_table_t*)realloc(stss->table, sizeof(quicktime_stss_table_t) * stss->entries_allocated); } for(i = 0; i < stss->total_entries; i++) { stss->table[i].sample = quicktime_read_int32(file); } } void quicktime_write_stss(quicktime_t *file, quicktime_stss_t *stss) { int i; quicktime_atom_t atom; if(stss->total_entries) { quicktime_atom_write_header(file, &atom, "stss"); quicktime_write_char(file, stss->version); quicktime_write_int24(file, stss->flags); quicktime_write_int32(file, stss->total_entries); for(i = 0; i < stss->total_entries; i++) { quicktime_write_int32(file, stss->table[i].sample); } quicktime_atom_write_footer(file, &atom); } } libquicktime-1.2.4/src/mvhd.c0000644000175000017500000001337511722257565013037 00000000000000/******************************************************************************* mvhd.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" int quicktime_mvhd_init(quicktime_mvhd_t *mvhd) { int i; mvhd->version = 0; mvhd->flags = 0; mvhd->creation_time = quicktime_current_time(); mvhd->modification_time = quicktime_current_time(); mvhd->time_scale = 600; mvhd->duration = 0; mvhd->preferred_rate = 1.0; mvhd->preferred_volume = 1.0; for(i = 0; i < 10; i++) mvhd->reserved[i] = 0; quicktime_matrix_init(&mvhd->matrix); mvhd->preview_time = 0; mvhd->preview_duration = 0; mvhd->poster_time = 0; mvhd->selection_time = 0; mvhd->selection_duration = 0; mvhd->current_time = 0; mvhd->next_track_id = 1; return 0; } int quicktime_mvhd_delete(quicktime_mvhd_t *mvhd) { return 0; } void quicktime_mvhd_dump(quicktime_mvhd_t *mvhd) { lqt_dump(" movie header (mvhd)\n"); lqt_dump(" version %d\n", mvhd->version); lqt_dump(" flags %ld\n", mvhd->flags); lqt_dump(" creation_time "); lqt_dump_time(mvhd->creation_time); lqt_dump("\n"); lqt_dump(" modification_time "); lqt_dump_time(mvhd->modification_time); lqt_dump("\n"); lqt_dump(" time_scale %ld\n", mvhd->time_scale); lqt_dump(" duration %"PRId64"\n", mvhd->duration); lqt_dump(" preferred_rate %f\n", mvhd->preferred_rate); lqt_dump(" preferred_volume %f\n", mvhd->preferred_volume); quicktime_print_chars(" reserved ", mvhd->reserved, 10); quicktime_matrix_dump(&mvhd->matrix); lqt_dump(" preview_time %ld\n", mvhd->preview_time); lqt_dump(" preview_duration %ld\n", mvhd->preview_duration); lqt_dump(" poster_time %ld\n", mvhd->poster_time); lqt_dump(" selection_time %ld\n", mvhd->selection_time); lqt_dump(" selection_duration %ld\n", mvhd->selection_duration); lqt_dump(" current_time %ld\n", mvhd->current_time); lqt_dump(" next_track_id %ld\n", mvhd->next_track_id); } void quicktime_read_mvhd(quicktime_t *file, quicktime_mvhd_t *mvhd, quicktime_atom_t *parent_atom) { mvhd->version = quicktime_read_char(file); mvhd->flags = quicktime_read_int24(file); if(mvhd->version == 0) { mvhd->creation_time = quicktime_read_int32(file); mvhd->modification_time = quicktime_read_int32(file); } else if(mvhd->version == 1) { mvhd->creation_time = quicktime_read_int64(file); mvhd->modification_time = quicktime_read_int64(file); } mvhd->time_scale = quicktime_read_int32(file); if(mvhd->version == 0) mvhd->duration = quicktime_read_int32(file); else if(mvhd->version == 1) mvhd->duration = quicktime_read_int64(file); mvhd->preferred_rate = quicktime_read_fixed32(file); mvhd->preferred_volume = quicktime_read_fixed16(file); quicktime_read_data(file, mvhd->reserved, 10); quicktime_read_matrix(file, &mvhd->matrix); mvhd->preview_time = quicktime_read_int32(file); mvhd->preview_duration = quicktime_read_int32(file); mvhd->poster_time = quicktime_read_int32(file); mvhd->selection_time = quicktime_read_int32(file); mvhd->selection_duration = quicktime_read_int32(file); mvhd->current_time = quicktime_read_int32(file); mvhd->next_track_id = quicktime_read_int32(file); } void quicktime_mhvd_init_video(quicktime_t *file, quicktime_mvhd_t *mvhd, int timescale) { if((mvhd->time_scale % timescale) || (mvhd->time_scale < timescale)) mvhd->time_scale = timescale; } void quicktime_write_mvhd(quicktime_t *file, quicktime_mvhd_t *mvhd) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "mvhd"); quicktime_write_char(file, mvhd->version); quicktime_write_int24(file, mvhd->flags); if(mvhd->version == 0) { quicktime_write_int32(file, mvhd->creation_time); quicktime_write_int32(file, mvhd->modification_time); } else if(mvhd->version == 1) { quicktime_write_int64(file, mvhd->creation_time); quicktime_write_int64(file, mvhd->modification_time); } quicktime_write_int32(file, mvhd->time_scale); if(mvhd->version == 0) quicktime_write_int32(file, mvhd->duration); else if(mvhd->version == 1) quicktime_write_int64(file, mvhd->duration); quicktime_write_fixed32(file, mvhd->preferred_rate); quicktime_write_fixed16(file, mvhd->preferred_volume); quicktime_write_data(file, mvhd->reserved, 10); quicktime_write_matrix(file, &mvhd->matrix); quicktime_write_int32(file, mvhd->preview_time); quicktime_write_int32(file, mvhd->preview_duration); quicktime_write_int32(file, mvhd->poster_time); quicktime_write_int32(file, mvhd->selection_time); quicktime_write_int32(file, mvhd->selection_duration); quicktime_write_int32(file, mvhd->current_time); quicktime_write_int32(file, mvhd->next_track_id); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/cmodel_default.c0000644000175000017500000005307111670173743015042 00000000000000/******************************************************************************* cmodel_default.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #define HAVE_RGB_16_TO_RGB_24 #define HAVE_RGB_TO_YUV #define HAVE_RGB_TO_YUVJ #define HAVE_YUV_TO_RGB #define HAVE_YUVJ_TO_RGB #define HAVE_YUV_8_TO_YUVJ #define HAVE_YUVJ_TO_YUV_8 #include "lqt_private.h" #include "cmodel_permutation.h" #define TRANSFER_FRAME_DEFAULT(output, \ input, \ y_in_offset, \ u_in_offset, \ v_in_offset, \ input_column) \ { \ register int i, j; \ \ switch(in_colormodel) \ { \ case BC_RGB565: \ switch(out_colormodel) \ { \ case BC_RGB565: \ TRANSFER_FRAME_HEAD_16 \ transfer_RGB565_to_RGB565((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB888: \ TRANSFER_FRAME_HEAD \ transfer_RGB565_to_RGB888((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_FRAME_HEAD \ transfer_RGB565_to_RGBA8888((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ } \ break; \ case BC_BGR565: \ switch(out_colormodel) \ { \ case BC_BGR565: \ TRANSFER_FRAME_HEAD_16 \ transfer_BGR565_to_BGR565((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB888: \ TRANSFER_FRAME_HEAD \ transfer_BGR565_to_RGB888((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_FRAME_HEAD \ transfer_BGR565_to_RGBA8888((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ } \ break; \ case BC_YUVA8888: \ switch(out_colormodel) \ { \ case BC_BGR565: \ TRANSFER_FRAME_HEAD_16 \ transfer_YUVA8888_to_BGR565((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB565: \ TRANSFER_FRAME_HEAD_16 \ transfer_YUVA8888_to_RGB565((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR888: \ TRANSFER_FRAME_HEAD \ transfer_YUVA8888_to_BGR888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR8888: \ TRANSFER_FRAME_HEAD \ transfer_YUVA8888_to_BGR8888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB888: \ TRANSFER_FRAME_HEAD \ transfer_YUVA8888_to_RGB888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_FRAME_HEAD \ transfer_YUVA8888_to_RGBA8888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVA8888: \ TRANSFER_FRAME_HEAD \ transfer_YUVA8888_to_YUVA8888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV420P: \ TRANSFER_YUV420P_OUT_HEAD \ transfer_YUVA8888_to_YUV420P_YUV422P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P: \ TRANSFER_YUV422P_OUT_HEAD \ transfer_YUVA8888_to_YUV420P_YUV422P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV444P: \ TRANSFER_YUV444P_OUT_HEAD \ transfer_YUVA8888_to_YUV444P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422: \ TRANSFER_FRAME_HEAD \ transfer_YUVA8888_to_YUV422((output), \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ } \ break; \ \ case BC_RGB888: \ switch(out_colormodel) \ { \ case BC_BGR565: \ TRANSFER_FRAME_HEAD_16 \ transfer_RGB888_to_BGR565((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB565: \ TRANSFER_FRAME_HEAD_16 \ transfer_RGB888_to_RGB565((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR888: \ TRANSFER_FRAME_HEAD \ transfer_RGB888_to_BGR888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB888: \ TRANSFER_FRAME_HEAD \ transfer_RGB888_to_RGB888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_FRAME_HEAD \ transfer_RGB888_to_RGBA8888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB161616: \ TRANSFER_FRAME_HEAD_16 \ transfer_RGB888_to_RGB161616((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA16161616: \ TRANSFER_FRAME_HEAD_16 \ transfer_RGB888_to_RGBA16161616((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR8888: \ TRANSFER_FRAME_HEAD \ transfer_RGB888_to_BGR8888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVA8888: \ TRANSFER_FRAME_HEAD \ transfer_RGB888_to_YUVA8888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV420P: \ TRANSFER_YUV420P_OUT_HEAD \ transfer_RGB888_to_YUV420P_YUV422P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVJ420P: \ TRANSFER_YUV420P_OUT_HEAD \ transfer_RGB888_to_YUVJ420P_YUVJ422P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422: \ TRANSFER_FRAME_HEAD \ transfer_RGB888_to_YUV422((output), (input), j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P: \ TRANSFER_YUV422P_OUT_HEAD \ transfer_RGB888_to_YUV420P_YUV422P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVJ422P: \ TRANSFER_YUV422P_OUT_HEAD \ transfer_RGB888_to_YUVJ420P_YUVJ422P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P16: \ TRANSFER_YUV422P16_OUT_HEAD \ transfer_RGB888_to_YUV422P16((uint16_t *)output_y, \ (uint16_t *)output_u, \ (uint16_t *)output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P10: \ TRANSFER_YUV422P16_OUT_HEAD \ transfer_RGB888_to_YUV422P10((uint16_t *)output_y, \ (uint16_t *)output_u, \ (uint16_t *)output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVJ422P10: \ TRANSFER_YUV422P16_OUT_HEAD \ transfer_RGB888_to_YUVJ422P10((uint16_t *)output_y, \ (uint16_t *)output_u, \ (uint16_t *)output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV411P: \ TRANSFER_YUV411P_OUT_HEAD \ transfer_RGB888_to_YUV411P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV444P: \ TRANSFER_YUV444P_OUT_HEAD \ transfer_RGB888_to_YUV444P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVJ444P: \ TRANSFER_YUV444P_OUT_HEAD \ transfer_RGB888_to_YUVJ444P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV444P16: \ TRANSFER_YUV444P_OUT_HEAD \ transfer_RGB888_to_YUV444P16((uint16_t*)output_y, \ (uint16_t*)output_u, \ (uint16_t*)output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ } \ break; \ \ case BC_RGBA8888: \ switch(out_colormodel) \ { \ case BC_BGR565: \ TRANSFER_FRAME_HEAD_16 \ transfer_RGBA8888_to_BGR565((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB565: \ TRANSFER_FRAME_HEAD_16 \ transfer_RGBA8888_to_RGB565((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR888: \ TRANSFER_FRAME_HEAD \ transfer_RGBA8888_to_BGR888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB888: \ TRANSFER_FRAME_HEAD \ transfer_RGBA8888_to_RGB888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_FRAME_HEAD \ transfer_RGBA8888_to_RGBA8888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB161616: \ TRANSFER_FRAME_HEAD_16 \ transfer_RGBA8888_to_RGB161616((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA16161616: \ TRANSFER_FRAME_HEAD_16 \ transfer_RGBA8888_to_RGBA16161616((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR8888: \ TRANSFER_FRAME_HEAD \ transfer_RGBA8888_to_BGR8888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVA8888: \ TRANSFER_FRAME_HEAD \ transfer_RGBA8888_to_YUVA8888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV420P: \ TRANSFER_YUV420P_OUT_HEAD \ transfer_RGBA8888_to_YUV420P_YUV422P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVJ420P: \ TRANSFER_YUV420P_OUT_HEAD \ transfer_RGBA8888_to_YUVJ420P_YUVJ422P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422: \ TRANSFER_FRAME_HEAD \ transfer_RGBA8888_to_YUV422((output), (input), j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P: \ TRANSFER_YUV422P_OUT_HEAD \ transfer_RGBA8888_to_YUV420P_YUV422P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVJ422P: \ TRANSFER_YUV422P_OUT_HEAD \ transfer_RGBA8888_to_YUVJ420P_YUVJ422P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P16: \ TRANSFER_YUV422P16_OUT_HEAD \ transfer_RGBA8888_to_YUV422P16((uint16_t *)output_y, \ (uint16_t *)output_u, \ (uint16_t *)output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV411P: \ TRANSFER_YUV411P_OUT_HEAD \ transfer_RGBA8888_to_YUV411P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV444P: \ TRANSFER_YUV444P_OUT_HEAD \ transfer_RGBA8888_to_YUV444P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVJ444P: \ TRANSFER_YUV444P_OUT_HEAD \ transfer_RGBA8888_to_YUVJ444P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV444P16: \ TRANSFER_YUV444P_OUT_HEAD \ transfer_RGBA8888_to_YUV444P16((uint16_t*)output_y, \ (uint16_t*)output_u, \ (uint16_t*)output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ } \ break; \ \ case BC_RGB161616: \ switch(out_colormodel) \ { \ case BC_BGR565: \ TRANSFER_FRAME_HEAD_16 \ transfer_RGB161616_to_BGR565((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB565: \ TRANSFER_FRAME_HEAD_16 \ transfer_RGB161616_to_RGB565((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR888: \ TRANSFER_FRAME_HEAD \ transfer_RGB161616_to_BGR888((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR8888: \ TRANSFER_FRAME_HEAD \ transfer_RGB161616_to_BGR8888((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB888: \ TRANSFER_FRAME_HEAD \ transfer_RGB161616_to_RGB888((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_FRAME_HEAD \ transfer_RGB161616_to_RGBA8888((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVA8888: \ TRANSFER_FRAME_HEAD \ transfer_RGB161616_to_YUVA8888((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV420P: \ TRANSFER_YUV420P_OUT_HEAD \ transfer_RGB161616_to_YUV420P_YUV422P(output_y, \ output_u, \ output_v, \ (uint16_t*)(input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422: \ TRANSFER_FRAME_HEAD \ transfer_RGB161616_to_YUV422((output), (uint16_t*)(input), j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P: \ TRANSFER_YUV422P_OUT_HEAD \ transfer_RGB161616_to_YUV420P_YUV422P(output_y, \ output_u, \ output_v, \ (uint16_t*)(input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P16: \ TRANSFER_YUV422P16_OUT_HEAD_16 \ transfer_RGB161616_to_YUV422P16(output_y, \ output_u, \ output_v, \ (uint16_t*)(input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P10: \ TRANSFER_YUV422P16_OUT_HEAD_16 \ transfer_RGB161616_to_YUV422P10(output_y, \ output_u, \ output_v, \ (uint16_t*)(input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVJ422P10: \ TRANSFER_YUV422P16_OUT_HEAD_16 \ transfer_RGB161616_to_YUVJ422P10(output_y, \ output_u, \ output_v, \ (uint16_t*)(input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV444P: \ TRANSFER_YUV444P_OUT_HEAD \ transfer_RGB161616_to_YUV444P(output_y, \ output_u, \ output_v, \ (uint16_t*)(input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV444P16: \ TRANSFER_YUV444P16_OUT_HEAD_16 \ transfer_RGB161616_to_YUV444P16(output_y, \ output_u, \ output_v, \ (uint16_t*)(input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ } \ break; \ \ case BC_RGBA16161616: \ switch(out_colormodel) \ { \ case BC_BGR565: \ TRANSFER_FRAME_HEAD_16 \ transfer_RGBA16161616_to_BGR565((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB565: \ TRANSFER_FRAME_HEAD_16 \ transfer_RGBA16161616_to_RGB565((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR888: \ TRANSFER_FRAME_HEAD \ transfer_RGBA16161616_to_BGR888((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR8888: \ TRANSFER_FRAME_HEAD \ transfer_RGBA16161616_to_BGR8888((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB888: \ TRANSFER_FRAME_HEAD \ transfer_RGBA16161616_to_RGB888((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_FRAME_HEAD \ transfer_RGBA16161616_to_RGBA8888((output), (uint16_t*)(input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV420P: \ TRANSFER_YUV420P_OUT_HEAD \ transfer_RGBA16161616_to_YUV420P_YUV422P(output_y, \ output_u, \ output_v, \ (uint16_t*)(input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P: \ TRANSFER_YUV422P_OUT_HEAD \ transfer_RGBA16161616_to_YUV420P_YUV422P(output_y, \ output_u, \ output_v, \ (uint16_t*)(input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV444P: \ TRANSFER_YUV444P_OUT_HEAD \ transfer_RGBA16161616_to_YUV444P(output_y, \ output_u, \ output_v, \ (uint16_t*)(input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ } \ break; \ \ case BC_BGR8888: \ switch(out_colormodel) \ { \ case BC_RGB888: \ TRANSFER_FRAME_HEAD \ transfer_BGR8888_to_RGB888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_FRAME_HEAD \ transfer_BGR8888_to_RGBA8888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR8888: \ TRANSFER_FRAME_HEAD \ transfer_BGR8888_to_BGR8888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV420P: \ TRANSFER_YUV420P_OUT_HEAD \ transfer_BGR888_to_YUV420P_YUV422P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ } \ break; \ \ case BC_BGR888: \ switch(out_colormodel) \ { \ case BC_RGB888: \ TRANSFER_FRAME_HEAD \ transfer_BGR888_to_RGB888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR565: \ TRANSFER_FRAME_HEAD_16 \ transfer_BGR888_to_BGR565((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB565: \ TRANSFER_FRAME_HEAD_16 \ transfer_BGR888_to_RGB565((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR888: \ TRANSFER_FRAME_HEAD \ transfer_BGR888_to_BGR888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_FRAME_HEAD \ transfer_BGR888_to_RGBA8888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB161616: \ TRANSFER_FRAME_HEAD_16 \ transfer_BGR888_to_RGB161616((uint16_t**)(output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA16161616: \ TRANSFER_FRAME_HEAD_16 \ transfer_BGR888_to_RGBA16161616((uint16_t**)(output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR8888: \ TRANSFER_FRAME_HEAD \ transfer_BGR888_to_BGR8888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVA8888: \ TRANSFER_FRAME_HEAD \ transfer_BGR888_to_YUVA8888((output), (input)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV420P: \ TRANSFER_YUV420P_OUT_HEAD \ transfer_BGR888_to_YUV420P_YUV422P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422: \ TRANSFER_FRAME_HEAD \ transfer_BGR888_to_YUV422((output), (input), j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P: \ TRANSFER_YUV422P_OUT_HEAD \ transfer_BGR888_to_YUV420P_YUV422P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV444P: \ TRANSFER_YUV444P_OUT_HEAD \ transfer_BGR888_to_YUV444P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ } \ break; \ } \ } void cmodel_default(PERMUTATION_ARGS) { if(scale) { TRANSFER_FRAME_DEFAULT(&output_row, input_row + column_table[j] * in_pixelsize, 0, 0, 0, 0); } else { TRANSFER_FRAME_DEFAULT(&output_row, input_row + j * in_pixelsize, 0, 0, 0, 0); } } libquicktime-1.2.4/src/colormodels.c0000644000175000017500000001634511670173743014420 00000000000000/******************************************************************************* colormodels.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include int cmodel_is_planar(int colormodel) { switch(colormodel) { case BC_YUV420P: return 1; break; case BC_YUV422P: return 1; break; case BC_YUV444P: return 1; break; case BC_YUV422P16: return 1; break; case BC_YUV444P16: return 1; break; case BC_YUVJ420P: return 1; break; case BC_YUVJ422P: return 1; break; case BC_YUVJ444P: return 1; break; case BC_YUV411P: return 1; break; case BC_YUV422P10: return 1; break; case BC_YUVJ422P10: return 1; break; } return 0; } int cmodel_calculate_pixelsize(int colormodel) { switch(colormodel) { case BC_COMPRESSED: return 1; break; case BC_RGB565: return 2; break; case BC_BGR565: return 2; break; case BC_BGR888: return 3; break; case BC_BGR8888: return 4; break; // Working bitmaps are packed to simplify processing case BC_RGB888: return 3; break; case BC_RGBA8888: return 4; break; case BC_RGB161616: return 6; break; case BC_RGBA16161616: return 8; break; case BC_YUVA8888: return 4; break; // Planar case BC_YUV420P: return 1; break; case BC_YUV422P: return 1; break; case BC_YUV444P: return 1; break; case BC_YUVJ420P: return 1; break; case BC_YUVJ422P: return 1; break; case BC_YUVJ444P: return 1; break; case BC_YUV422P16: return 2; break; case BC_YUV444P16: return 2; break; case BC_YUV422: return 2; break; case BC_YUV411P: return 1; break; case BC_YUV422P10: return 2; break; case BC_YUVJ422P10: return 2; break; } return 0; } static void get_scale_tables(int **column_table, int **row_table, int in_x1, int in_y1, int in_x2, int in_y2, int out_x1, int out_y1, int out_x2, int out_y2) { int i; float w_in = in_x2 - in_x1; float h_in = in_y2 - in_y1; int w_out = out_x2 - out_x1; int h_out = out_y2 - out_y1; float hscale = w_in / w_out; float vscale = h_in / h_out; (*column_table) = malloc(sizeof(int) * w_out); (*row_table) = malloc(sizeof(int) * h_out); for(i = 0; i < w_out; i++) { (*column_table)[i] = (int)(hscale * i) + in_x1; } for(i = 0; i < h_out; i++) { (*row_table)[i] = (int)(vscale * i) + in_y1; } } void cmodel_transfer(unsigned char **output_rows, unsigned char **input_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, int in_colormodel, int out_colormodel, int in_rowspan, int out_rowspan, int in_rowspan_uv, int out_rowspan_uv) { int *column_table; int *row_table; int scale; int in_pixelsize = cmodel_calculate_pixelsize(in_colormodel); int out_pixelsize = cmodel_calculate_pixelsize(out_colormodel); // Get scaling scale = (out_w != in_w) || (in_x != 0); get_scale_tables(&column_table, &row_table, in_x, in_y, in_x + in_w, in_y + in_h, 0, 0, out_w, out_h); // Handle planar cmodels separately switch(in_colormodel) { case BC_YUV420P: case BC_YUV422P: case BC_YUV422P16: case BC_YUVJ420P: case BC_YUVJ422P: case BC_YUV422P10: case BC_YUVJ422P10: cmodel_yuv420p(output_rows, \ input_rows, \ in_x, \ in_y, \ in_w, \ in_h, \ out_w, \ out_h, \ in_colormodel, \ out_colormodel, \ in_rowspan, \ out_rowspan, \ in_rowspan_uv, \ out_rowspan_uv, \ scale, \ out_pixelsize, \ in_pixelsize, \ row_table, \ column_table); \ break; \ case BC_YUV411P: cmodel_yuv411p(output_rows, \ input_rows, \ in_x, \ in_y, \ in_w, \ in_h, \ out_w, \ out_h, \ in_colormodel, \ out_colormodel, \ in_rowspan, \ out_rowspan, \ in_rowspan_uv, \ out_rowspan_uv, \ scale, \ out_pixelsize, \ in_pixelsize, \ row_table, \ column_table); \ break; \ case BC_YUV444P: case BC_YUV444P16: case BC_YUVJ444P: cmodel_yuv444p(output_rows, \ input_rows, \ in_x, \ in_y, \ in_w, \ in_h, \ out_w, \ out_h, \ in_colormodel, \ out_colormodel, \ in_rowspan, \ out_rowspan, \ in_rowspan_uv, \ out_rowspan_uv, \ scale, \ out_pixelsize, \ in_pixelsize, \ row_table, \ column_table); \ break; case BC_YUV422: cmodel_yuv422(output_rows, \ input_rows, \ in_x, \ in_y, \ in_w, \ in_h, \ out_w, \ out_h, \ in_colormodel, \ out_colormodel, \ in_rowspan, \ out_rowspan, \ in_rowspan_uv, \ out_rowspan_uv, \ scale, \ out_pixelsize, \ in_pixelsize, \ row_table, \ column_table); break; default: cmodel_default(output_rows, \ input_rows, \ in_x, \ in_y, \ in_w, \ in_h, \ out_w, \ out_h, \ in_colormodel, \ out_colormodel, \ in_rowspan, \ out_rowspan, \ in_rowspan_uv, \ out_rowspan_uv, \ scale, \ out_pixelsize, \ in_pixelsize, \ row_table, \ column_table); break; } free(column_table); free(row_table); } int cmodel_bc_to_x(int color_model) { switch(color_model) { case BC_YUV420P: return FOURCC_YV12; break; case BC_YUV422: return FOURCC_YUV2; break; } return -1; } int cmodel_is_yuv(int colormodel) { switch(colormodel) { case BC_YUVA8888: case BC_YUV422: case BC_YUVJ422P: case BC_YUV420P: case BC_YUV422P: case BC_YUV444P: case BC_YUV411P: case BC_YUV422P16: case BC_YUV444P16: case BC_YUV422P10: case BC_YUVJ422P10: return 1; break; default: return 0; break; } } libquicktime-1.2.4/src/avi_hdrl.c0000644000175000017500000001106711511622756013657 00000000000000/******************************************************************************* avi_hdrl.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" void quicktime_delete_hdrl(quicktime_t *file, quicktime_hdrl_t *hdrl) { int i; for(i = 0; i < file->moov.total_tracks; i++) { if(hdrl->strl[i]) quicktime_delete_strl(hdrl->strl[i]); } } void quicktime_read_hdrl(quicktime_t *file, quicktime_hdrl_t *hdrl, quicktime_atom_t *parent_atom) { quicktime_atom_t leaf_atom; uint8_t data[4]; int current_track = 0; do { quicktime_atom_read_header(file, &leaf_atom); if(quicktime_atom_is(&leaf_atom, "avih")) { quicktime_read_avih(file, &hdrl->avih, &leaf_atom); } /* Got LIST */ else if(quicktime_atom_is(&leaf_atom, "LIST")) { data[0] = data[1] = data[2] = data[3] = 0; quicktime_read_data(file, data, 4); /* Got strl */ if(quicktime_match_32(data, "strl")) { quicktime_strl_t *strl = hdrl->strl[current_track++] = quicktime_new_strl(); quicktime_read_strl(file, strl, &leaf_atom); quicktime_strl_2_qt(file, strl); } } quicktime_atom_skip(file, &leaf_atom); }while(quicktime_position(file) < parent_atom->end); quicktime_atom_skip(file, &leaf_atom); } void quicktime_init_hdrl(quicktime_t *file, quicktime_hdrl_t *hdrl) { int i; int current_track; // LIST 'hdrl' quicktime_atom_write_header(file, &hdrl->atom, "LIST"); quicktime_write_char32(file, "hdrl"); // avih hdrl->avih_offset = quicktime_position(file); quicktime_avih_init(&hdrl->avih, file); quicktime_write_avih(file, &hdrl->avih); /* Write stream lists. */ /* Need the track maps to get the WAV ID for audio. */ current_track = 0; for(i = 0; i < file->total_vtracks; i++) { quicktime_video_map_t *video_map = &file->vtracks[i]; quicktime_trak_t *trak = video_map->track; quicktime_strl_t *strl = hdrl->strl[current_track++] = quicktime_new_strl(); trak->tkhd.track_id = current_track; quicktime_init_strl(file, 0, video_map, trak, strl); } for(i = 0; i < file->total_atracks; i++) { quicktime_audio_map_t *audio_map = &file->atracks[i]; quicktime_trak_t *trak = audio_map->track; quicktime_strl_t *strl = hdrl->strl[current_track++] = quicktime_new_strl(); trak->tkhd.track_id = current_track; quicktime_init_strl(file, audio_map, 0, trak, strl); } /* ODML header */ quicktime_init_odml(file, hdrl); quicktime_atom_write_footer(file, &hdrl->atom); } void quicktime_finalize_hdrl(quicktime_t *file, quicktime_hdrl_t *hdrl) { int i; int64_t position = quicktime_position(file); double frame_rate = 0; int64_t total_frames; for(i = 0; i < file->moov.total_tracks; i++) { quicktime_trak_t *trak = file->moov.trak[i]; if(trak->strl) quicktime_finalize_strl(file, trak, trak->strl); } if(file->total_vtracks) { total_frames = quicktime_video_length(file, 0); frame_rate = quicktime_frame_rate(file, 0); // hdrl->avih.dwMaxBytesPerSec = file->total_length / (total_frames / frame_rate); hdrl->avih.dwTotalFrames = total_frames; quicktime_set_position(file, hdrl->avih_offset); quicktime_write_avih(file, &hdrl->avih); } quicktime_set_position(file, position); } libquicktime-1.2.4/src/log.c0000644000175000017500000000632411511622756012650 00000000000000/******************************************************************************* log.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include #include #include static struct { lqt_log_level_t level; const char * name; } level_names[] = { { LQT_LOG_DEBUG, "Debug" }, { LQT_LOG_WARNING, "Warning" }, { LQT_LOG_ERROR, "Error" }, { LQT_LOG_INFO, "Info" }, { 0, (char*)0 } }; static const char * log_level_to_string(lqt_log_level_t level) { int index = 0; while(level_names[index].name) { if(level_names[index].level == level) return level_names[index].name; index++; } return (char*)0; } static lqt_log_callback_t log_callback; static void * log_data; static int log_mask = LQT_LOG_ERROR | LQT_LOG_WARNING; void lqt_set_log_callback(lqt_log_callback_t cb, void * data) { log_callback = cb; log_data = data; } void lqt_logs(quicktime_t * file, lqt_log_level_t level, const char * domain, const char * msg_string) { if(!file || !file->log_callback) { if(log_callback) log_callback(level, domain, msg_string, log_data); else fprintf(stderr, "[%s] %s: %s\n", domain, log_level_to_string(level), msg_string); } else { file->log_callback(level, domain, msg_string, file->log_data); } } void lqt_log(quicktime_t * file, lqt_log_level_t level, const char * domain, const char * format, ...) { char * msg_string; char * format_tr; va_list argp; /* arg ptr */ #ifndef HAVE_VASPRINTF int len; #endif if((!file || !file->log_callback) && !log_callback && !(level & log_mask)) return; lqt_translation_init(); va_start( argp, format); format_tr = dgettext(PACKAGE, format); #ifndef HAVE_VASPRINTF len = vsnprintf((char*)0, 0, format_tr, argp); msg_string = malloc(len+1); vsnprintf(msg_string, len+1, format_tr, argp); #else vasprintf(&msg_string, format_tr, argp); #endif va_end(argp); lqt_logs(file, level, domain, msg_string); free(msg_string); } void lqt_dump(const char * format, ...) { va_list argp; /* arg ptr */ va_start( argp, format); vfprintf(stdout, format, argp); va_end(argp); } libquicktime-1.2.4/src/minf.c0000644000175000017500000002065711511622757013026 00000000000000/******************************************************************************* minf.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" void quicktime_minf_init(quicktime_minf_t *minf) { minf->is_video = minf->is_audio = 0; minf->is_panorama = 0; minf->is_qtvr = 0; minf->is_object = 0; quicktime_vmhd_init(&minf->vmhd); quicktime_smhd_init(&minf->smhd); quicktime_hdlr_init(&minf->hdlr); quicktime_dinf_init(&minf->dinf); quicktime_stbl_init(&minf->stbl); } void quicktime_minf_init_qtvr(quicktime_t *file, quicktime_minf_t *minf, int track_type, int frame_duration) { minf->is_qtvr = track_type; quicktime_stbl_init_qtvr(file, &minf->stbl, track_type, frame_duration); quicktime_hdlr_init_data(&minf->hdlr); minf->has_hdlr = 1; quicktime_dinf_init_all(&minf->dinf, file->file_type); quicktime_gmhd_init(&minf->gmhd); minf->has_gmhd = 1; } void quicktime_minf_init_panorama(quicktime_t *file, quicktime_minf_t *minf, int width, int height, int frame_duration) { minf->is_panorama = 1; quicktime_stbl_init_panorama(file, &minf->stbl, width, height, frame_duration); quicktime_hdlr_init_data(&minf->hdlr); minf->has_hdlr = 1; quicktime_dinf_init_all(&minf->dinf, file->file_type); quicktime_gmhd_init(&minf->gmhd); minf->has_gmhd = 1; } void quicktime_minf_init_video(quicktime_t *file, quicktime_minf_t *minf, int frame_w, int frame_h, int frame_duration, int time_scale, char *compressor) { minf->is_video = 1; quicktime_vmhd_init_video(file, &minf->vmhd, frame_w, frame_h, frame_duration, time_scale); quicktime_stbl_init_video(file, &minf->stbl, frame_w, frame_h, frame_duration, time_scale, compressor); if(!IS_MP4(file->file_type)) { quicktime_hdlr_init_data(&minf->hdlr); minf->has_hdlr = 1; } quicktime_dinf_init_all(&minf->dinf, file->file_type); } void quicktime_minf_init_audio(quicktime_t *file, quicktime_minf_t *minf, int channels, int sample_rate, int bits, char *compressor) { minf->is_audio = 1; /* smhd doesn't store anything worth initializing */ quicktime_stbl_init_audio(file, &minf->stbl, channels, sample_rate, bits, compressor); if(!IS_MP4(file->file_type)) { quicktime_hdlr_init_data(&minf->hdlr); minf->has_hdlr = 1; } quicktime_dinf_init_all(&minf->dinf, file->file_type); } void quicktime_minf_init_text(quicktime_t *file, quicktime_minf_t *minf) { minf->is_text = 1; quicktime_hdlr_init_data(&minf->hdlr); minf->has_hdlr = 1; quicktime_dinf_init_all(&minf->dinf, file->file_type); quicktime_stbl_init_text(file, &minf->stbl); quicktime_gmhd_init(&minf->gmhd); minf->has_gmhd = 1; quicktime_gmhd_text_init(&minf->gmhd.gmhd_text); minf->gmhd.has_gmhd_text = 1; } void quicktime_minf_init_tx3g(quicktime_t *file, quicktime_minf_t *minf) { minf->is_text = 1; quicktime_dinf_init_all(&minf->dinf, file->file_type); minf->dinf.dref.table[0].type[0] = 'u'; minf->dinf.dref.table[0].type[1] = 'r'; minf->dinf.dref.table[0].type[2] = 'l'; minf->dinf.dref.table[0].type[3] = ' '; quicktime_stbl_init_tx3g(file, &minf->stbl); quicktime_nmhd_init(&minf->nmhd); minf->has_nmhd = 1; } void quicktime_minf_init_timecode(quicktime_t *file, quicktime_minf_t *minf, int time_scale, int frame_duration, int num_frames, uint32_t flags) { minf->is_timecode = 1; minf->has_gmhd = 1; quicktime_gmhd_init_timecode(&minf->gmhd); quicktime_stbl_init_timecode(file, &minf->stbl, time_scale, frame_duration, num_frames, flags); quicktime_hdlr_init_data(&minf->hdlr); quicktime_dinf_init_all(&minf->dinf, file->file_type); } void quicktime_minf_delete(quicktime_minf_t *minf) { quicktime_vmhd_delete(&minf->vmhd); quicktime_smhd_delete(&minf->smhd); quicktime_gmhd_delete(&minf->gmhd); quicktime_dinf_delete(&minf->dinf); quicktime_stbl_delete(&minf->stbl); quicktime_hdlr_delete(&minf->hdlr); } void quicktime_minf_dump(quicktime_minf_t *minf) { lqt_dump(" media info (minf)\n"); lqt_dump(" is_audio %d\n", minf->is_audio); lqt_dump(" is_audio_vbr %d\n", minf->is_audio_vbr); lqt_dump(" is_video %d\n", minf->is_video); lqt_dump(" is_text %d\n", minf->is_text); lqt_dump(" is_timecode %d\n", minf->is_timecode); if(minf->is_audio) quicktime_smhd_dump(&minf->smhd); if(minf->is_video) quicktime_vmhd_dump(&minf->vmhd); if(minf->has_gmhd) quicktime_gmhd_dump(&minf->gmhd); if(minf->has_nmhd) quicktime_nmhd_dump(&minf->nmhd); if(minf->has_hdlr) quicktime_hdlr_dump(&minf->hdlr); quicktime_dinf_dump(&minf->dinf); quicktime_stbl_dump(minf, &minf->stbl); } int quicktime_read_minf(quicktime_t *file, quicktime_trak_t *trak, quicktime_minf_t *minf, quicktime_atom_t *parent_atom) { quicktime_atom_t leaf_atom; do { quicktime_atom_read_header(file, &leaf_atom); /* mandatory */ if(quicktime_atom_is(&leaf_atom, "vmhd")) { minf->is_video = 1; quicktime_read_vmhd(file, &minf->vmhd); } else if(quicktime_atom_is(&leaf_atom, "smhd")) { minf->is_audio = 1; quicktime_read_smhd(file, &minf->smhd); } else if(quicktime_atom_is(&leaf_atom, "gmhd")) { minf->has_gmhd = 1; quicktime_read_gmhd(file, &minf->gmhd, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "nmhd")) { minf->has_nmhd = 1; quicktime_read_nmhd(file, &minf->nmhd); } else if(quicktime_atom_is(&leaf_atom, "hdlr")) { quicktime_read_hdlr(file, &minf->hdlr, &leaf_atom); minf->has_hdlr = 1; } else if(quicktime_atom_is(&leaf_atom, "dinf")) { quicktime_read_dinf(file, &minf->dinf, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "stbl")) { quicktime_read_stbl(file, minf, &minf->stbl, &leaf_atom); } else quicktime_atom_skip(file, &leaf_atom); }while(quicktime_position(file) < parent_atom->end); /* Finalize stsd */ quicktime_finalize_stsd(file, trak, &minf->stbl.stsd); if(minf->is_audio && (minf->stbl.stsd.table[0].compression_id == -2)) minf->is_audio_vbr = 1; return 0; } void quicktime_write_minf(quicktime_t *file, quicktime_minf_t *minf) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "minf"); if(minf->is_video) quicktime_write_vmhd(file, &minf->vmhd); else if(minf->is_audio) quicktime_write_smhd(file, &minf->smhd); else if(minf->has_gmhd) quicktime_write_gmhd(file, &minf->gmhd); else if(minf->has_nmhd) quicktime_write_nmhd(file, &minf->nmhd); if(minf->has_hdlr) quicktime_write_hdlr(file, &minf->hdlr); quicktime_write_dinf(file, &minf->dinf); quicktime_write_stbl(file, minf, &minf->stbl); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/moov.c0000644000175000017500000002444711511622757013056 00000000000000/******************************************************************************* moov.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include #include #define LOG_DOMAIN "moov" int quicktime_moov_init(quicktime_moov_t *moov) { int i; moov->total_tracks = 0; for(i = 0 ; i < MAXTRACKS; i++) moov->trak[i] = 0; quicktime_mvhd_init(&moov->mvhd); quicktime_udta_init(&moov->udta); quicktime_ctab_init(&moov->ctab); quicktime_iods_init(&moov->iods); return 0; } int quicktime_moov_delete(quicktime_moov_t *moov) { while(moov->total_tracks) quicktime_delete_trak(moov); quicktime_mvhd_delete(&moov->mvhd); quicktime_udta_delete(&moov->udta); quicktime_ctab_delete(&moov->ctab); quicktime_iods_delete(&moov->iods); return 0; } void quicktime_moov_dump(quicktime_moov_t *moov) { int i; lqt_dump("movie (moov)\n"); quicktime_mvhd_dump(&moov->mvhd); quicktime_udta_dump(&moov->udta); if(moov->has_iods) quicktime_iods_dump(&moov->iods); for(i = 0; i < moov->total_tracks; i++) quicktime_trak_dump(moov->trak[i]); if(moov->has_ctab) quicktime_ctab_dump(&moov->ctab); } static void* zalloc(void *opaque, unsigned int items, unsigned int size) { return calloc(items, size); } static void zfree(void *opaque, void *ptr) { free(ptr); } static int read_cmov(quicktime_t *file, quicktime_atom_t *parent_atom, quicktime_atom_t *moov_atom) { int64_t old_preload_size; uint8_t *old_preload_buffer; int64_t old_preload_start; int64_t old_preload_end; int64_t old_preload_ptr; quicktime_atom_t leaf_atom; unsigned char *data_in, *data_out; z_stream zlib; do { quicktime_atom_read_header(file, &leaf_atom); /* Algorithm used to compress */ if(quicktime_atom_is(&leaf_atom, "dcom")) { char data[5]; quicktime_read_data(file, (uint8_t*)data, 4); data[4] = 0; if(strcmp(data, "zlib")) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "read_cmov: compression '%c%c%c%c' not zlib.", data[0], data[1], data[2], data[3]); return 1; } quicktime_atom_skip(file, &leaf_atom); } else /* Size of uncompressed data followed by compressed data */ if(quicktime_atom_is(&leaf_atom, "cmvd")) { /* Size of uncompressed data */ int uncompressed_size = quicktime_read_int32(file); /* Read compressed data */ int compressed_size = leaf_atom.end - quicktime_position(file); data_in = calloc(1, compressed_size); quicktime_read_data(file, data_in, compressed_size); /* Decompress to another buffer */ data_out = calloc(1, uncompressed_size + 0x400); zlib.zalloc = zalloc; zlib.zfree = zfree; zlib.opaque = NULL; zlib.avail_out = uncompressed_size + 0x400; zlib.next_out = data_out; zlib.avail_in = compressed_size; zlib.next_in = data_in; inflateInit(&zlib); inflate(&zlib, Z_PARTIAL_FLUSH); inflateEnd(&zlib); free(data_in); file->moov_data = data_out; /* * FILE *test = fopen("/tmp/test", "w"); * fwrite(data_out, uncompressed_size, 1, test); * fclose(test); * exit(0); */ /* Trick library into reading temporary buffer for the moov */ file->moov_end = moov_atom->end; file->moov_size = moov_atom->size; moov_atom->end = moov_atom->start + uncompressed_size; moov_atom->size = uncompressed_size; old_preload_size = file->preload_size; old_preload_buffer = file->preload_buffer; old_preload_start = file->preload_start; old_preload_end = file->preload_end; old_preload_ptr = file->preload_ptr; file->preload_size = uncompressed_size; file->preload_buffer = data_out; file->preload_start = moov_atom->start; file->preload_end = file->preload_start + uncompressed_size; file->preload_ptr = 0; quicktime_set_position(file, file->preload_start + 8); /* Try again */ if(quicktime_read_moov(file, &file->moov, moov_atom)) return 1; /* Exit the compressed state */ moov_atom->size = file->moov_size; moov_atom->end = file->moov_end; file->preload_size = old_preload_size; file->preload_buffer = old_preload_buffer; file->preload_start = old_preload_start; file->preload_end = old_preload_end; file->preload_ptr = old_preload_ptr; quicktime_set_position(file, moov_atom->end); } else quicktime_atom_skip(file, &leaf_atom); }while(quicktime_position(file) < parent_atom->end); return 0; } int quicktime_read_moov(quicktime_t *file, quicktime_moov_t *moov, quicktime_atom_t *parent_atom) { /* mandatory mvhd */ quicktime_atom_t leaf_atom; /* AVI translation: */ /* strh -> mvhd */ do { quicktime_atom_read_header(file, &leaf_atom); if(quicktime_atom_is(&leaf_atom, "cmov")) { file->compressed_moov = 1; if(read_cmov(file, &leaf_atom, parent_atom)) return 1; /* Now were reading the compressed moov atom from the beginning. */ } else if(quicktime_atom_is(&leaf_atom, "mvhd")) { quicktime_read_mvhd(file, &moov->mvhd, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "clip")) { quicktime_atom_skip(file, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "trak")) { quicktime_trak_t *trak = quicktime_add_trak(file); quicktime_read_trak(file, trak, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "udta")) { quicktime_read_udta(file, &moov->udta, &leaf_atom); quicktime_atom_skip(file, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "ctab")) { quicktime_read_ctab(file, &moov->ctab); moov->has_ctab = 1; } else if(quicktime_atom_is(&leaf_atom, "iods")) { quicktime_read_iods(file, &moov->iods); quicktime_atom_skip(file, &leaf_atom); moov->has_iods = 1; } else quicktime_atom_skip(file, &leaf_atom); }while(quicktime_position(file) < parent_atom->end); return 0; } void quicktime_finalize_moov(quicktime_t *file, quicktime_moov_t *moov) { int i; int64_t longest_duration = 0; int64_t duration; int timescale; /* get the duration from the longest track in the mvhd's timescale */ for(i = 0; i < moov->total_tracks; i++) { quicktime_trak_fix_counts(file, moov->trak[i], moov->mvhd.time_scale); quicktime_trak_duration(moov->trak[i], &duration, ×cale); duration = (long)((double)duration / timescale * moov->mvhd.time_scale + 0.5); if(duration > longest_duration) { longest_duration = duration; } /* Add tracks to iods */ quicktime_iods_add_track(&moov->iods, moov->trak[i]); } moov->mvhd.duration = longest_duration; if(!IS_MP4(file->file_type)) moov->mvhd.selection_duration = longest_duration; } void quicktime_write_moov(quicktime_t *file, quicktime_moov_t *moov) { quicktime_atom_t atom; int result, i; // Try moov header immediately file->mdat.atom.end = quicktime_position(file); result = quicktime_atom_write_header(file, &atom, "moov"); // Disk full. Rewind and try again if(result) { quicktime_set_position(file, file->mdat.atom.end - (int64_t)0x100000); file->mdat.atom.end = quicktime_position(file); quicktime_atom_write_header(file, &atom, "moov"); } quicktime_write_mvhd(file, &moov->mvhd); if(moov->has_iods) quicktime_write_iods(file, moov); for(i = 0; i < moov->total_tracks; i++) { quicktime_write_trak(file, moov->trak[i]); } quicktime_write_udta(file, &moov->udta); /*quicktime_write_ctab(file, &moov->ctab); */ quicktime_atom_write_footer(file, &atom); } void quicktime_update_durations(quicktime_moov_t *moov) { } int quicktime_shift_offsets(quicktime_moov_t *moov, int64_t offset) { int i; for(i = 0; i < moov->total_tracks; i++) { quicktime_trak_shift_offsets(moov->trak[i], offset); } return 0; } libquicktime-1.2.4/src/stbl.c0000644000175000017500000001720011511622757013027 00000000000000/******************************************************************************* stbl.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" void quicktime_stbl_init(quicktime_stbl_t *stbl) { stbl->version = 0; stbl->flags = 0; quicktime_stsd_init(&stbl->stsd); quicktime_stts_init(&stbl->stts); quicktime_stss_init(&stbl->stss); quicktime_stsc_init(&stbl->stsc); quicktime_stsz_init(&stbl->stsz); quicktime_stco_init(&stbl->stco); } void quicktime_stbl_init_qtvr(quicktime_t *file, quicktime_stbl_t *stbl, int track_type, int frame_duration) { quicktime_stsd_init_qtvr(file, &stbl->stsd, track_type); quicktime_stts_init_video(file, &stbl->stts, frame_duration); quicktime_stsc_init_video(file, &stbl->stsc); quicktime_stsz_init_video(file, &stbl->stsz); quicktime_stco_init_common(file, &stbl->stco); } void quicktime_stbl_init_panorama(quicktime_t *file, quicktime_stbl_t *stbl, int width, int height, int frame_duration) { quicktime_stsd_init_panorama(file, &stbl->stsd, width, height); quicktime_stts_init_video(file, &stbl->stts, frame_duration); quicktime_stsc_init_video(file, &stbl->stsc); quicktime_stsz_init_video(file, &stbl->stsz); quicktime_stco_init_common(file, &stbl->stco); } void quicktime_stbl_init_video(quicktime_t *file, quicktime_stbl_t *stbl, int frame_w, int frame_h, int frame_duration, int time_scale, char *compressor) { quicktime_stsd_init_video(file, &stbl->stsd, frame_w, frame_h, compressor); quicktime_stts_init_video(file, &stbl->stts, frame_duration); quicktime_stsc_init_video(file, &stbl->stsc); quicktime_stsz_init_video(file, &stbl->stsz); quicktime_stco_init_common(file, &stbl->stco); } void quicktime_stbl_init_audio(quicktime_t *file, quicktime_stbl_t *stbl, int channels, int sample_rate, int bits, char *compressor) { quicktime_stsd_init_audio(file, &stbl->stsd, channels, sample_rate, bits, compressor); quicktime_stts_init_audio(file, &stbl->stts, sample_rate); quicktime_stsc_init_audio(file, &stbl->stsc, sample_rate); quicktime_stsz_init_audio(file, &stbl->stsz, channels, bits, compressor); quicktime_stco_init_common(file, &stbl->stco); } void quicktime_stbl_init_text(quicktime_t *file, quicktime_stbl_t *stbl) { quicktime_stco_init_common(file, &stbl->stco); quicktime_stsd_init_text(file, &stbl->stsd); /* stts doesn't need to be updated */ } void quicktime_stbl_init_tx3g(quicktime_t *file, quicktime_stbl_t *stbl) { quicktime_stco_init_common(file, &stbl->stco); quicktime_stsd_init_tx3g(file, &stbl->stsd); /* stts doesn't need to be updated */ } void quicktime_stbl_init_timecode(quicktime_t *file, quicktime_stbl_t *stbl, int time_scale, int frame_duration, int num_frames, uint32_t flags) { quicktime_stsd_init_timecode(file, &stbl->stsd, time_scale, frame_duration, num_frames, flags); quicktime_stts_init_timecode(file, &stbl->stts); quicktime_stsc_init_video(file, &stbl->stsc); quicktime_stsz_init_timecode(&stbl->stsz); quicktime_stco_init_common(file, &stbl->stco); } void quicktime_stbl_delete(quicktime_stbl_t *stbl) { quicktime_stsd_delete(&stbl->stsd); quicktime_stts_delete(&stbl->stts); quicktime_stss_delete(&stbl->stss); quicktime_stsc_delete(&stbl->stsc); quicktime_stsz_delete(&stbl->stsz); quicktime_stco_delete(&stbl->stco); } void quicktime_stbl_dump(void *minf_ptr, quicktime_stbl_t *stbl) { lqt_dump(" sample table\n"); quicktime_stsd_dump(minf_ptr, &stbl->stsd); quicktime_stts_dump(&stbl->stts); if(stbl->stss.total_entries) quicktime_stss_dump(&stbl->stss); quicktime_stsc_dump(&stbl->stsc); quicktime_stsz_dump(&stbl->stsz); quicktime_stco_dump(&stbl->stco); if(stbl->has_ctts) quicktime_ctts_dump(&stbl->ctts); } int quicktime_read_stbl(quicktime_t *file, quicktime_minf_t *minf, quicktime_stbl_t *stbl, quicktime_atom_t *parent_atom) { quicktime_atom_t leaf_atom; do { quicktime_atom_read_header(file, &leaf_atom); /* mandatory */ if(quicktime_atom_is(&leaf_atom, "stsd")) { quicktime_read_stsd(file, &stbl->stsd); /* Some codecs store extra information at the end of this */ quicktime_atom_skip(file, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "stts")) { quicktime_read_stts(file, &stbl->stts); quicktime_atom_skip(file, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "ctts")) { quicktime_read_ctts(file, &stbl->ctts); quicktime_atom_skip(file, &leaf_atom); stbl->has_ctts = 1; } else if(quicktime_atom_is(&leaf_atom, "stss")) { quicktime_read_stss(file, &stbl->stss); quicktime_atom_skip(file, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "stsc")) { quicktime_read_stsc(file, &stbl->stsc); quicktime_atom_skip(file, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "stsz")) { quicktime_read_stsz(file, &stbl->stsz); quicktime_atom_skip(file, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "co64")) { quicktime_read_stco64(file, &stbl->stco); quicktime_atom_skip(file, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "stco")) { quicktime_read_stco(file, &stbl->stco); quicktime_atom_skip(file, &leaf_atom); } else quicktime_atom_skip(file, &leaf_atom); }while(quicktime_position(file) < parent_atom->end); return 0; } void quicktime_write_stbl(quicktime_t *file, quicktime_minf_t *minf, quicktime_stbl_t *stbl) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "stbl"); quicktime_write_stsd(file, minf, &stbl->stsd); quicktime_write_stts(file, &stbl->stts); quicktime_write_stss(file, &stbl->stss); quicktime_write_stsc(file, &stbl->stsc); quicktime_write_stsz(file, &stbl->stsz); quicktime_write_stco(file, &stbl->stco); if(stbl->has_ctts) quicktime_write_ctts(file, &stbl->ctts); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/iods.c0000644000175000017500000003003611511622756013022 00000000000000/******************************************************************************* iods.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include static const char * get_video_profile_name(uint8_t video_pl) { switch (video_pl) { case 0x00: return "Reserved (0x00) Profile"; case 0x01: return "Simple Profile @ Level 1"; case 0x02: return "Simple Profile @ Level 2"; case 0x03: return "Simple Profile @ Level 3"; case 0x08: return "Simple Profile @ Level 0"; case 0x10: return "Simple Scalable Profile @ Level 0"; case 0x11: return "Simple Scalable Profile @ Level 1"; case 0x12: return "Simple Scalable Profile @ Level 2"; case 0x15: return "AVC/H264 Profile"; case 0x21: return "Core Profile @ Level 1"; case 0x22: return "Core Profile @ Level 2"; case 0x32: return "Main Profile @ Level 2"; case 0x33: return "Main Profile @ Level 3"; case 0x34: return "Main Profile @ Level 4"; case 0x42: return "N-bit Profile @ Level 2"; case 0x51: return "Scalable Texture Profile @ Level 1"; case 0x61: return "Simple Face Animation Profile @ Level 1"; case 0x62: return "Simple Face Animation Profile @ Level 2"; case 0x63: return "Simple FBA Profile @ Level 1"; case 0x64: return "Simple FBA Profile @ Level 2"; case 0x71: return "Basic Animated Texture Profile @ Level 1"; case 0x72: return "Basic Animated Texture Profile @ Level 2"; case 0x81: return "Hybrid Profile @ Level 1"; case 0x82: return "Hybrid Profile @ Level 2"; case 0x91: return "Advanced Real Time Simple Profile @ Level 1"; case 0x92: return "Advanced Real Time Simple Profile @ Level 2"; case 0x93: return "Advanced Real Time Simple Profile @ Level 3"; case 0x94: return "Advanced Real Time Simple Profile @ Level 4"; case 0xA1: return "Core Scalable Profile @ Level1"; case 0xA2: return "Core Scalable Profile @ Level2"; case 0xA3: return "Core Scalable Profile @ Level3"; case 0xB1: return "Advanced Coding Efficiency Profile @ Level 1"; case 0xB2: return "Advanced Coding Efficiency Profile @ Level 2"; case 0xB3: return "Advanced Coding Efficiency Profile @ Level 3"; case 0xB4: return "Advanced Coding Efficiency Profile @ Level 4"; case 0xC1: return "Advanced Core Profile @ Level 1"; case 0xC2: return "Advanced Core Profile @ Level 2"; case 0xD1: return "Advanced Scalable Texture @ Level1"; case 0xD2: return "Advanced Scalable Texture @ Level2"; case 0xE1: return "Simple Studio Profile @ Level 1"; case 0xE2: return "Simple Studio Profile @ Level 2"; case 0xE3: return "Simple Studio Profile @ Level 3"; case 0xE4: return "Simple Studio Profile @ Level 4"; case 0xE5: return "Core Studio Profile @ Level 1"; case 0xE6: return "Core Studio Profile @ Level 2"; case 0xE7: return "Core Studio Profile @ Level 3"; case 0xE8: return "Core Studio Profile @ Level 4"; case 0xF0: return "Advanced Simple Profile @ Level 0"; case 0xF1: return "Advanced Simple Profile @ Level 1"; case 0xF2: return "Advanced Simple Profile @ Level 2"; case 0xF3: return "Advanced Simple Profile @ Level 3"; case 0xF4: return "Advanced Simple Profile @ Level 4"; case 0xF5: return "Advanced Simple Profile @ Level 5"; case 0xF7: return "Advanced Simple Profile @ Level 3b"; case 0xF8: return "Fine Granularity Scalable Profile @ Level 0"; case 0xF9: return "Fine Granularity Scalable Profile @ Level 1"; case 0xFA: return "Fine Granularity Scalable Profile @ Level 2"; case 0xFB: return "Fine Granularity Scalable Profile @ Level 3"; case 0xFC: return "Fine Granularity Scalable Profile @ Level 4"; case 0xFD: return "Fine Granularity Scalable Profile @ Level 5"; case 0xFE: return "Not part of MPEG-4 Visual profiles"; case 0xFF: return "No visual capability required"; default: return "ISO Reserved Profile"; } } static const char * get_audio_profile_name(uint8_t audio_pl) { switch (audio_pl) { case 0x00: return "ISO Reserved (0x00)"; case 0x01: return "Main Audio Profile @ Level 1"; case 0x02: return "Main Audio Profile @ Level 2"; case 0x03: return "Main Audio Profile @ Level 3"; case 0x04: return "Main Audio Profile @ Level 4"; case 0x05: return "Scalable Audio Profile @ Level 1"; case 0x06: return "Scalable Audio Profile @ Level 2"; case 0x07: return "Scalable Audio Profile @ Level 3"; case 0x08: return "Scalable Audio Profile @ Level 4"; case 0x09: return "Speech Audio Profile @ Level 1"; case 0x0A: return "Speech Audio Profile @ Level 2"; case 0x0B: return "Synthetic Audio Profile @ Level 1"; case 0x0C: return "Synthetic Audio Profile @ Level 2"; case 0x0D: return "Synthetic Audio Profile @ Level 3"; case 0x0E: return "High Quality Audio Profile @ Level 1"; case 0x0F: return "High Quality Audio Profile @ Level 2"; case 0x10: return "High Quality Audio Profile @ Level 3"; case 0x11: return "High Quality Audio Profile @ Level 4"; case 0x12: return "High Quality Audio Profile @ Level 5"; case 0x13: return "High Quality Audio Profile @ Level 6"; case 0x14: return "High Quality Audio Profile @ Level 7"; case 0x15: return "High Quality Audio Profile @ Level 8"; case 0x16: return "Low Delay Audio Profile @ Level 1"; case 0x17: return "Low Delay Audio Profile @ Level 2"; case 0x18: return "Low Delay Audio Profile @ Level 3"; case 0x19: return "Low Delay Audio Profile @ Level 4"; case 0x1A: return "Low Delay Audio Profile @ Level 5"; case 0x1B: return "Low Delay Audio Profile @ Level 6"; case 0x1C: return "Low Delay Audio Profile @ Level 7"; case 0x1D: return "Low Delay Audio Profile @ Level 8"; case 0x1E: return "Natural Audio Profile @ Level 1"; case 0x1F: return "Natural Audio Profile @ Level 2"; case 0x20: return "Natural Audio Profile @ Level 3"; case 0x21: return "Natural Audio Profile @ Level 4"; case 0x22: return "Mobile Audio Internetworking Profile @ Level 1"; case 0x23: return "Mobile Audio Internetworking Profile @ Level 2"; case 0x24: return "Mobile Audio Internetworking Profile @ Level 3"; case 0x25: return "Mobile Audio Internetworking Profile @ Level 4"; case 0x26: return "Mobile Audio Internetworking Profile @ Level 5"; case 0x27: return "Mobile Audio Internetworking Profile @ Level 6"; case 0x28: return "AAC Profile @ Level 1"; case 0x29: return "AAC Profile @ Level 2"; case 0x2A: return "AAC Profile @ Level 4"; case 0x2B: return "AAC Profile @ Level 5"; case 0x2C: return "High Efficiency AAC Profile @ Level 2"; case 0x2D: return "High Efficiency AAC Profile @ Level 3"; case 0x2E: return "High Efficiency AAC Profile @ Level 4"; case 0x2F: return "High Efficiency AAC Profile @ Level 5"; case 0xFE: return "Not part of MPEG-4 audio profiles"; case 0xFF: return "No audio capability required"; default: return "ISO Reserved / User Private"; } } void quicktime_iods_init(quicktime_iods_t * iods) { iods->version = 0; iods->flags = 0; iods->ObjectDescriptorID = 0x004F; iods->ODProfileLevel = 0xff; iods->sceneProfileLevel = 0xff; iods->audioProfileId = 0xff; iods->videoProfileId = 0xff; iods->graphicsProfileLevel = 0xff; } void quicktime_iods_delete(quicktime_iods_t * iods) { if(iods->tracks) free(iods->tracks); } void quicktime_iods_dump(quicktime_iods_t * iods) { int i; lqt_dump("Initial object descriptor (iods)\n"); lqt_dump(" version: %d\n", iods->version); lqt_dump(" flags: %ld\n", iods->flags); lqt_dump(" ObjectDescriptorID: %04x\n", iods->ObjectDescriptorID); lqt_dump(" ODProfileLevel: %d\n", iods->ODProfileLevel); lqt_dump(" sceneProfileLevel: %d\n", iods->sceneProfileLevel); lqt_dump(" audioProfileId: %d [%s]\n", iods->audioProfileId, get_audio_profile_name(iods->audioProfileId)); lqt_dump(" videoProfileId: %d [%s]\n", iods->videoProfileId, get_video_profile_name(iods->videoProfileId)); lqt_dump(" graphicsProfileLevel: %d\n", iods->graphicsProfileLevel); for(i = 0; i < iods->num_tracks; i++) { lqt_dump(" track %d: ES_ID_IncTag: %d, length: %d, track_id: %d\n", i+1, iods->tracks[i].ES_ID_IncTag, iods->tracks[i].length, iods->tracks[i].track_id); } } void quicktime_iods_add_track(quicktime_iods_t * iods, quicktime_trak_t * trak) { iods->tracks = realloc(iods->tracks, sizeof(*iods->tracks)*(iods->num_tracks+1)); iods->tracks[iods->num_tracks].ES_ID_IncTag = 0x0e; iods->tracks[iods->num_tracks].length = 0x04; iods->tracks[iods->num_tracks].track_id = trak->tkhd.track_id; iods->num_tracks++; } void quicktime_read_iods(quicktime_t *file, quicktime_iods_t * iods) { int len, i; iods->version = quicktime_read_char(file); iods->flags = quicktime_read_int24(file); quicktime_read_char(file); /* skip tag */ len = quicktime_read_mp4_descr_length(file); /* Length */ iods->ObjectDescriptorID = quicktime_read_int16(file); iods->ODProfileLevel = quicktime_read_char(file); iods->sceneProfileLevel = quicktime_read_char(file); iods->audioProfileId = quicktime_read_char(file); iods->videoProfileId = quicktime_read_char(file); iods->graphicsProfileLevel = quicktime_read_char(file); iods->num_tracks = (len - 7)/6; iods->tracks = calloc(iods->num_tracks, sizeof(*(iods->tracks))); for(i = 0; i < iods->num_tracks; i++) { iods->tracks[i].ES_ID_IncTag = quicktime_read_char(file); iods->tracks[i].length = quicktime_read_mp4_descr_length(file); iods->tracks[i].track_id = quicktime_read_int32(file); } /* will skip the remainder of the atom */ } void quicktime_write_iods(quicktime_t *file, quicktime_moov_t * moov) { quicktime_atom_t atom; int i; quicktime_iods_t * iods = &moov->iods; quicktime_atom_write_header(file, &atom, "iods"); quicktime_write_char(file, iods->version); quicktime_write_int24(file, iods->flags); quicktime_write_char(file, 0x10); /* MP4_IOD_Tag */ quicktime_write_mp4_descr_length(file, 7 + (iods->num_tracks * (1+1+4)), 0); /* length */ quicktime_write_int16(file, 0x004F); /* ObjectDescriptorID = 1 */ quicktime_write_char(file, iods->ODProfileLevel); /* ODProfileLevel */ quicktime_write_char(file, iods->sceneProfileLevel); /* sceneProfileLevel */ quicktime_write_char(file, iods->audioProfileId); /* audioProfileLevel */ quicktime_write_char(file, iods->videoProfileId); /* videoProfileLevel */ quicktime_write_char(file, iods->graphicsProfileLevel); /* graphicsProfileLevel */ for (i = 0; i < iods->num_tracks; i++) { quicktime_write_char(file, iods->tracks[i].ES_ID_IncTag); /* ES_ID_IncTag */ quicktime_write_char(file, iods->tracks[i].length); /* length */ quicktime_write_int32(file, iods->tracks[i].track_id); } /* no OCI_Descriptors */ /* no IPMP_DescriptorPointers */ /* no Extenstion_Descriptors */ quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/useratoms.c0000644000175000017500000001645711536446251014122 00000000000000/******************************************************************************* useratoms.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include uint8_t * quicktime_user_atoms_get_atom(quicktime_user_atoms_t * u, char * name, uint32_t * len) { int i; for(i = 0; i < u->num_atoms; i++) { if((u->atoms[i][4] == name[0]) && (u->atoms[i][5] == name[1]) && (u->atoms[i][6] == name[2]) && (u->atoms[i][7] == name[3])) { *len = ((uint32_t)u->atoms[i][0] << 24) | ((uint32_t)u->atoms[i][1] << 16) | ((uint32_t)u->atoms[i][2] << 8) | u->atoms[i][3]; return u->atoms[i]; } } return (uint8_t*)0; } void quicktime_user_atoms_add_atom(quicktime_user_atoms_t * u, char * name, uint8_t * data, uint32_t len) { u->atoms = realloc(u->atoms, (u->num_atoms+1)*sizeof(*u->atoms)); u->atoms[u->num_atoms] = malloc(len+8); u->atoms[u->num_atoms][0] = ((len+8) & 0xff000000) >> 24; u->atoms[u->num_atoms][1] = ((len+8) & 0x00ff0000) >> 16; u->atoms[u->num_atoms][2] = ((len+8) & 0x0000ff00) >> 8; u->atoms[u->num_atoms][3] = ((len+8) & 0x000000ff); u->atoms[u->num_atoms][4] = name[0]; u->atoms[u->num_atoms][5] = name[1]; u->atoms[u->num_atoms][6] = name[2]; u->atoms[u->num_atoms][7] = name[3]; memcpy(u->atoms[u->num_atoms]+8, data, len); u->num_atoms++; } void quicktime_user_atoms_read_atom(quicktime_t * file, quicktime_user_atoms_t * u, quicktime_atom_t * leaf_atom) { u->atoms = realloc(u->atoms, (u->num_atoms+1)*sizeof(*u->atoms)); u->atoms[u->num_atoms] = malloc(leaf_atom->size); u->atoms[u->num_atoms][0] = ((leaf_atom->size) & 0xff000000) >> 24; u->atoms[u->num_atoms][1] = ((leaf_atom->size) & 0x00ff0000) >> 16; u->atoms[u->num_atoms][2] = ((leaf_atom->size) & 0x0000ff00) >> 8; u->atoms[u->num_atoms][3] = ((leaf_atom->size) & 0x000000ff); u->atoms[u->num_atoms][4] = leaf_atom->type[0]; u->atoms[u->num_atoms][5] = leaf_atom->type[1]; u->atoms[u->num_atoms][6] = leaf_atom->type[2]; u->atoms[u->num_atoms][7] = leaf_atom->type[3]; quicktime_read_data(file, u->atoms[u->num_atoms] + 8, leaf_atom->size - 8); u->num_atoms++; } void quicktime_user_atoms_delete(quicktime_user_atoms_t * u) { int i; if(u->atoms) { for(i = 0; i < u->num_atoms; i++) { free(u->atoms[i]); } free(u->atoms); } } static uint32_t read_be32(uint8_t const* p) { return ((uint32_t)p[0] << 24) + ((uint32_t)p[1] << 16) + ((uint32_t)p[2] << 8) + (uint32_t)p[3]; } static void quicktime_user_atoms_dump_ACLR(uint8_t const* atom, uint32_t len) { if (len >= 12) lqt_dump(" Tag: %.4s\n", atom + 8); if (len >= 16) lqt_dump(" Version: %.4s\n", atom + 12); if (len >= 20) { uint32_t yuv_range = read_be32(atom + 16); if (yuv_range == 1) lqt_dump(" YUV range: full -> [0, 255]\n"); else if (yuv_range == 2) lqt_dump(" YUV range: normal -> [16, 235] for Y, [16, 240] for U and V\n"); else lqt_dump(" YUV range: unknown (%u)\n", (unsigned)yuv_range); } if (len >= 24) lqt_dump(" Unknown: %u\n", (unsigned)read_be32(atom + 20)); if (len > 24) lqt_dump(" %u more bytes follow\n", (unsigned)(len - 24)); } static void quicktime_user_atoms_dump_APRG(uint8_t const* atom, uint32_t len) { if (len >= 12) lqt_dump(" Tag: %.4s\n", atom + 8); if (len >= 16) lqt_dump(" Version: %.4s\n", atom + 12); if (len >= 20) lqt_dump(" Unknown #1: %u\n", (unsigned)read_be32(atom + 16)); if (len >= 24) lqt_dump(" Unknown #2: %u\n", (unsigned)read_be32(atom + 20)); if (len > 24) lqt_dump(" %u more bytes follow\n", (unsigned)(len - 24)); } static void quicktime_user_atoms_dump_ARES(uint8_t const* atom, uint32_t len) { if (len >= 12) lqt_dump(" Tag: %.4s\n", atom + 8); if (len >= 16) lqt_dump(" Version: %.4s\n", atom + 12); if (len >= 20) lqt_dump(" CID: %u\n", (unsigned)read_be32(atom + 16)); if (len >= 24) lqt_dump(" Frame/field width: %u\n", (unsigned)read_be32(atom + 20)); if (len >= 28) lqt_dump(" Frame/field height: %u\n", (unsigned)read_be32(atom + 24)); if (len >= 32) lqt_dump(" Unknown #1: %u\n", (unsigned)read_be32(atom + 28)); if (len >= 36) lqt_dump(" Unknown #2: %u\n", (unsigned)read_be32(atom + 32)); if (len >= 40) lqt_dump(" Unknown #3: %u\n", (unsigned)read_be32(atom + 36)); if (len > 40) lqt_dump(" %u more bytes follow\n", (unsigned)(len - 40)); } void quicktime_user_atoms_dump(quicktime_user_atoms_t * u) { int i; uint32_t len; for(i = 0; i < u->num_atoms; i++) { len = ((uint32_t)u->atoms[i][0] << 24) | ((uint32_t)u->atoms[i][1] << 16) | ((uint32_t)u->atoms[i][2] << 8) | u->atoms[i][3]; lqt_dump(" User atom %.4s (%d bytes)\n", u->atoms[i] + 4, len); if (strncmp((char const*)u->atoms[i] + 4, "ACLR", 4) == 0) quicktime_user_atoms_dump_ACLR(u->atoms[i], len); else if (strncmp((char const*)u->atoms[i] + 4, "APRG", 4) == 0) quicktime_user_atoms_dump_APRG(u->atoms[i], len); else if (strncmp((char const*)u->atoms[i] + 4, "ARES", 4) == 0) quicktime_user_atoms_dump_ARES(u->atoms[i], len); } } void quicktime_write_user_atoms(quicktime_t * file, quicktime_user_atoms_t * u) { int i; uint32_t len; for(i = 0; i < u->num_atoms; i++) { len = ((uint32_t)u->atoms[i][0] << 24) | ((uint32_t)u->atoms[i][1] << 16) | ((uint32_t)u->atoms[i][2] << 8) | u->atoms[i][3]; quicktime_write_data(file, u->atoms[i], len); if (strncmp((char const*)u->atoms[i] + 4, "ARES", 4) == 0) { /* This padding keeps the Windows QuickTime player from crashing. FFMpeg inserts this kind of padding as well in mov_write_avid_tag(), although they don't specify the reason. */ static uint8_t const zero_padding[] = { 0, 0, 0, 0 }; quicktime_write_data(file, zero_padding, 4); } } } libquicktime-1.2.4/src/vrsc.c0000644000175000017500000000517011511622757013043 00000000000000/******************************************************************************* vrsc.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" int quicktime_vrsc_init(quicktime_vrsc_t *vrsc) { vrsc->version = 2; vrsc->revision = 0; vrsc->DefaultNodeID = 1; return 0; } int quicktime_vrsc_delete(quicktime_vrsc_t *vrsc) { return 0; } void quicktime_vrsc_dump(quicktime_vrsc_t *vrsc) { lqt_dump(" world header (vrsc)\n"); lqt_dump(" version %i\n", vrsc->version); lqt_dump(" revision %i\n", vrsc->revision); lqt_dump(" name atom id %ld\n", vrsc->NameAtomID); lqt_dump(" default node %ld\n", vrsc->DefaultNodeID); lqt_dump(" world flags %ld\n", vrsc->flags); } int quicktime_read_vrsc(quicktime_t *file, quicktime_vrsc_t *vrsc, quicktime_qtatom_t *vrsc_atom) { vrsc->version = quicktime_read_int16(file); vrsc->revision = quicktime_read_int16(file); vrsc->NameAtomID = quicktime_read_int32(file); vrsc->DefaultNodeID = quicktime_read_int32(file); vrsc->flags = quicktime_read_int32(file); vrsc->reserved1 = quicktime_read_int32(file); vrsc->reserved2 = quicktime_read_int32(file); return 0; } void quicktime_write_vrsc(quicktime_t *file, quicktime_vrsc_t *vrsc) { quicktime_qtatom_t atom; quicktime_qtatom_write_header(file, &atom, "vrsc", 1); quicktime_write_int16(file, vrsc->version); quicktime_write_int16(file, vrsc->revision); quicktime_write_int32(file, vrsc->NameAtomID); quicktime_write_int32(file, vrsc->DefaultNodeID); quicktime_write_int32(file, vrsc->flags); quicktime_write_int32(file, vrsc->reserved1); quicktime_write_int32(file, vrsc->reserved2); quicktime_qtatom_write_footer(file, &atom); } libquicktime-1.2.4/src/avi_avih.c0000644000175000017500000001157311511622756013657 00000000000000/******************************************************************************* avi_avih.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" /* uint32_t dwMicroSecPerFrame; uint32_t dwMaxBytesPerSec; uint32_t dwReserved1; uint32_t dwFlags; uint32_t dwTotalFrames; uint32_t dwInitialFrames; uint32_t dwStreams; uint32_t dwSuggestedBufferSize; uint32_t dwWidth; uint32_t dwHeight; uint32_t dwScale; uint32_t dwRate; uint32_t dwStart; uint32_t dwLength; */ void quicktime_read_avih(quicktime_t *file, quicktime_avih_t *avih, quicktime_atom_t *parent_atom) { avih->dwMicroSecPerFrame = quicktime_read_int32_le(file); avih->dwMaxBytesPerSec = quicktime_read_int32_le(file); avih->dwReserved1 = quicktime_read_int32_le(file); avih->dwFlags = quicktime_read_int32_le(file); avih->dwTotalFrames = quicktime_read_int32_le(file); avih->dwInitialFrames = quicktime_read_int32_le(file); avih->dwStreams = quicktime_read_int32_le(file); avih->dwSuggestedBufferSize = quicktime_read_int32_le(file); avih->dwWidth = quicktime_read_int32_le(file); avih->dwHeight = quicktime_read_int32_le(file); avih->dwScale = quicktime_read_int32_le(file); avih->dwRate = quicktime_read_int32_le(file); avih->dwStart = quicktime_read_int32_le(file); avih->dwLength = quicktime_read_int32_le(file); } void quicktime_write_avih(quicktime_t *file, quicktime_avih_t *avih) { quicktime_atom_t avih_atom; quicktime_atom_write_header(file, &avih_atom, "avih"); quicktime_write_int32_le(file, avih->dwMicroSecPerFrame); quicktime_write_int32_le(file, avih->dwMaxBytesPerSec); quicktime_write_int32_le(file, avih->dwReserved1); quicktime_write_int32_le(file, avih->dwFlags); quicktime_write_int32_le(file, avih->dwTotalFrames); quicktime_write_int32_le(file, avih->dwInitialFrames); quicktime_write_int32_le(file, avih->dwStreams); quicktime_write_int32_le(file, avih->dwSuggestedBufferSize); quicktime_write_int32_le(file, avih->dwWidth); quicktime_write_int32_le(file, avih->dwHeight); quicktime_write_int32_le(file, avih->dwScale); quicktime_write_int32_le(file, avih->dwRate); quicktime_write_int32_le(file, avih->dwStart); quicktime_write_int32_le(file, avih->dwLength); quicktime_atom_write_footer(file, &avih_atom); } void quicktime_avih_dump(quicktime_avih_t *avih) { lqt_dump("avih\n"); lqt_dump(" dwMicroSecPerFrame: %d\n", avih->dwMicroSecPerFrame); lqt_dump(" dwMaxBytesPerSec: %d\n", avih->dwMaxBytesPerSec); lqt_dump(" dwReserved1: %d\n", avih->dwReserved1); lqt_dump(" dwFlags: %d\n", avih->dwFlags); lqt_dump(" dwTotalFrames: %d\n", avih->dwTotalFrames); lqt_dump(" dwInitialFrames: %d\n", avih->dwInitialFrames); lqt_dump(" dwStreams: %d\n", avih->dwStreams); lqt_dump(" dwSuggestedBufferSize: %d\n", avih->dwSuggestedBufferSize); lqt_dump(" dwWidth: %d\n", avih->dwWidth); lqt_dump(" dwHeight: %d\n", avih->dwHeight); lqt_dump(" dwScale: %d\n", avih->dwScale); lqt_dump(" dwRate: %d\n", avih->dwRate); lqt_dump(" dwStart: %d\n", avih->dwStart); lqt_dump(" dwLength: %d\n", avih->dwLength); } void quicktime_avih_init(quicktime_avih_t *avih, quicktime_t * file) { if(file->total_vtracks) avih->dwMicroSecPerFrame = (uint32_t)(1000000 / quicktime_frame_rate(file, 0)); avih->dwFlags = AVI_HASINDEX | AVI_ISINTERLEAVED; avih->dwStreams = file->total_atracks + file->total_vtracks; // avih->dwSuggestedBufferSize = 1024 * 1024; if(file->total_vtracks) { avih->dwWidth = file->vtracks[0].track->tkhd.track_width; avih->dwHeight = file->vtracks[0].track->tkhd.track_height; } } libquicktime-1.2.4/src/multichannel.c0000644000175000017500000000621611511622757014553 00000000000000/******************************************************************************* multichannel.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ /* Multichannel support for libquicktime. */ #include "lqt_private.h" #include #include static struct { lqt_channel_t ch; char * name; } channels[] = { { LQT_CHANNEL_UNKNOWN, "Unknown" }, { LQT_CHANNEL_FRONT_LEFT, "Front Left" }, { LQT_CHANNEL_FRONT_RIGHT, "Front Right" }, { LQT_CHANNEL_FRONT_CENTER, "Front Center" }, { LQT_CHANNEL_FRONT_CENTER_LEFT, "Front Center Left" }, { LQT_CHANNEL_FRONT_CENTER_RIGHT, "Front Center Right" }, { LQT_CHANNEL_BACK_LEFT, "Back Left" }, { LQT_CHANNEL_BACK_RIGHT, "Back Right" }, { LQT_CHANNEL_BACK_CENTER, "Back Center" }, { LQT_CHANNEL_SIDE_LEFT, "Side Left" }, { LQT_CHANNEL_SIDE_RIGHT, "Side Right" }, #if 0 { LQT_CHANNEL_TOP_FRONT_LEFT, "Top Front Left" }, { LQT_CHANNEL_TOP_FRONT_RIGHT, "Top Front Right" }, { LQT_CHANNEL_TOP_FRONT_CENTER, "Top Front Center" }, { LQT_CHANNEL_TOP_BACK_LEFT, "Top Back Left" }, { LQT_CHANNEL_TOP_BACK_RIGHT, "Top Back Right" }, { LQT_CHANNEL_TOP_BACK_CENTER, "Top Back Center" }, #endif { LQT_CHANNEL_LFE, "LFE" } }; const char * lqt_channel_to_string(lqt_channel_t ch) { int i; for(i = 0; i < sizeof(channels) / sizeof(channels[0]); i++) { if(channels[i].ch == ch) return channels[i].name; } return channels[0].name; } void lqt_set_channel_setup(quicktime_t * file, int track, lqt_channel_t * ch) { if(!file->atracks[track].channel_setup) file->atracks[track].channel_setup = calloc(file->atracks[track].channels, sizeof(*file->atracks[track].channel_setup)); memcpy(file->atracks[track].channel_setup, ch, sizeof(*ch)*file->atracks[track].channels); quicktime_set_chan(&file->atracks[track]); } const lqt_channel_t * lqt_get_channel_setup(quicktime_t * file, int track) { if((track >= file->total_atracks) || (track < 0)) return (lqt_channel_t*)0; return file->atracks[track].channel_setup; } libquicktime-1.2.4/src/ndhd.c0000644000175000017500000000555411511622757013011 00000000000000/******************************************************************************* ndhd.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" int quicktime_ndhd_init(quicktime_ndhd_t *ndhd) { ndhd->version = 2; ndhd->revision = 0; ndhd->nodeType[0] = 'o'; ndhd->nodeType[1] = 'b'; ndhd->nodeType[2] = 'j'; ndhd->nodeType[3] = 'e'; ndhd->nodeID = 1; ndhd->nameAtomID = 0; ndhd->commentAtomID = 0; return 0; } int quicktime_ndhd_delete(quicktime_ndhd_t *ndhd) { return 0; } void quicktime_ndhd_dump(quicktime_ndhd_t *ndhd) { lqt_dump("node header (ndhd)\n"); lqt_dump(" version %i\n", ndhd->version ); lqt_dump(" revision %i\n", ndhd->revision ); lqt_dump(" node type %c%c%c%c\n", ndhd->nodeType[0],ndhd->nodeType[1],ndhd->nodeType[2],ndhd->nodeType[3] ); lqt_dump(" node id %ld\n", ndhd->nodeID ); lqt_dump(" name atom id %ld\n", ndhd->nameAtomID ); lqt_dump(" comment atom id %ld\n", ndhd->commentAtomID ); } int quicktime_read_ndhd(quicktime_t *file, quicktime_ndhd_t *ndhd) { ndhd->version = quicktime_read_int16(file); ndhd->revision = quicktime_read_int16(file); quicktime_read_char32(file, ndhd->nodeType); ndhd->nodeID = quicktime_read_int32(file); ndhd->nameAtomID = quicktime_read_int32(file); ndhd->commentAtomID = quicktime_read_int32(file); return 0; } void quicktime_write_ndhd(quicktime_t *file, quicktime_ndhd_t *ndhd) { quicktime_write_int16(file, ndhd->version); quicktime_write_int16(file, ndhd->revision); quicktime_write_char32(file, ndhd->nodeType); quicktime_write_int32(file, ndhd->nodeID); quicktime_write_int32(file, ndhd->nameAtomID); quicktime_write_int32(file, ndhd->commentAtomID); quicktime_write_int32(file, ndhd->reserved1); quicktime_write_int32(file, ndhd->reserved2); return; } libquicktime-1.2.4/src/charset.c0000644000175000017500000001451011511622756013514 00000000000000/******************************************************************************* charset.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include "charset.h" #include #include #include #include #define LOG_DOMAIN "charset" struct lqt_charset_converter_s { iconv_t cd; quicktime_t * file; /* For logging */ int utf_8_16; char * out_charset; char * in_buffer; int in_buffer_alloc; }; lqt_charset_converter_t * lqt_charset_converter_create(quicktime_t * file, const char * src_charset, const char * dst_charset) { lqt_charset_converter_t * ret = calloc(1, sizeof(*ret)); if(!strcmp(src_charset, LQT_UTF_8_16)) { ret->out_charset = malloc(strlen(dst_charset)+1); strcpy(ret->out_charset, dst_charset); ret->utf_8_16 = 1; ret->cd = (iconv_t)-1; } else { ret->cd = iconv_open(dst_charset, src_charset); if(ret->cd == (iconv_t)-1) { free(ret); return (lqt_charset_converter_t*)0; } } ret->file = file; return ret; } #define BYTES_INCREMENT 10 static int do_convert(lqt_charset_converter_t * cnv, char * in_string, int len, int * out_len, char ** ret, int * ret_alloc) { char *inbuf; char *outbuf; int output_pos; size_t inbytesleft; size_t outbytesleft; /* Check for MP4 Unicode */ if(cnv->utf_8_16 && (cnv->cd == (iconv_t)-1)) { /* Byte order Little Endian */ if((len > 1) && ((uint8_t)in_string[0] == 0xff) && ((uint8_t)in_string[1] == 0xfe)) { cnv->cd = iconv_open(cnv->out_charset, "UTF-16LE"); if(cnv->cd == (iconv_t)-1) { lqt_log(cnv->file, LQT_LOG_ERROR, LOG_DOMAIN, "Cannot open iconv for conversion to %s from %s", cnv->out_charset, "UTF-16LE"); return 0; } } /* Byte order Big Endian */ else if((len > 1) && ((uint8_t)in_string[0] == 0xfe) && ((uint8_t)in_string[1] == 0xff)) { cnv->cd = iconv_open(cnv->out_charset, "UTF-16BE"); if(cnv->cd == (iconv_t)-1) { lqt_log(cnv->file, LQT_LOG_ERROR, LOG_DOMAIN, "Cannot open iconv for conversion to %s from %s", cnv->out_charset, "UTF-16BE"); return 0; } } /* UTF-8 */ else if(!strcmp(cnv->out_charset, "UTF-8")) { if(*ret_alloc < len+1) { *ret_alloc = len + BYTES_INCREMENT; *ret = realloc(*ret, *ret_alloc); } strncpy(*ret, in_string, len); (*ret)[len] = '\0'; if(out_len) *out_len = len; return 1; } else { cnv->cd = iconv_open(cnv->out_charset, "UTF-8"); if(cnv->cd == (iconv_t)-1) { lqt_log(cnv->file, LQT_LOG_ERROR, LOG_DOMAIN, "Cannot open iconv for conversion to %s from %s", cnv->out_charset, "UTF-8"); return 0; } } } if((*ret_alloc) < len + BYTES_INCREMENT) { *ret_alloc = len + BYTES_INCREMENT; *ret = realloc(*ret, *ret_alloc); } inbytesleft = len; outbytesleft = *ret_alloc; inbuf = in_string; outbuf = *ret; while(1) { if(iconv(cnv->cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft) == (size_t)-1) { switch(errno) { case E2BIG: output_pos = (int)(outbuf - *ret); *ret_alloc += BYTES_INCREMENT; outbytesleft += BYTES_INCREMENT; *ret = realloc(*ret, *ret_alloc); outbuf = &((*ret)[output_pos]); break; case EILSEQ: lqt_log(cnv->file, LQT_LOG_ERROR, LOG_DOMAIN, "Invalid Multibyte sequence"); return 0; break; case EINVAL: lqt_log(cnv->file, LQT_LOG_ERROR, LOG_DOMAIN, "Incomplete Multibyte sequence"); return 0; break; } } if(!inbytesleft) break; } /* Zero terminate */ output_pos = (int)(outbuf - *ret); if(outbytesleft < 2) { *ret_alloc+=2; *ret = realloc(*ret, *ret_alloc); outbuf = &((*ret)[output_pos]); } outbuf[0] = '\0'; outbuf[1] = '\0'; if(out_len) *out_len = outbuf - *ret; return 1; } /* We convert all strings "in place" */ void lqt_charset_convert(lqt_charset_converter_t * cnv, char ** str, int in_len, int * out_len) { char * new = (char*)0; int new_alloc = 0; if(!(*str)) return; if(in_len < 0) in_len = strlen(*str); if(!do_convert(cnv, *str, in_len, out_len, &new, &new_alloc)) { if(new) free(new); return; } free(*str); *str = new; } void lqt_charset_convert_realloc(lqt_charset_converter_t * cnv, const char * in_str, int in_len, char ** out_str, int * out_alloc, int * out_len) { if(in_len < 0) in_len = strlen(in_str); if(cnv->in_buffer_alloc < in_len + 2) { cnv->in_buffer_alloc = in_len + 128; cnv->in_buffer = realloc(cnv->in_buffer, cnv->in_buffer_alloc); } memcpy(cnv->in_buffer, in_str, in_len); cnv->in_buffer[in_len] = '\0'; cnv->in_buffer[in_len+1] = '\0'; do_convert(cnv, cnv->in_buffer, in_len, out_len, out_str, out_alloc); } void lqt_charset_converter_destroy(lqt_charset_converter_t * cnv) { if(cnv->cd != (iconv_t)-1) iconv_close(cnv->cd); if(cnv->out_charset) free(cnv->out_charset); free(cnv); } libquicktime-1.2.4/src/lqt_qtvr.c0000644000175000017500000005701111511622756013742 00000000000000/******************************************************************************* lqt_qtvr.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #define LOG_DOMAIN "qtvr" /* util */ static int deg2frame(quicktime_t *file, float hdeg, float vdeg) { return ((hdeg * abs(vdeg-90)) / 64800) * lqt_qtvr_get_columns(file) * lqt_qtvr_get_rows(file) * file->moov.udta.navg.loop_frames; } int lqt_qtvr_add_object_node(quicktime_t *file) { quicktime_qtatom_t root_atom, leaf_atom; quicktime_trak_t *trak; quicktime_ndhd_init(&file->qtvr_node[0].ndhd); trak = file->moov.trak[lqt_qtvr_get_qtvr_track(file)]; if (quicktime_track_samples(file, trak) > 0) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "lqt_qtvr_add_node only single node movies supported."); return -1; } quicktime_write_chunk_header(file, trak); quicktime_qtatom_write_container_header(file); quicktime_qtatom_write_header(file, &root_atom, "sean", 1); root_atom.child_count = 1; quicktime_qtatom_write_header(file, &leaf_atom, "ndhd", 1); quicktime_write_ndhd(file, &file->qtvr_node[0].ndhd); quicktime_qtatom_write_footer(file, &leaf_atom); quicktime_qtatom_write_footer(file, &root_atom); trak->chunk_samples = 1; quicktime_write_chunk_footer(file, trak); trak->mdia.minf.stbl.stsd.table->qtvr.vrnp.children++; trak->mdia.minf.stbl.stsd.table->qtvr.vrnp.vrni->nloc.nodeType[0] = 'o'; trak->mdia.minf.stbl.stsd.table->qtvr.vrnp.vrni->nloc.nodeType[1] = 'b'; trak->mdia.minf.stbl.stsd.table->qtvr.vrnp.vrni->nloc.nodeType[2] = 'j'; trak->mdia.minf.stbl.stsd.table->qtvr.vrnp.vrni->nloc.nodeType[3] = 'e'; trak->mdia.minf.stbl.stts.table[0].sample_count = 1; /* set duration to duration of image track */ /* works with 1 too but this seems to be more correct */ trak->mdia.minf.stbl.stts.table[0].sample_duration = file->qtvr_node[0].obji.rows * file->qtvr_node[0].obji.columns; trak->tref.references[0].tracks[0] = file->moov.trak[lqt_qtvr_get_object_track(file)]->tkhd.track_id; trak = file->moov.trak[lqt_qtvr_get_object_track(file)]; quicktime_write_chunk_header(file, trak); quicktime_qtatom_write_container_header(file); quicktime_qtatom_write_header(file, &root_atom, "sean", 1); root_atom.child_count = 1; quicktime_qtatom_write_header(file, &leaf_atom, "obji", 1); leaf_atom.child_count = 0; quicktime_write_obji(file, &file->qtvr_node[0].obji); quicktime_qtatom_write_footer(file, &leaf_atom); quicktime_qtatom_write_footer(file, &root_atom); trak->chunk_samples = 1; quicktime_write_chunk_footer(file, trak); trak->mdia.minf.stbl.stts.table[0].sample_count = 1; /* set duration to duration of image track */ trak->mdia.minf.stbl.stts.table[0].sample_duration = file->qtvr_node[0].obji.rows * file->qtvr_node[0].obji.columns; return 0; } int lqt_qtvr_add_panorama_node(quicktime_t *file) { quicktime_qtatom_t root_atom, leaf_atom; quicktime_trak_t *trak; quicktime_ndhd_init(&file->qtvr_node[0].ndhd); file->qtvr_node[0].ndhd.nodeType[0] = 'p'; file->qtvr_node[0].ndhd.nodeType[1] = 'a'; file->qtvr_node[0].ndhd.nodeType[2] = 'n'; file->qtvr_node[0].ndhd.nodeType[3] = 'o'; file->qtvr_node[0].pdat.imageSizeX = quicktime_video_width(file, 0); // could be a different track file->qtvr_node[0].pdat.imageSizeY = quicktime_video_height(file, 0) * file->qtvr_node[0].pdat.imageNumFramesY; trak = file->moov.trak[lqt_qtvr_get_qtvr_track(file)]; if (quicktime_track_samples(file, trak) > 0) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "lqt_qtvr_add_node only single node movies supported."); return -1; } quicktime_write_chunk_header(file, trak); quicktime_qtatom_write_container_header(file); quicktime_qtatom_write_header(file, &root_atom, "sean", 1); root_atom.child_count = 1; quicktime_qtatom_write_header(file, &leaf_atom, "ndhd", 1); quicktime_write_ndhd(file, &file->qtvr_node[0].ndhd); quicktime_qtatom_write_footer(file, &leaf_atom); quicktime_qtatom_write_footer(file, &root_atom); trak->chunk_samples = 1; quicktime_write_chunk_footer(file, trak); trak->mdia.minf.stbl.stsd.table->qtvr.vrnp.children++; trak->mdia.minf.stbl.stsd.table->qtvr.vrnp.vrni->nloc.nodeType[0] = 'p'; trak->mdia.minf.stbl.stsd.table->qtvr.vrnp.vrni->nloc.nodeType[1] = 'a'; trak->mdia.minf.stbl.stsd.table->qtvr.vrnp.vrni->nloc.nodeType[2] = 'n'; trak->mdia.minf.stbl.stsd.table->qtvr.vrnp.vrni->nloc.nodeType[3] = 'o'; trak->mdia.minf.stbl.stts.table[0].sample_count = 1; /* set duration to duration of image track */ /* works with 1 too but this seems more correct */ trak->mdia.minf.stbl.stts.table[0].sample_duration = file->qtvr_node[0].pdat.imageNumFramesX * file->qtvr_node[0].pdat.imageNumFramesX; trak->tref.references[0].tracks[0] = file->moov.trak[lqt_qtvr_get_panorama_track(file)]->tkhd.track_id; trak = file->moov.trak[lqt_qtvr_get_panorama_track(file)]; quicktime_write_chunk_header(file, trak); quicktime_qtatom_write_container_header(file); quicktime_qtatom_write_header(file, &root_atom, "sean", 1); root_atom.child_count = 1; quicktime_qtatom_write_header(file, &leaf_atom, "pdat", 1); leaf_atom.child_count = 0; quicktime_write_pdat(file, &file->qtvr_node[0].pdat); quicktime_qtatom_write_footer(file, &leaf_atom); quicktime_qtatom_write_footer(file, &root_atom); trak->chunk_samples = 1; quicktime_write_chunk_footer(file, trak); trak->mdia.minf.stbl.stts.table[0].sample_count = 1; /* set duration to duration of image track */ trak->mdia.minf.stbl.stts.table[0].sample_duration = file->qtvr_node[0].pdat.imageNumFramesX * file->qtvr_node[0].pdat.imageNumFramesX; return 0; } /* type of file */ int lqt_is_qtvr(quicktime_t *file) { if (file->moov.udta.is_qtvr) { if (quicktime_match_32(file->moov.udta.ctyp, "stna") || (lqt_qtvr_get_object_track(file) >= 0)) return QTVR_OBJ; if (quicktime_match_32(file->moov.udta.ctyp, "STpn") || (lqt_qtvr_get_panorama_track(file) >= 0)) return QTVR_PAN; } return 0; } /* type of qtvr to write */ int lqt_qtvr_set_type(quicktime_t *file, int type, int width, int height, int duration, int time_scale, int scene_track) { quicktime_trak_t *trak; if (time_scale < 1 || duration < 1 || scene_track >= file->total_vtracks || scene_track < 0) return -1; if (type == QTVR_OBJ) { file->moov.udta.ctyp[0] = 'q'; file->moov.udta.ctyp[1] = 't'; file->moov.udta.ctyp[2] = 'v'; file->moov.udta.ctyp[3] = 'r'; file->moov.udta.is_qtvr = 1; trak = quicktime_add_track(file); quicktime_trak_init_qtvr(file, trak, QTVR_OBJ, width, height, duration, time_scale); quicktime_obji_init(&file->qtvr_node[0].obji); file->qtvr_node[0].obji.viewDuration = duration; trak = quicktime_add_track(file); quicktime_trak_init_qtvr(file, trak, QTVR_QTVR_OBJ, width, height, duration, time_scale); lqt_qtvr_set_display_width(file, width); lqt_qtvr_set_display_height(file, height); lqt_qtvr_set_image_track(file, scene_track); return 0; } if (type == QTVR_PAN) { file->moov.udta.ctyp[0] = 'q'; file->moov.udta.ctyp[1] = 't'; file->moov.udta.ctyp[2] = 'v'; file->moov.udta.ctyp[3] = 'r'; file->moov.udta.is_qtvr = 1; trak = quicktime_add_track(file); quicktime_trak_init_qtvr(file, trak, QTVR_PAN, width, height, duration, time_scale); quicktime_pdat_init(&file->qtvr_node[0].pdat); trak = quicktime_add_track(file); quicktime_trak_init_qtvr(file, trak, QTVR_QTVR_PAN, width, height, duration, time_scale); /* set initial scene track*/ lqt_qtvr_set_image_track(file, scene_track); return 0; } file->moov.udta.is_qtvr = 0; return -1; } /* Number of frames in loop */ int lqt_qtvr_get_loop_frames(quicktime_t *file) { if (lqt_qtvr_get_object_track(file) >= 0) { return file->qtvr_node[0].obji.viewDuration / file->moov.trak[lqt_track_from_id(file, lqt_qtvr_get_image_track(file))]->mdia.minf.stbl.stts.table[0].sample_duration; } else { return file->moov.udta.navg.loop_frames; } } /* Number of rows */ int lqt_qtvr_get_rows(quicktime_t *file) { if (lqt_is_qtvr(file) == QTVR_OBJ) { if (lqt_qtvr_get_object_track(file) >= 0) { return file->qtvr_node[0].obji.rows; } else { return file->moov.udta.navg.rows; } } else if (lqt_is_qtvr(file) == QTVR_PAN) { if (lqt_qtvr_get_qtvr_track(file) >= 0) { if (lqt_qtvr_get_panotype(file) == QTVR_PANO_HORZ) { return file->qtvr_node[0].pdat.imageNumFramesY; } else { return file->qtvr_node[0].pdat.imageNumFramesX; } } else { return file->moov.trak[lqt_qtvr_get_panorama_track(file)]->mdia.minf.stbl.stsd.table->pano.SNumFramesHeight; } } return -1; } /* Number of columns */ int lqt_qtvr_get_columns(quicktime_t *file) { if (lqt_is_qtvr(file) == QTVR_OBJ) { if (lqt_qtvr_get_object_track(file) >= 0) { return file->qtvr_node[0].obji.columns; } else { return file->moov.udta.navg.columns; } } else if (lqt_is_qtvr(file) == QTVR_PAN) { if (lqt_qtvr_get_qtvr_track(file) >= 0) { if (lqt_qtvr_get_panotype(file) == QTVR_PANO_HORZ) { return file->qtvr_node[0].pdat.imageNumFramesX; } else { return file->qtvr_node[0].pdat.imageNumFramesY; } } else { return file->moov.trak[lqt_qtvr_get_panorama_track(file)]->mdia.minf.stbl.stsd.table->pano.SNumFramesWidth; } } return -1; } /* pan (H) */ void lqt_qtvr_get_pan(quicktime_t *file, float *minpan, float *maxpan, float *defpan) { if (lqt_qtvr_get_object_track(file) >= 0) { if (minpan != NULL ) *minpan = file->qtvr_node[0].obji.minPan; if (maxpan != NULL ) *maxpan = file->qtvr_node[0].obji.maxPan; if (defpan != NULL ) *maxpan = file->qtvr_node[0].obji.defaultPan; } else { if (minpan != NULL ) *minpan = file->moov.udta.navg.startHPan; if (maxpan != NULL ) *maxpan = file->moov.udta.navg.endHPan; if (defpan != NULL ) *defpan = file->moov.udta.navg.initialHPan; } } void lqt_qtvr_set_pan(quicktime_t *file, float minpan, float maxpan, float defpan) { if (lqt_qtvr_get_object_track(file) >= 0) { file->qtvr_node[0].obji.minPan = minpan; file->qtvr_node[0].obji.maxPan = maxpan; file->qtvr_node[0].obji.defaultPan = defpan; } else { file->moov.udta.navg.startHPan = minpan; file->moov.udta.navg.endHPan = maxpan; file->moov.udta.navg.initialHPan = defpan; } } /* tilt (V) */ void lqt_qtvr_get_tilt(quicktime_t *file, float *mintilt, float *maxtilt, float *deftilt) { if (lqt_qtvr_get_object_track(file) >= 0) { if (mintilt != NULL ) *mintilt = file->qtvr_node[0].obji.minTilt; if (maxtilt != NULL ) *maxtilt = file->qtvr_node[0].obji.maxTilt; if (deftilt != NULL ) *maxtilt = file->qtvr_node[0].obji.defaultTilt; } else { if (mintilt != NULL ) *mintilt = file->moov.udta.navg.startVPan; if (maxtilt != NULL ) *maxtilt = file->moov.udta.navg.endVPan; if (deftilt != NULL ) *deftilt = file->moov.udta.navg.initialVPan; } } void lqt_qtvr_set_tilt(quicktime_t *file, float mintilt, float maxtilt, float deftilt) { if (lqt_qtvr_get_object_track(file) >= 0) { file->qtvr_node[0].obji.minTilt = mintilt; file->qtvr_node[0].obji.maxTilt = maxtilt; file->qtvr_node[0].obji.defaultTilt = deftilt; } else { file->moov.udta.navg.startHPan = mintilt; file->moov.udta.navg.endHPan = maxtilt; file->moov.udta.navg.initialHPan = deftilt; } } /* FOV "Zoom" */ void lqt_qtvr_get_fov(quicktime_t *file, float *minfov, float *maxfov, float *deffov) { if (lqt_qtvr_get_qtvr_track(file) >= 0 ) { if (lqt_qtvr_get_object_track(file) >= 0) { if (minfov != NULL ) *minfov = file->qtvr_node[0].obji.minFOV; if (maxfov != NULL ) *maxfov = file->qtvr_node[0].obji.FOV; if (deffov != NULL ) *deffov = file->qtvr_node[0].obji.defaultFOV; } else if (lqt_qtvr_get_panorama_track(file) >= 0) { if (minfov != NULL) *minfov = file->qtvr_node[0].pdat.minFOV; if (maxfov != NULL) *maxfov = file->qtvr_node[0].pdat.maxFOV; if (deffov != NULL) *deffov = file->qtvr_node[0].pdat.defaultFOV; } } else { if (lqt_is_qtvr(file) == QTVR_OBJ) { if (minfov != NULL ) *minfov = file->moov.udta.navg.fieldofview; if (maxfov != NULL ) *maxfov = file->moov.udta.navg.fieldofview; if (deffov != NULL ) *deffov = file->moov.udta.navg.fieldofview; } else if (lqt_is_qtvr(file) == QTVR_PAN) { if (minfov != NULL ) *minfov = file->moov.trak[lqt_qtvr_get_panorama_track(file)]->mdia.minf.stbl.stsd.table->pano.MinZoom; if (maxfov != NULL ) *maxfov = file->moov.trak[lqt_qtvr_get_panorama_track(file)]->mdia.minf.stbl.stsd.table->pano.MaxZoom; if (deffov != NULL ) *deffov = file->moov.trak[lqt_qtvr_get_panorama_track(file)]->mdia.minf.stbl.stsd.table->pano.MinZoom; } } } void lqt_qtvr_set_fov(quicktime_t *file, float minfov, float maxfov, float deffov) { if (lqt_qtvr_get_object_track(file) >= 0) { file->qtvr_node[0].obji.minFOV = minfov; file->qtvr_node[0].obji.FOV = maxfov; file->qtvr_node[0].obji.defaultFOV = deffov; } else { file->moov.trak[lqt_qtvr_get_panorama_track(file)]->mdia.minf.stbl.stsd.table->pano.MinZoom = minfov; file->moov.trak[lqt_qtvr_get_panorama_track(file)]->mdia.minf.stbl.stsd.table->pano.MaxZoom = maxfov; } } /* frame to start at */ int lqt_qtvr_get_initial_position(quicktime_t *file) { if (lqt_qtvr_get_object_track(file) >= 0) { return deg2frame(file, file->qtvr_node[0].obji.defaultPan, file->qtvr_node[0].obji.defaultTilt); } else { return deg2frame(file, file->moov.udta.navg.initialHPan, file->moov.udta.navg.initialVPan); } return -1; } /* movietype */ int lqt_qtvr_get_movietype(quicktime_t *file) { if (lqt_qtvr_get_object_track(file) >= 0) { return file->qtvr_node[0].obji.movieType; } else { return file->moov.udta.navg.movietype; } } int lqt_qtvr_set_movietype(quicktime_t *file, int movietype) { if (movietype == QTVR_GRABBER_SCROLLER_UI || movietype == QTVR_OLD_JOYSTICK_UI || movietype == QTVR_JOYSTICK_UI || movietype == QTVR_GRABBER_UI || movietype == QTVR_ABSOLUTE_UI) { if (lqt_qtvr_get_object_track(file) >= 0) { file->qtvr_node[0].obji.movieType = movietype; } else { file->moov.udta.navg.movietype = movietype; } return 0; } return -1; } /* Set number of rows */ int lqt_qtvr_set_rows(quicktime_t *file, int rows) { if (rows > 0) { if (lqt_is_qtvr(file) == QTVR_OBJ) { file->qtvr_node[0].obji.rows = rows; return 0; } else if (lqt_is_qtvr(file) == QTVR_PAN) { file->qtvr_node[0].pdat.imageNumFramesX = rows; return 0; } } return -1; } /* Set number of columns */ int lqt_qtvr_set_columns(quicktime_t *file, int columns) { if (columns > 0) { if (lqt_is_qtvr(file) == QTVR_OBJ) { file->qtvr_node[0].obji.columns = columns; return 0; } else if (lqt_is_qtvr(file) == QTVR_PAN) { file->qtvr_node[0].pdat.imageNumFramesY = columns; return 0; } } return -1; } /* dimensions of the player window */ int lqt_qtvr_get_display_width(quicktime_t *file) { if (lqt_is_qtvr(file) == QTVR_OBJ) { return quicktime_video_width(file, 0); } else if (lqt_is_qtvr(file) == QTVR_PAN) { return (int)file->moov.trak[lqt_qtvr_get_panorama_track(file)]->tkhd.track_width; } return -1; } int lqt_qtvr_set_display_width(quicktime_t *file, int width) { if (lqt_is_qtvr(file) == QTVR_OBJ) { file->moov.trak[lqt_qtvr_get_qtvr_track(file)]->tkhd.track_width = (float)width; file->moov.trak[lqt_qtvr_get_object_track(file)]->tkhd.track_width = (float)width; } else if (lqt_is_qtvr(file) == QTVR_PAN) { file->moov.trak[lqt_qtvr_get_panorama_track(file)]->tkhd.track_width = (float)width; } return -1; } int lqt_qtvr_get_display_height(quicktime_t *file) { if (lqt_is_qtvr(file) == QTVR_OBJ) { return quicktime_video_height(file, 0); } else if (lqt_is_qtvr(file) == QTVR_PAN) { return (int)file->moov.trak[lqt_qtvr_get_panorama_track(file)]->tkhd.track_height; } return -1; } int lqt_qtvr_set_display_height(quicktime_t *file, int height) { if (lqt_is_qtvr(file) == QTVR_OBJ) { file->moov.trak[lqt_qtvr_get_qtvr_track(file)]->tkhd.track_height = height; file->moov.trak[lqt_qtvr_get_object_track(file)]->tkhd.track_height = height; } else if (lqt_is_qtvr(file) == QTVR_PAN) { file->moov.trak[lqt_qtvr_get_panorama_track(file)]->tkhd.track_height = height; } return -1; } /* get depth */ int lqt_qtvr_get_depth(quicktime_t *file) { if (lqt_is_qtvr(file) == QTVR_OBJ) { return quicktime_video_depth(file, 0); } else if (lqt_is_qtvr(file) == QTVR_PAN) { // add v2 return (int)file->moov.trak[lqt_qtvr_get_panorama_track(file)]->mdia.minf.stbl.stsd.table->pano.SDepth; } return -1; } /* get/set full pano dimensions */ int lqt_qtvr_get_width(quicktime_t *file) { if (lqt_is_qtvr(file) == QTVR_OBJ) { return quicktime_video_width(file, 0); } else if (lqt_is_qtvr(file) == QTVR_PAN) { if (lqt_qtvr_get_qtvr_track(file) >= 0) { if (lqt_qtvr_get_panotype(file) == QTVR_PANO_HORZ) { return file->qtvr_node[0].pdat.imageSizeX; } else { return file->qtvr_node[0].pdat.imageSizeY; } } else { return file->moov.trak[lqt_qtvr_get_panorama_track(file)]->mdia.minf.stbl.stsd.table->pano.SWidth; } } return -1; } int lqt_qtvr_get_height(quicktime_t *file) { if (lqt_is_qtvr(file) == QTVR_OBJ) { return quicktime_video_height(file, 0); } else if (lqt_is_qtvr(file) == QTVR_PAN) { if (lqt_qtvr_get_qtvr_track(file) >= 0) { if (lqt_qtvr_get_panotype(file) == QTVR_PANO_HORZ) { return file->qtvr_node[0].pdat.imageSizeY; } else { return file->qtvr_node[0].pdat.imageSizeX; } } else { return file->moov.trak[lqt_qtvr_get_panorama_track(file)]->mdia.minf.stbl.stsd.table->pano.SHeight; } } return -1; } /* Panorama specific */ int lqt_qtvr_get_panorama_track(quicktime_t *file) { int i; for(i = 0; i < file->moov.total_tracks; i++) { if (quicktime_match_32(file->moov.trak[i]->mdia.hdlr.component_subtype, "STpn")) { return i; } if (quicktime_match_32(file->moov.trak[i]->mdia.hdlr.component_subtype, "pano")) { return i; } } return -1; } int lqt_qtvr_get_panotype(quicktime_t *file) { if (lqt_is_qtvr(file) == QTVR_PAN) { if (lqt_qtvr_get_qtvr_track(file) >= 0 && quicktime_match_32(file->qtvr_node[0].pdat.panoType, "hcyl")) { return QTVR_PANO_HORZ; } return QTVR_PANO_VERT; } return -1; } /* object specific */ int lqt_qtvr_get_object_track(quicktime_t *file) { int i; for(i = 0; i < file->moov.total_tracks; i++) { if (quicktime_match_32(file->moov.trak[i]->mdia.hdlr.component_subtype, "obje")) { return i; } } return -1; } /* get qtvr track */ int lqt_qtvr_get_qtvr_track(quicktime_t *file) { int i; for(i = 0; i < file->moov.total_tracks; i++) { if (quicktime_match_32(file->moov.trak[i]->mdia.hdlr.component_subtype, "qtvr")) { return i; } } return -1; } /* set/get image track */ int lqt_qtvr_set_image_track(quicktime_t *file, int track) { if (lqt_qtvr_get_object_track(file) >= 0) { int otrack = lqt_qtvr_get_object_track(file); if (otrack != -1 && file->total_vtracks > track) { file->moov.trak[otrack]->tref.references[0].tracks[0] = file->vtracks[track].track->tkhd.track_id; return 0; } } else { int ptrack = lqt_qtvr_get_panorama_track(file); if (ptrack != -1 && file->total_vtracks > track) { /* reset the prevous vtracks flags if required */ if (file->moov.trak[ptrack]->mdia.minf.stbl.stsd.table->pano.STrack != 0) file->moov.trak[lqt_track_from_id(file, file->moov.trak[ptrack]->mdia.minf.stbl.stsd.table->pano.STrack)]->tkhd.flags = 15; file->moov.trak[ptrack]->mdia.minf.stbl.stsd.table->pano.STrack = file->vtracks[track].track->tkhd.track_id; file->vtracks[track].track->tkhd.flags = 14; /* deactivate this vtrack */ return 0; } } return -1; } // This will not work correctly with movies that contain panos and obj movies in the same file // possibly replace with _get_object_image_track() and _get_pano_image_track() int lqt_qtvr_get_image_track(quicktime_t *file) { if (lqt_qtvr_get_qtvr_track(file) >= 0) { if (lqt_qtvr_get_object_track(file) != -1) { return file->moov.trak[lqt_qtvr_get_object_track(file)]->tref.references[0].tracks[0]; } else if (lqt_qtvr_get_panorama_track(file) != -1) { return file->qtvr_node[0].pdat.imageRefTrackIndex; } } else { if (lqt_qtvr_get_panorama_track(file) != -1) { return file->moov.trak[lqt_qtvr_get_panorama_track(file)]->mdia.minf.stbl.stsd.table->pano.STrack; } } return -1; } /* get track by track id */ int lqt_track_from_id(quicktime_t *file, int track_id) { int i; for(i = 0; i < file->moov.total_tracks; i++) { if (file->moov.trak[i]->tkhd.track_id == track_id ) return i; } return -1; } libquicktime-1.2.4/src/imgp.c0000644000175000017500000000415711511622756013025 00000000000000/******************************************************************************* imgp.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" int quicktime_imgp_init(quicktime_imgp_t *imgp) { quicktime_impn_init(&imgp->impn); return 0; } int quicktime_imgp_delete(quicktime_imgp_t *imgp) { return 0; } void quicktime_imgp_dump(quicktime_imgp_t *imgp) { lqt_dump(" Imaging Parent (imgp)\n"); quicktime_impn_dump(&imgp->impn); } int quicktime_read_imgp(quicktime_t *file, quicktime_imgp_t *imgp, quicktime_qtatom_t *imgp_atom) { quicktime_qtatom_t leaf_atom; int result = 0; do { quicktime_qtatom_read_header(file, &leaf_atom); if(quicktime_qtatom_is(&leaf_atom, "impn")) { result += quicktime_read_impn(file, &imgp->impn, &leaf_atom); } else quicktime_qtatom_skip(file, &leaf_atom); }while(quicktime_position(file) < imgp_atom->end); return result; } void quicktime_write_imgp(quicktime_t *file, quicktime_imgp_t *imgp ) { quicktime_qtatom_t atom; quicktime_qtatom_write_header(file, &atom, "imgp", 1); quicktime_write_impn(file, &imgp->impn); atom.child_count = 1; quicktime_qtatom_write_footer(file, &atom); } libquicktime-1.2.4/src/elst.c0000644000175000017500000001221211722235260013021 00000000000000/******************************************************************************* elst.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include void quicktime_elst_table_init(quicktime_elst_table_t *table) { table->duration = 0; table->time = 0; table->rate = 1; } void quicktime_elst_table_delete(quicktime_elst_table_t *table) { } void quicktime_read_elst_table(quicktime_t *file, quicktime_elst_table_t *table) { table->duration = quicktime_read_int32(file); table->time = quicktime_read_int32(file); table->rate = quicktime_read_fixed32(file); } void quicktime_write_elst_table(quicktime_t *file, quicktime_elst_table_t *table) { quicktime_write_int32(file, table->duration); quicktime_write_int32(file, table->time); quicktime_write_fixed32(file, table->rate); } void quicktime_elst_table_dump(quicktime_elst_table_t *table) { lqt_dump(" edit list table\n"); lqt_dump(" duration %d\n", table->duration); lqt_dump(" time %d\n", table->time); lqt_dump(" rate %f\n", table->rate); } void quicktime_elst_init(quicktime_elst_t *elst) { elst->version = 0; elst->flags = 0; elst->total_entries = 0; elst->table = 0; } void quicktime_elst_init_all(quicktime_elst_t *elst) { if(!elst->total_entries) { elst->total_entries = 1; elst->table = realloc(NULL, sizeof(*elst->table) * elst->total_entries); quicktime_elst_table_init(&elst->table[0]); } } void quicktime_elst_fix_counts(quicktime_elst_t *elst, int moov_scale, quicktime_trak_t * trak, int timescale) { int64_t offset_scaled; offset_scaled = (int64_t)((double)trak->pts_offset / timescale * moov_scale + 0.5); elst->table[0].duration = trak->tkhd.duration; if(trak->pts_offset < 0) { elst->table[0].time = -trak->pts_offset; } else if(offset_scaled > 0) { /* Insert empty edit */ elst->total_entries++; elst->table = realloc(elst->table, sizeof(*elst->table) * elst->total_entries); memmove(elst->table + 1, elst->table, sizeof(*elst->table) * (elst->total_entries-1)); elst->table[0].time = -1; elst->table[0].duration = offset_scaled; elst->table[0].rate = 1.0; } } int64_t quicktime_elst_get_pts_offset(quicktime_elst_t *elst, int moov_scale, int timescale) { if(elst->total_entries == 1) { if(elst->table[0].time > 0) return - elst->table[0].time; } /* Detect empty edit */ else if((elst->total_entries == 2) && (elst->table[0].time == -1)) return (int64_t)((double)elst->table[0].duration / moov_scale * timescale + 0.5); return 0; } void quicktime_elst_delete(quicktime_elst_t *elst) { int i; if(elst->total_entries) { for(i = 0; i < elst->total_entries; i++) quicktime_elst_table_delete(&elst->table[i]); free(elst->table); } elst->total_entries = 0; } void quicktime_elst_dump(quicktime_elst_t *elst) { int i; lqt_dump(" edit list (elst)\n"); lqt_dump(" version %d\n", elst->version); lqt_dump(" flags %ld\n", elst->flags); lqt_dump(" total_entries %ld\n", elst->total_entries); for(i = 0; i < elst->total_entries; i++) { quicktime_elst_table_dump(&elst->table[i]); } } void quicktime_read_elst(quicktime_t *file, quicktime_elst_t *elst) { int i; elst->version = quicktime_read_char(file); elst->flags = quicktime_read_int24(file); elst->total_entries = quicktime_read_int32(file); elst->table = (quicktime_elst_table_t*)calloc(1, sizeof(quicktime_elst_table_t) * elst->total_entries); for(i = 0; i < elst->total_entries; i++) { quicktime_elst_table_init(&elst->table[i]); quicktime_read_elst_table(file, &elst->table[i]); } } void quicktime_write_elst(quicktime_t *file, quicktime_elst_t *elst) { quicktime_atom_t atom; int i; quicktime_atom_write_header(file, &atom, "elst"); quicktime_write_char(file, elst->version); quicktime_write_int24(file, elst->flags); quicktime_write_int32(file, elst->total_entries); for(i = 0; i < elst->total_entries; i++) quicktime_write_elst_table(file, &elst->table[i]); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/qtvr.c0000644000175000017500000000551711511622757013067 00000000000000/******************************************************************************* qtvr.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include int quicktime_qtvr_init(quicktime_qtvr_t *qtvr) { memset(qtvr, 0, sizeof(*qtvr)); quicktime_imgp_init(&qtvr->imgp); quicktime_vrsc_init(&qtvr->vrsc); quicktime_vrnp_init(&qtvr->vrnp); return 0; } int quicktime_qtvr_delete(quicktime_qtvr_t *qtvr) { return 0; } void quicktime_qtvr_dump(quicktime_qtvr_t *qtvr) { lqt_dump(" qtvr world\n"); quicktime_vrsc_dump(&qtvr->vrsc); quicktime_imgp_dump(&qtvr->imgp); quicktime_vrnp_dump(&qtvr->vrnp); } int quicktime_read_qtvr(quicktime_t *file, quicktime_qtvr_t *qtvr, quicktime_atom_t *qtvr_atom) { quicktime_qtatom_t leaf_atom, root_atom; int result = 0; quicktime_qtatom_read_container_header(file); quicktime_qtatom_read_header(file, &root_atom); do { quicktime_qtatom_read_header(file, &leaf_atom); if(quicktime_qtatom_is(&leaf_atom, "vrsc")) { result += quicktime_read_vrsc(file, &qtvr->vrsc, &leaf_atom); } else if(quicktime_qtatom_is(&leaf_atom, "imgp")) { result += quicktime_read_imgp(file, &qtvr->imgp, &leaf_atom); } else if(quicktime_qtatom_is(&leaf_atom, "vrnp")) { qtvr->vrnp.children = leaf_atom.child_count; result += quicktime_read_vrnp(file, &qtvr->vrnp, &leaf_atom); } else quicktime_qtatom_skip(file, &leaf_atom); }while(quicktime_position(file) < root_atom.end); return result; } void quicktime_write_qtvr(quicktime_t *file, quicktime_qtvr_t *qtvr ) { quicktime_qtatom_t subatom; quicktime_qtatom_write_container_header(file); quicktime_qtatom_write_header(file, &subatom, "sean", 1); subatom.child_count = 3; quicktime_write_vrsc(file, &qtvr->vrsc); quicktime_write_imgp(file, &qtvr->imgp); quicktime_write_vrnp(file, &qtvr->vrnp); quicktime_qtatom_write_footer(file, &subatom); } libquicktime-1.2.4/src/wave.c0000644000175000017500000000727411511622757013037 00000000000000/******************************************************************************* wave.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" uint8_t * quicktime_wave_get_user_atom(quicktime_trak_t * trak, char * name, uint32_t * len) { quicktime_wave_t * wave = &trak->mdia.minf.stbl.stsd.table[0].wave; return(quicktime_user_atoms_get_atom(&wave->user_atoms, name, len)); } void quicktime_wave_set_user_atom(quicktime_trak_t * trak, char * name, uint8_t * data, uint32_t len) { quicktime_wave_t * wave = &trak->mdia.minf.stbl.stsd.table[0].wave; quicktime_user_atoms_add_atom(&wave->user_atoms, name, data, len); trak->mdia.minf.stbl.stsd.table[0].has_wave = 1; } void quicktime_wave_delete(quicktime_wave_t *wave) { quicktime_user_atoms_delete(&wave->user_atoms); quicktime_esds_delete(&wave->esds); } void quicktime_read_wave(quicktime_t *file, quicktime_wave_t *wave, quicktime_atom_t *wave_atom) { quicktime_atom_t leaf_atom; do{ quicktime_atom_read_header(file, &leaf_atom); if(quicktime_atom_is(&leaf_atom, "frma")) { quicktime_read_frma(file, &wave->frma, &leaf_atom); wave->has_frma = 1; } else if(quicktime_atom_is(&leaf_atom, "enda")) { quicktime_read_enda(file, &wave->enda, &leaf_atom); wave->has_enda = 1; } else if(quicktime_atom_is(&leaf_atom, "esds")) { quicktime_read_esds(file, &wave->esds); wave->has_esds = 1; quicktime_atom_skip(file, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, (char[]){ 0x00, 0x00, 0x00, 0x00 })) { break; } else /* Add to user atoms */ { quicktime_user_atoms_read_atom(file, &wave->user_atoms, &leaf_atom); } quicktime_atom_skip(file, &leaf_atom); }while(quicktime_position(file) < wave_atom->end); } void quicktime_write_wave(quicktime_t *file, quicktime_wave_t *wave) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "wave"); if(wave->has_frma) quicktime_write_frma(file, &wave->frma); if(wave->has_esds) quicktime_write_esds(file, &wave->esds); if(wave->has_enda) quicktime_write_enda(file, &wave->enda); quicktime_write_user_atoms(file, &wave->user_atoms); quicktime_atom_write_footer(file, &atom); } void quicktime_wave_dump(quicktime_wave_t *wave) { lqt_dump(" wave: \n"); if(wave->has_frma) quicktime_frma_dump(&wave->frma); if(wave->has_enda) quicktime_enda_dump(&wave->enda); if(wave->has_esds) quicktime_esds_dump(&wave->esds); quicktime_user_atoms_dump(&wave->user_atoms); } libquicktime-1.2.4/src/hdlr.c0000644000175000017500000002067711511622756013027 00000000000000/******************************************************************************* hdlr.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include void quicktime_hdlr_init(quicktime_hdlr_t *hdlr) { hdlr->version = 0; hdlr->flags = 0; hdlr->component_type[0] = 'm'; hdlr->component_type[1] = 'h'; hdlr->component_type[2] = 'l'; hdlr->component_type[3] = 'r'; hdlr->component_subtype[0] = 'v'; hdlr->component_subtype[1] = 'i'; hdlr->component_subtype[2] = 'd'; hdlr->component_subtype[3] = 'e'; hdlr->component_manufacturer[0] = 0; hdlr->component_manufacturer[1] = 0; hdlr->component_manufacturer[2] = 0; hdlr->component_manufacturer[3] = 0; hdlr->component_flags = 0; hdlr->component_flag_mask = 0; strcpy(hdlr->component_name, "Libquicktime Media Handler"); } int quicktime_hdlr_init_qtvr(quicktime_hdlr_t *hdlr, int track_type) { switch(track_type) { case QTVR_QTVR_OBJ: case QTVR_QTVR_PAN: hdlr->component_subtype[0] = 'q'; hdlr->component_subtype[1] = 't'; hdlr->component_subtype[2] = 'v'; hdlr->component_subtype[3] = 'r'; strcpy(hdlr->component_name, "Libquicktime QTVR Handler"); break; case QTVR_OBJ: hdlr->component_subtype[0] = 'o'; hdlr->component_subtype[1] = 'b'; hdlr->component_subtype[2] = 'j'; hdlr->component_subtype[3] = 'e'; strcpy(hdlr->component_name, "Libquicktime QTVR Object Handler"); break; case QTVR_PAN: hdlr->component_subtype[0] = 'p'; hdlr->component_subtype[1] = 'a'; hdlr->component_subtype[2] = 'n'; hdlr->component_subtype[3] = 'o'; strcpy(hdlr->component_name, "Libquicktime QTVR Panorama Handler"); break; default: return -1; } return 0; } void quicktime_hdlr_init_panorama(quicktime_hdlr_t *hdlr) { hdlr->component_subtype[0] = 'S'; hdlr->component_subtype[1] = 'T'; hdlr->component_subtype[2] = 'p'; hdlr->component_subtype[3] = 'n'; strcpy(hdlr->component_name, "Libquicktime Panorama Media Handler"); } void quicktime_hdlr_init_video(quicktime_hdlr_t *hdlr) { hdlr->component_subtype[0] = 'v'; hdlr->component_subtype[1] = 'i'; hdlr->component_subtype[2] = 'd'; hdlr->component_subtype[3] = 'e'; strcpy(hdlr->component_name, "Libquicktime Video Media Handler"); } void quicktime_hdlr_init_audio(quicktime_hdlr_t *hdlr) { hdlr->component_subtype[0] = 's'; hdlr->component_subtype[1] = 'o'; hdlr->component_subtype[2] = 'u'; hdlr->component_subtype[3] = 'n'; strcpy(hdlr->component_name, "Libquicktime Sound Media Handler"); } void quicktime_hdlr_init_timecode(quicktime_hdlr_t *hdlr) { hdlr->component_subtype[0] = 't'; hdlr->component_subtype[1] = 'm'; hdlr->component_subtype[2] = 'c'; hdlr->component_subtype[3] = 'd'; strcpy(hdlr->component_name, "Libquicktime Time Code Media Handler"); } void quicktime_hdlr_init_text(quicktime_hdlr_t *hdlr) { hdlr->component_subtype[0] = 't'; hdlr->component_subtype[1] = 'e'; hdlr->component_subtype[2] = 'x'; hdlr->component_subtype[3] = 't'; strcpy(hdlr->component_name, "Libquicktime Text Media Handler"); } void quicktime_hdlr_init_tx3g(quicktime_hdlr_t *hdlr) { hdlr->component_subtype[0] = 't'; hdlr->component_subtype[1] = 'e'; hdlr->component_subtype[2] = 'x'; hdlr->component_subtype[3] = 't'; strcpy(hdlr->component_name, "Libquicktime Streaming Text Handler"); } /* hdlr->version = quicktime_read_char(file); hdlr->flags = quicktime_read_int24(file); quicktime_read_char32(file, hdlr->component_type); quicktime_read_char32(file, hdlr->component_subtype); hdlr->component_manufacturer = quicktime_read_int32(file); hdlr->component_flags = quicktime_read_int32(file); hdlr->component_flag_mask = quicktime_read_int32(file); quicktime_read_pascal(file, hdlr->component_name); */ void quicktime_hdlr_init_udta(quicktime_hdlr_t *hdlr) { hdlr->version = 0; hdlr->flags = 0; hdlr->component_type[0] = 0x00; hdlr->component_type[1] = 0x00; hdlr->component_type[2] = 0x00; hdlr->component_type[3] = 0x00; hdlr->component_subtype[0] = 'm'; hdlr->component_subtype[1] = 'd'; hdlr->component_subtype[2] = 'i'; hdlr->component_subtype[3] = 'r'; hdlr->component_manufacturer[0] = 'a'; hdlr->component_manufacturer[1] = 'p'; hdlr->component_manufacturer[2] = 'p'; hdlr->component_manufacturer[3] = 'l'; hdlr->component_flags = 0; hdlr->component_flag_mask = 0; hdlr->component_name[0] = '\0'; } void quicktime_hdlr_init_data(quicktime_hdlr_t *hdlr) { hdlr->component_type[0] = 'd'; hdlr->component_type[1] = 'h'; hdlr->component_type[2] = 'l'; hdlr->component_type[3] = 'r'; hdlr->component_subtype[0] = 'a'; hdlr->component_subtype[1] = 'l'; hdlr->component_subtype[2] = 'i'; hdlr->component_subtype[3] = 's'; strcpy(hdlr->component_name, "Linux Alias Data Handler"); } void quicktime_hdlr_delete(quicktime_hdlr_t *hdlr) { } void quicktime_hdlr_dump(quicktime_hdlr_t *hdlr) { lqt_dump(" handler reference (hdlr)\n"); lqt_dump(" version %d\n", hdlr->version); lqt_dump(" flags %ld\n", hdlr->flags); lqt_dump(" component_type %c%c%c%c\n", hdlr->component_type[0], hdlr->component_type[1], hdlr->component_type[2], hdlr->component_type[3]); lqt_dump(" component_subtype %c%c%c%c\n", hdlr->component_subtype[0], hdlr->component_subtype[1], hdlr->component_subtype[2], hdlr->component_subtype[3]); lqt_dump(" component_name %s\n", hdlr->component_name); } void quicktime_read_hdlr(quicktime_t *file, quicktime_hdlr_t *hdlr, quicktime_atom_t * parent_atom) { int component_name_len; hdlr->version = quicktime_read_char(file); hdlr->flags = quicktime_read_int24(file); quicktime_read_char32(file, hdlr->component_type); quicktime_read_char32(file, hdlr->component_subtype); quicktime_read_char32(file, hdlr->component_manufacturer); hdlr->component_flags = quicktime_read_int32(file); hdlr->component_flag_mask = quicktime_read_int32(file); /* Difference between mp4 and quicktime: In quicktime, component name is a pascal string. In mp4, it's until the end of the atom */ if(!hdlr->component_type[0] && !hdlr->component_type[1] && !hdlr->component_type[2] && !hdlr->component_type[3]) { component_name_len = parent_atom->end - quicktime_position(file); if(component_name_len > 256) component_name_len = 256; quicktime_read_data(file, (uint8_t*)hdlr->component_name, component_name_len); } else { if(quicktime_position(file) < parent_atom->end) quicktime_read_pascal(file, hdlr->component_name); } /* Main Actor doesn't write component name */ quicktime_atom_skip(file, parent_atom); } void quicktime_write_hdlr(quicktime_t *file, quicktime_hdlr_t *hdlr) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "hdlr"); quicktime_write_char(file, hdlr->version); quicktime_write_int24(file, hdlr->flags); if(IS_MP4(file->file_type)) quicktime_write_int32(file, 0); else quicktime_write_char32(file, hdlr->component_type); quicktime_write_char32(file, hdlr->component_subtype); quicktime_write_char32(file, hdlr->component_manufacturer); quicktime_write_int32(file, hdlr->component_flags); quicktime_write_int32(file, hdlr->component_flag_mask); if(IS_MP4(file->file_type)) { // quicktime_write_data(file, (uint8_t*)hdlr->component_name, strlen(hdlr->component_name)+1); quicktime_write_int16(file, 0); } else quicktime_write_pascal(file, hdlr->component_name); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/esds.c0000644000175000017500000002016411511622756013023 00000000000000/******************************************************************************* esds.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include int quicktime_read_mp4_descr_length(quicktime_t * file) { uint8_t b; int num_bytes = 0; unsigned int length = 0; do{ if(!quicktime_read_data(file, &b, 1)) return -1; num_bytes++; length = (length << 7) | (b & 0x7F); } while ((b & 0x80) && (num_bytes < 4)); return length; } void quicktime_read_esds(quicktime_t * file, quicktime_esds_t * esds) { uint8_t tag; esds->version = quicktime_read_char(file); esds->flags = quicktime_read_int24(file); quicktime_read_data(file, &tag, 1); if(tag == 0x03) { if(quicktime_read_mp4_descr_length(file) < 20) return; // elementary stream id esds->esid = quicktime_read_int16(file); // stream priority esds->stream_priority = quicktime_read_char(file); } else quicktime_read_int16(file); /* Skip 2 bytes */ quicktime_read_data(file, &tag, 1); if(tag != 0x04) return; if(quicktime_read_mp4_descr_length(file) < 15) return; quicktime_read_data(file, &esds->objectTypeId, 1); quicktime_read_data(file, &esds->streamType, 1); esds->bufferSizeDB = quicktime_read_int24(file); esds->maxBitrate = quicktime_read_int32(file); esds->avgBitrate = quicktime_read_int32(file); quicktime_read_data(file, &tag, 1); if(tag != 0x05) return; esds->decoderConfigLen = quicktime_read_mp4_descr_length(file); /* Need some padding for ffmpeg */ esds->decoderConfig = calloc(esds->decoderConfigLen+16, 1); quicktime_read_data(file, esds->decoderConfig, esds->decoderConfigLen); } int quicktime_write_mp4_descr_length(quicktime_t *file, int length, int compact) { uint8_t b; int i; int numBytes; if (compact) { if (length <= 0x7F) { numBytes = 1; } else if(length <= 0x3FFF) { numBytes = 2; } else if(length <= 0x1FFFFF) { numBytes = 3; } else { numBytes = 4; } } else { numBytes = 4; } for (i = numBytes-1; i >= 0; i--) { b = (length >> (i * 7)) & 0x7F; if (i != 0) { b |= 0x80; } quicktime_write_char(file, b); } return numBytes; } #if 1 void quicktime_write_esds(quicktime_t * file, quicktime_esds_t * esds) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "esds"); quicktime_write_char(file, 0); /* Version */ quicktime_write_int24(file, 0); /* Flags */ quicktime_write_char(file, 0x03); /* ES_DescrTag */ quicktime_write_mp4_descr_length(file, 3 + (5 + (13 + (8 + esds->decoderConfigLen))) + 3, 0); quicktime_write_int16(file, esds->esid); quicktime_write_char(file, esds->stream_priority); /* DecoderConfigDescriptor */ quicktime_write_char(file, 0x04); /* DecoderConfigDescrTag */ quicktime_write_mp4_descr_length(file, 10 + (8 + esds->decoderConfigLen), 0); quicktime_write_char(file, esds->objectTypeId); /* objectTypeIndication */ quicktime_write_char(file, esds->streamType); /* streamType */ quicktime_write_int24(file, esds->bufferSizeDB); /* buffer size */ quicktime_write_int32(file, esds->maxBitrate); /* max bitrate */ quicktime_write_int32(file, esds->avgBitrate); /* average bitrate */ quicktime_write_char(file, 0x05); /* DecSpecificInfoTag */ quicktime_write_mp4_descr_length(file, esds->decoderConfigLen, 0); quicktime_write_data(file, esds->decoderConfig, esds->decoderConfigLen); /* SLConfigDescriptor */ quicktime_write_char(file, 0x06); /* SLConfigDescrTag */ quicktime_write_mp4_descr_length(file, 1, 0); quicktime_write_char(file, 0x02); /* constant in mp4 files */ quicktime_atom_write_footer(file, &atom); } #else static unsigned int descrLength(unsigned int len) { int i; for(i=1; len>>(7*i); i++); return len + 1 + i; } static void putDescr(quicktime_t * file, int tag, unsigned int size) { int i= descrLength(size) - size - 2; quicktime_write_char(file, tag); for(; i>0; i--) quicktime_write_char(file, (size>>(7*i)) | 0x80); quicktime_write_char(file, size & 0x7F); } void quicktime_write_esds(quicktime_t * file, quicktime_esds_t * esds) { quicktime_atom_t atom; int decoderSpecificInfoLen = esds->decoderConfigLen ? descrLength(esds->decoderConfigLen):0; quicktime_atom_write_header(file, &atom, "esds"); quicktime_write_char(file, 0); /* Version */ quicktime_write_int24(file, 0); /* Flags */ // ES descriptor putDescr(file, 0x03, 3 + descrLength(13 + decoderSpecificInfoLen) + descrLength(1)); quicktime_write_int16(file, esds->esid); quicktime_write_char(file, esds->stream_priority); // DecoderConfig descriptor putDescr(file, 0x04, 13 + esds->decoderConfigLen); // Object type indication quicktime_write_char(file, esds->objectTypeId); /* objectTypeIndication */ quicktime_write_char(file, esds->streamType); /* streamType */ quicktime_write_int24(file, esds->bufferSizeDB); /* buffer size */ quicktime_write_int32(file, esds->maxBitrate); /* max bitrate */ quicktime_write_int32(file, esds->avgBitrate); /* average bitrate */ // DecoderSpecific info descriptor if(decoderSpecificInfoLen) { putDescr(file, 0x05, esds->decoderConfigLen); quicktime_write_data(file, esds->decoderConfig, esds->decoderConfigLen); } // SL descriptor putDescr(file, 0x06, 1); quicktime_write_char(file, 0x02); quicktime_atom_write_footer(file, &atom); } #endif void quicktime_esds_dump(quicktime_esds_t * esds) { int i; lqt_dump(" esds: \n"); lqt_dump(" Version: %d\n", esds->version); lqt_dump(" Flags: 0x%06lx\n", esds->flags); lqt_dump(" ES ID: 0x%04x\n", esds->esid); lqt_dump(" Priority: 0x%02x\n", esds->stream_priority); lqt_dump(" objectTypeId: %d\n", esds->objectTypeId); lqt_dump(" streamType: 0x%02x\n", esds->streamType); lqt_dump(" bufferSizeDB: %d\n", esds->bufferSizeDB); lqt_dump(" maxBitrate: %d\n", esds->maxBitrate); lqt_dump(" avgBitrate: %d\n", esds->avgBitrate); lqt_dump(" decoderConfigLen: %d\n", esds->decoderConfigLen); lqt_dump(" decoderConfig:"); for(i = 0; i < esds->decoderConfigLen; i++) { if(!(i % 16)) lqt_dump("\n "); lqt_dump("%02x ", esds->decoderConfig[i]); } lqt_dump("\n"); } void quicktime_esds_delete(quicktime_esds_t * esds) { if(esds->decoderConfig) free(esds->decoderConfig); } quicktime_esds_t * quicktime_set_esds(quicktime_trak_t * trak, const uint8_t * decoderConfig, int decoderConfigLen) { quicktime_esds_t * esds; trak->mdia.minf.stbl.stsd.table[0].has_esds = 1; esds = &trak->mdia.minf.stbl.stsd.table[0].esds; esds->decoderConfigLen = decoderConfigLen; esds->decoderConfig = malloc(esds->decoderConfigLen); memcpy(esds->decoderConfig, decoderConfig, esds->decoderConfigLen); return esds; } libquicktime-1.2.4/src/mdia.c0000644000175000017500000001377511511622756013011 00000000000000/******************************************************************************* mdia.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" void quicktime_mdia_init(quicktime_mdia_t *mdia) { quicktime_mdhd_init(&mdia->mdhd); quicktime_hdlr_init(&mdia->hdlr); quicktime_minf_init(&mdia->minf); } void quicktime_mdia_init_qtvr(quicktime_t *file, quicktime_mdia_t *mdia, int track_type, int timescale, int frame_duration) { quicktime_mdhd_init_video(file, &mdia->mdhd, timescale); quicktime_minf_init_qtvr(file, &mdia->minf, track_type, frame_duration); quicktime_hdlr_init_qtvr(&mdia->hdlr, track_type); } void quicktime_mdia_init_panorama(quicktime_t *file, quicktime_mdia_t *mdia, int width, int height, int timescale, int frame_duration) { quicktime_mdhd_init_video(file, &mdia->mdhd, timescale); quicktime_minf_init_panorama(file, &mdia->minf, width, height, frame_duration); quicktime_hdlr_init_panorama(&mdia->hdlr); } void quicktime_mdia_init_video(quicktime_t *file, quicktime_mdia_t *mdia, int frame_w, int frame_h, int frame_duration, int timescale, char *compressor) { quicktime_mdhd_init_video(file, &mdia->mdhd, timescale); quicktime_minf_init_video(file, &mdia->minf, frame_w, frame_h, frame_duration, timescale, compressor); quicktime_hdlr_init_video(&mdia->hdlr); } void quicktime_mdia_init_timecode(quicktime_t *file, quicktime_mdia_t *mdia, int time_scale, int frame_duration, int num_frames, uint32_t flags) { quicktime_mdhd_init_video(file, &mdia->mdhd, time_scale); quicktime_minf_init_timecode(file, &mdia->minf, time_scale, frame_duration, num_frames, flags); quicktime_hdlr_init_timecode(&mdia->hdlr); } void quicktime_mdia_init_audio(quicktime_t *file, quicktime_mdia_t *mdia, int channels, int sample_rate, int bits, char *compressor) { quicktime_mdhd_init_audio(file, &mdia->mdhd, sample_rate); quicktime_minf_init_audio(file, &mdia->minf, channels, sample_rate, bits, compressor); quicktime_hdlr_init_audio(&mdia->hdlr); } void quicktime_mdia_init_text(quicktime_t * file, quicktime_mdia_t * mdia, int timescale) { quicktime_hdlr_init_text(&mdia->hdlr); quicktime_mdhd_init_text(file, &mdia->mdhd, timescale); quicktime_minf_init_text(file, &mdia->minf); } void quicktime_mdia_init_tx3g(quicktime_t * file, quicktime_mdia_t * mdia, int timescale) { quicktime_hdlr_init_tx3g(&mdia->hdlr); quicktime_mdhd_init_text(file, &mdia->mdhd, timescale); quicktime_minf_init_tx3g(file, &mdia->minf); } void quicktime_mdia_delete(quicktime_mdia_t *mdia) { quicktime_mdhd_delete(&mdia->mdhd); quicktime_hdlr_delete(&mdia->hdlr); quicktime_minf_delete(&mdia->minf); } void quicktime_mdia_dump(quicktime_mdia_t *mdia) { lqt_dump(" media (mdia)\n"); quicktime_mdhd_dump(&mdia->mdhd); quicktime_hdlr_dump(&mdia->hdlr); quicktime_minf_dump(&mdia->minf); } int quicktime_read_mdia(quicktime_t *file, quicktime_trak_t *trak, quicktime_mdia_t *mdia, quicktime_atom_t *trak_atom) { quicktime_atom_t leaf_atom; do { quicktime_atom_read_header(file, &leaf_atom); /* mandatory */ if(quicktime_atom_is(&leaf_atom, "mdhd")) quicktime_read_mdhd(file, &mdia->mdhd); else if(quicktime_atom_is(&leaf_atom, "hdlr")) quicktime_read_hdlr(file, &mdia->hdlr, &leaf_atom); else if(quicktime_atom_is(&leaf_atom, "minf")) quicktime_read_minf(file, trak, &mdia->minf, &leaf_atom); else quicktime_atom_skip(file, &leaf_atom); }while(quicktime_position(file) < trak_atom->end); return 0; } void quicktime_write_mdia(quicktime_t *file, quicktime_mdia_t *mdia) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "mdia"); quicktime_write_mdhd(file, &mdia->mdhd); quicktime_write_hdlr(file, &mdia->hdlr); quicktime_write_minf(file, &mdia->minf); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/ctab.c0000644000175000017500000007104511511622756013002 00000000000000/******************************************************************************* ctab.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include int quicktime_ctab_init(quicktime_ctab_t *ctab) { ctab->seed = 0; ctab->flags = 0; ctab->size = 0; ctab->alpha = 0; ctab->red = 0; ctab->green = 0; ctab->blue = 0; return 0; } int quicktime_ctab_delete(quicktime_ctab_t *ctab) { if(ctab->alpha) free(ctab->alpha); if(ctab->red) free(ctab->red); if(ctab->green) free(ctab->green); if(ctab->blue) free(ctab->blue); return 0; } void quicktime_ctab_dump(quicktime_ctab_t *ctab) { int i; lqt_dump(" color table (ctab)\n"); lqt_dump(" seed %ld\n", ctab->seed); lqt_dump(" flags %ld\n", ctab->flags); lqt_dump(" size %ld\n", ctab->size); lqt_dump(" colors "); for(i = 0; i < ctab->size; i++) { lqt_dump("[0x%02x 0x%02x 0x%02x 0x%02x]\n", (ctab->red[i])>>8, (ctab->green[i])>>8, (ctab->blue[i])>>8, (ctab->alpha[i])>>8); } lqt_dump("\n"); } int quicktime_read_ctab(quicktime_t *file, quicktime_ctab_t *ctab) { int i; ctab->seed = quicktime_read_int32(file); ctab->flags = quicktime_read_int16(file); ctab->size = quicktime_read_int16(file) + 1; ctab->alpha = malloc(sizeof(int16_t) * ctab->size); ctab->red = malloc(sizeof(int16_t) * ctab->size); ctab->green = malloc(sizeof(int16_t) * ctab->size); ctab->blue = malloc(sizeof(int16_t) * ctab->size); for(i = 0; i < ctab->size; i++) { ctab->alpha[i] = quicktime_read_int16(file); ctab->red[i] = quicktime_read_int16(file); ctab->green[i] = quicktime_read_int16(file); ctab->blue[i] = quicktime_read_int16(file); } // quicktime_ctab_dump(ctab); return 0; } /* Added for libquicktime: Default color tables */ typedef struct { uint16_t r; uint16_t g; uint16_t b; uint16_t a; } palette_entry; static palette_entry qt_default_palette_2[] = { { 0xFFFF, 0xFFFF, 0xFFFF, 0x0000 }, { 0x0000, 0x0000, 0x0000, 0x0000 }, }; static palette_entry qt_default_palette_4[] = { { 0x9393, 0x6565, 0x5E5E, 0x0000 }, { 0xFFFF, 0xFFFF, 0xFFFF, 0x0000 }, { 0xDFDF, 0xD0D0, 0xABAB, 0x0000 }, { 0x0000, 0x0000, 0x0000, 0x0000 } }; static palette_entry qt_default_palette_16[] = { { 0xFFFF, 0xFBFB, 0xFFFF, 0x0000 }, { 0xEFEF, 0xD9D9, 0xBBBB, 0x0000 }, { 0xE8E8, 0xC9C9, 0xB1B1, 0x0000 }, { 0x9393, 0x6565, 0x5E5E, 0x0000 }, { 0xFCFC, 0xDEDE, 0xE8E8, 0x0000 }, { 0x9D9D, 0x8888, 0x9191, 0x0000 }, { 0xFFFF, 0xFFFF, 0xFFFF, 0x0000 }, { 0xFFFF, 0xFFFF, 0xFFFF, 0x0000 }, { 0xFFFF, 0xFFFF, 0xFFFF, 0x0000 }, { 0x4747, 0x4848, 0x3737, 0x0000 }, { 0x7A7A, 0x5E5E, 0x5555, 0x0000 }, { 0xDFDF, 0xD0D0, 0xABAB, 0x0000 }, { 0xFFFF, 0xFBFB, 0xF9F9, 0x0000 }, { 0xE8E8, 0xCACA, 0xC5C5, 0x0000 }, { 0x8A8A, 0x7C7C, 0x7777, 0x0000 }, { 0x0000, 0x0000, 0x0000, 0x0000 } }; static palette_entry qt_default_palette_256[256] = { /* 0, 0x00 */ { 0xFFFF, 0xFFFF, 0xFFFF, 0x0000 }, /* 1, 0x01 */ { 0xFFFF, 0xFFFF, 0xCCCC, 0x0000 }, /* 2, 0x02 */ { 0xFFFF, 0xFFFF, 0x9999, 0x0000 }, /* 3, 0x03 */ { 0xFFFF, 0xFFFF, 0x6666, 0x0000 }, /* 4, 0x04 */ { 0xFFFF, 0xFFFF, 0x3333, 0x0000 }, /* 5, 0x05 */ { 0xFFFF, 0xFFFF, 0x0000, 0x0000 }, /* 6, 0x06 */ { 0xFFFF, 0xCCCC, 0xFFFF, 0x0000 }, /* 7, 0x07 */ { 0xFFFF, 0xCCCC, 0xCCCC, 0x0000 }, /* 8, 0x08 */ { 0xFFFF, 0xCCCC, 0x9999, 0x0000 }, /* 9, 0x09 */ { 0xFFFF, 0xCCCC, 0x6666, 0x0000 }, /* 10, 0x0A */ { 0xFFFF, 0xCCCC, 0x3333, 0x0000 }, /* 11, 0x0B */ { 0xFFFF, 0xCCCC, 0x0000, 0x0000 }, /* 12, 0x0C */ { 0xFFFF, 0x9999, 0xFFFF, 0x0000 }, /* 13, 0x0D */ { 0xFFFF, 0x9999, 0xCCCC, 0x0000 }, /* 14, 0x0E */ { 0xFFFF, 0x9999, 0x9999, 0x0000 }, /* 15, 0x0F */ { 0xFFFF, 0x9999, 0x6666, 0x0000 }, /* 16, 0x10 */ { 0xFFFF, 0x9999, 0x3333, 0x0000 }, /* 17, 0x11 */ { 0xFFFF, 0x9999, 0x0000, 0x0000 }, /* 18, 0x12 */ { 0xFFFF, 0x6666, 0xFFFF, 0x0000 }, /* 19, 0x13 */ { 0xFFFF, 0x6666, 0xCCCC, 0x0000 }, /* 20, 0x14 */ { 0xFFFF, 0x6666, 0x9999, 0x0000 }, /* 21, 0x15 */ { 0xFFFF, 0x6666, 0x6666, 0x0000 }, /* 22, 0x16 */ { 0xFFFF, 0x6666, 0x3333, 0x0000 }, /* 23, 0x17 */ { 0xFFFF, 0x6666, 0x0000, 0x0000 }, /* 24, 0x18 */ { 0xFFFF, 0x3333, 0xFFFF, 0x0000 }, /* 25, 0x19 */ { 0xFFFF, 0x3333, 0xCCCC, 0x0000 }, /* 26, 0x1A */ { 0xFFFF, 0x3333, 0x9999, 0x0000 }, /* 27, 0x1B */ { 0xFFFF, 0x3333, 0x6666, 0x0000 }, /* 28, 0x1C */ { 0xFFFF, 0x3333, 0x3333, 0x0000 }, /* 29, 0x1D */ { 0xFFFF, 0x3333, 0x0000, 0x0000 }, /* 30, 0x1E */ { 0xFFFF, 0x0000, 0xFFFF, 0x0000 }, /* 31, 0x1F */ { 0xFFFF, 0x0000, 0xCCCC, 0x0000 }, /* 32, 0x20 */ { 0xFFFF, 0x0000, 0x9999, 0x0000 }, /* 33, 0x21 */ { 0xFFFF, 0x0000, 0x6666, 0x0000 }, /* 34, 0x22 */ { 0xFFFF, 0x0000, 0x3333, 0x0000 }, /* 35, 0x23 */ { 0xFFFF, 0x0000, 0x0000, 0x0000 }, /* 36, 0x24 */ { 0xCCCC, 0xFFFF, 0xFFFF, 0x0000 }, /* 37, 0x25 */ { 0xCCCC, 0xFFFF, 0xCCCC, 0x0000 }, /* 38, 0x26 */ { 0xCCCC, 0xFFFF, 0x9999, 0x0000 }, /* 39, 0x27 */ { 0xCCCC, 0xFFFF, 0x6666, 0x0000 }, /* 40, 0x28 */ { 0xCCCC, 0xFFFF, 0x3333, 0x0000 }, /* 41, 0x29 */ { 0xCCCC, 0xFFFF, 0x0000, 0x0000 }, /* 42, 0x2A */ { 0xCCCC, 0xCCCC, 0xFFFF, 0x0000 }, /* 43, 0x2B */ { 0xCCCC, 0xCCCC, 0xCCCC, 0x0000 }, /* 44, 0x2C */ { 0xCCCC, 0xCCCC, 0x9999, 0x0000 }, /* 45, 0x2D */ { 0xCCCC, 0xCCCC, 0x6666, 0x0000 }, /* 46, 0x2E */ { 0xCCCC, 0xCCCC, 0x3333, 0x0000 }, /* 47, 0x2F */ { 0xCCCC, 0xCCCC, 0x0000, 0x0000 }, /* 48, 0x30 */ { 0xCCCC, 0x9999, 0xFFFF, 0x0000 }, /* 49, 0x31 */ { 0xCCCC, 0x9999, 0xCCCC, 0x0000 }, /* 50, 0x32 */ { 0xCCCC, 0x9999, 0x9999, 0x0000 }, /* 51, 0x33 */ { 0xCCCC, 0x9999, 0x6666, 0x0000 }, /* 52, 0x34 */ { 0xCCCC, 0x9999, 0x3333, 0x0000 }, /* 53, 0x35 */ { 0xCCCC, 0x9999, 0x0000, 0x0000 }, /* 54, 0x36 */ { 0xCCCC, 0x6666, 0xFFFF, 0x0000 }, /* 55, 0x37 */ { 0xCCCC, 0x6666, 0xCCCC, 0x0000 }, /* 56, 0x38 */ { 0xCCCC, 0x6666, 0x9999, 0x0000 }, /* 57, 0x39 */ { 0xCCCC, 0x6666, 0x6666, 0x0000 }, /* 58, 0x3A */ { 0xCCCC, 0x6666, 0x3333, 0x0000 }, /* 59, 0x3B */ { 0xCCCC, 0x6666, 0x0000, 0x0000 }, /* 60, 0x3C */ { 0xCCCC, 0x3333, 0xFFFF, 0x0000 }, /* 61, 0x3D */ { 0xCCCC, 0x3333, 0xCCCC, 0x0000 }, /* 62, 0x3E */ { 0xCCCC, 0x3333, 0x9999, 0x0000 }, /* 63, 0x3F */ { 0xCCCC, 0x3333, 0x6666, 0x0000 }, /* 64, 0x40 */ { 0xCCCC, 0x3333, 0x3333, 0x0000 }, /* 65, 0x41 */ { 0xCCCC, 0x3333, 0x0000, 0x0000 }, /* 66, 0x42 */ { 0xCCCC, 0x0000, 0xFFFF, 0x0000 }, /* 67, 0x43 */ { 0xCCCC, 0x0000, 0xCCCC, 0x0000 }, /* 68, 0x44 */ { 0xCCCC, 0x0000, 0x9999, 0x0000 }, /* 69, 0x45 */ { 0xCCCC, 0x0000, 0x6666, 0x0000 }, /* 70, 0x46 */ { 0xCCCC, 0x0000, 0x3333, 0x0000 }, /* 71, 0x47 */ { 0xCCCC, 0x0000, 0x0000, 0x0000 }, /* 72, 0x48 */ { 0x9999, 0xFFFF, 0xFFFF, 0x0000 }, /* 73, 0x49 */ { 0x9999, 0xFFFF, 0xCCCC, 0x0000 }, /* 74, 0x4A */ { 0x9999, 0xFFFF, 0x9999, 0x0000 }, /* 75, 0x4B */ { 0x9999, 0xFFFF, 0x6666, 0x0000 }, /* 76, 0x4C */ { 0x9999, 0xFFFF, 0x3333, 0x0000 }, /* 77, 0x4D */ { 0x9999, 0xFFFF, 0x0000, 0x0000 }, /* 78, 0x4E */ { 0x9999, 0xCCCC, 0xFFFF, 0x0000 }, /* 79, 0x4F */ { 0x9999, 0xCCCC, 0xCCCC, 0x0000 }, /* 80, 0x50 */ { 0x9999, 0xCCCC, 0x9999, 0x0000 }, /* 81, 0x51 */ { 0x9999, 0xCCCC, 0x6666, 0x0000 }, /* 82, 0x52 */ { 0x9999, 0xCCCC, 0x3333, 0x0000 }, /* 83, 0x53 */ { 0x9999, 0xCCCC, 0x0000, 0x0000 }, /* 84, 0x54 */ { 0x9999, 0x9999, 0xFFFF, 0x0000 }, /* 85, 0x55 */ { 0x9999, 0x9999, 0xCCCC, 0x0000 }, /* 86, 0x56 */ { 0x9999, 0x9999, 0x9999, 0x0000 }, /* 87, 0x57 */ { 0x9999, 0x9999, 0x6666, 0x0000 }, /* 88, 0x58 */ { 0x9999, 0x9999, 0x3333, 0x0000 }, /* 89, 0x59 */ { 0x9999, 0x9999, 0x0000, 0x0000 }, /* 90, 0x5A */ { 0x9999, 0x6666, 0xFFFF, 0x0000 }, /* 91, 0x5B */ { 0x9999, 0x6666, 0xCCCC, 0x0000 }, /* 92, 0x5C */ { 0x9999, 0x6666, 0x9999, 0x0000 }, /* 93, 0x5D */ { 0x9999, 0x6666, 0x6666, 0x0000 }, /* 94, 0x5E */ { 0x9999, 0x6666, 0x3333, 0x0000 }, /* 95, 0x5F */ { 0x9999, 0x6666, 0x0000, 0x0000 }, /* 96, 0x60 */ { 0x9999, 0x3333, 0xFFFF, 0x0000 }, /* 97, 0x61 */ { 0x9999, 0x3333, 0xCCCC, 0x0000 }, /* 98, 0x62 */ { 0x9999, 0x3333, 0x9999, 0x0000 }, /* 99, 0x63 */ { 0x9999, 0x3333, 0x6666, 0x0000 }, /* 100, 0x64 */ { 0x9999, 0x3333, 0x3333, 0x0000 }, /* 101, 0x65 */ { 0x9999, 0x3333, 0x0000, 0x0000 }, /* 102, 0x66 */ { 0x9999, 0x0000, 0xFFFF, 0x0000 }, /* 103, 0x67 */ { 0x9999, 0x0000, 0xCCCC, 0x0000 }, /* 104, 0x68 */ { 0x9999, 0x0000, 0x9999, 0x0000 }, /* 105, 0x69 */ { 0x9999, 0x0000, 0x6666, 0x0000 }, /* 106, 0x6A */ { 0x9999, 0x0000, 0x3333, 0x0000 }, /* 107, 0x6B */ { 0x9999, 0x0000, 0x0000, 0x0000 }, /* 108, 0x6C */ { 0x6666, 0xFFFF, 0xFFFF, 0x0000 }, /* 109, 0x6D */ { 0x6666, 0xFFFF, 0xCCCC, 0x0000 }, /* 110, 0x6E */ { 0x6666, 0xFFFF, 0x9999, 0x0000 }, /* 111, 0x6F */ { 0x6666, 0xFFFF, 0x6666, 0x0000 }, /* 112, 0x70 */ { 0x6666, 0xFFFF, 0x3333, 0x0000 }, /* 113, 0x71 */ { 0x6666, 0xFFFF, 0x0000, 0x0000 }, /* 114, 0x72 */ { 0x6666, 0xCCCC, 0xFFFF, 0x0000 }, /* 115, 0x73 */ { 0x6666, 0xCCCC, 0xCCCC, 0x0000 }, /* 116, 0x74 */ { 0x6666, 0xCCCC, 0x9999, 0x0000 }, /* 117, 0x75 */ { 0x6666, 0xCCCC, 0x6666, 0x0000 }, /* 118, 0x76 */ { 0x6666, 0xCCCC, 0x3333, 0x0000 }, /* 119, 0x77 */ { 0x6666, 0xCCCC, 0x0000, 0x0000 }, /* 120, 0x78 */ { 0x6666, 0x9999, 0xFFFF, 0x0000 }, /* 121, 0x79 */ { 0x6666, 0x9999, 0xCCCC, 0x0000 }, /* 122, 0x7A */ { 0x6666, 0x9999, 0x9999, 0x0000 }, /* 123, 0x7B */ { 0x6666, 0x9999, 0x6666, 0x0000 }, /* 124, 0x7C */ { 0x6666, 0x9999, 0x3333, 0x0000 }, /* 125, 0x7D */ { 0x6666, 0x9999, 0x0000, 0x0000 }, /* 126, 0x7E */ { 0x6666, 0x6666, 0xFFFF, 0x0000 }, /* 127, 0x7F */ { 0x6666, 0x6666, 0xCCCC, 0x0000 }, /* 128, 0x80 */ { 0x6666, 0x6666, 0x9999, 0x0000 }, /* 129, 0x81 */ { 0x6666, 0x6666, 0x6666, 0x0000 }, /* 130, 0x82 */ { 0x6666, 0x6666, 0x3333, 0x0000 }, /* 131, 0x83 */ { 0x6666, 0x6666, 0x0000, 0x0000 }, /* 132, 0x84 */ { 0x6666, 0x3333, 0xFFFF, 0x0000 }, /* 133, 0x85 */ { 0x6666, 0x3333, 0xCCCC, 0x0000 }, /* 134, 0x86 */ { 0x6666, 0x3333, 0x9999, 0x0000 }, /* 135, 0x87 */ { 0x6666, 0x3333, 0x6666, 0x0000 }, /* 136, 0x88 */ { 0x6666, 0x3333, 0x3333, 0x0000 }, /* 137, 0x89 */ { 0x6666, 0x3333, 0x0000, 0x0000 }, /* 138, 0x8A */ { 0x6666, 0x0000, 0xFFFF, 0x0000 }, /* 139, 0x8B */ { 0x6666, 0x0000, 0xCCCC, 0x0000 }, /* 140, 0x8C */ { 0x6666, 0x0000, 0x9999, 0x0000 }, /* 141, 0x8D */ { 0x6666, 0x0000, 0x6666, 0x0000 }, /* 142, 0x8E */ { 0x6666, 0x0000, 0x3333, 0x0000 }, /* 143, 0x8F */ { 0x6666, 0x0000, 0x0000, 0x0000 }, /* 144, 0x90 */ { 0x3333, 0xFFFF, 0xFFFF, 0x0000 }, /* 145, 0x91 */ { 0x3333, 0xFFFF, 0xCCCC, 0x0000 }, /* 146, 0x92 */ { 0x3333, 0xFFFF, 0x9999, 0x0000 }, /* 147, 0x93 */ { 0x3333, 0xFFFF, 0x6666, 0x0000 }, /* 148, 0x94 */ { 0x3333, 0xFFFF, 0x3333, 0x0000 }, /* 149, 0x95 */ { 0x3333, 0xFFFF, 0x0000, 0x0000 }, /* 150, 0x96 */ { 0x3333, 0xCCCC, 0xFFFF, 0x0000 }, /* 151, 0x97 */ { 0x3333, 0xCCCC, 0xCCCC, 0x0000 }, /* 152, 0x98 */ { 0x3333, 0xCCCC, 0x9999, 0x0000 }, /* 153, 0x99 */ { 0x3333, 0xCCCC, 0x6666, 0x0000 }, /* 154, 0x9A */ { 0x3333, 0xCCCC, 0x3333, 0x0000 }, /* 155, 0x9B */ { 0x3333, 0xCCCC, 0x0000, 0x0000 }, /* 156, 0x9C */ { 0x3333, 0x9999, 0xFFFF, 0x0000 }, /* 157, 0x9D */ { 0x3333, 0x9999, 0xCCCC, 0x0000 }, /* 158, 0x9E */ { 0x3333, 0x9999, 0x9999, 0x0000 }, /* 159, 0x9F */ { 0x3333, 0x9999, 0x6666, 0x0000 }, /* 160, 0xA0 */ { 0x3333, 0x9999, 0x3333, 0x0000 }, /* 161, 0xA1 */ { 0x3333, 0x9999, 0x0000, 0x0000 }, /* 162, 0xA2 */ { 0x3333, 0x6666, 0xFFFF, 0x0000 }, /* 163, 0xA3 */ { 0x3333, 0x6666, 0xCCCC, 0x0000 }, /* 164, 0xA4 */ { 0x3333, 0x6666, 0x9999, 0x0000 }, /* 165, 0xA5 */ { 0x3333, 0x6666, 0x6666, 0x0000 }, /* 166, 0xA6 */ { 0x3333, 0x6666, 0x3333, 0x0000 }, /* 167, 0xA7 */ { 0x3333, 0x6666, 0x0000, 0x0000 }, /* 168, 0xA8 */ { 0x3333, 0x3333, 0xFFFF, 0x0000 }, /* 169, 0xA9 */ { 0x3333, 0x3333, 0xCCCC, 0x0000 }, /* 170, 0xAA */ { 0x3333, 0x3333, 0x9999, 0x0000 }, /* 171, 0xAB */ { 0x3333, 0x3333, 0x6666, 0x0000 }, /* 172, 0xAC */ { 0x3333, 0x3333, 0x3333, 0x0000 }, /* 173, 0xAD */ { 0x3333, 0x3333, 0x0000, 0x0000 }, /* 174, 0xAE */ { 0x3333, 0x0000, 0xFFFF, 0x0000 }, /* 175, 0xAF */ { 0x3333, 0x0000, 0xCCCC, 0x0000 }, /* 176, 0xB0 */ { 0x3333, 0x0000, 0x9999, 0x0000 }, /* 177, 0xB1 */ { 0x3333, 0x0000, 0x6666, 0x0000 }, /* 178, 0xB2 */ { 0x3333, 0x0000, 0x3333, 0x0000 }, /* 179, 0xB3 */ { 0x3333, 0x0000, 0x0000, 0x0000 }, /* 180, 0xB4 */ { 0x0000, 0xFFFF, 0xFFFF, 0x0000 }, /* 181, 0xB5 */ { 0x0000, 0xFFFF, 0xCCCC, 0x0000 }, /* 182, 0xB6 */ { 0x0000, 0xFFFF, 0x9999, 0x0000 }, /* 183, 0xB7 */ { 0x0000, 0xFFFF, 0x6666, 0x0000 }, /* 184, 0xB8 */ { 0x0000, 0xFFFF, 0x3333, 0x0000 }, /* 185, 0xB9 */ { 0x0000, 0xFFFF, 0x0000, 0x0000 }, /* 186, 0xBA */ { 0x0000, 0xCCCC, 0xFFFF, 0x0000 }, /* 187, 0xBB */ { 0x0000, 0xCCCC, 0xCCCC, 0x0000 }, /* 188, 0xBC */ { 0x0000, 0xCCCC, 0x9999, 0x0000 }, /* 189, 0xBD */ { 0x0000, 0xCCCC, 0x6666, 0x0000 }, /* 190, 0xBE */ { 0x0000, 0xCCCC, 0x3333, 0x0000 }, /* 191, 0xBF */ { 0x0000, 0xCCCC, 0x0000, 0x0000 }, /* 192, 0xC0 */ { 0x0000, 0x9999, 0xFFFF, 0x0000 }, /* 193, 0xC1 */ { 0x0000, 0x9999, 0xCCCC, 0x0000 }, /* 194, 0xC2 */ { 0x0000, 0x9999, 0x9999, 0x0000 }, /* 195, 0xC3 */ { 0x0000, 0x9999, 0x6666, 0x0000 }, /* 196, 0xC4 */ { 0x0000, 0x9999, 0x3333, 0x0000 }, /* 197, 0xC5 */ { 0x0000, 0x9999, 0x0000, 0x0000 }, /* 198, 0xC6 */ { 0x0000, 0x6666, 0xFFFF, 0x0000 }, /* 199, 0xC7 */ { 0x0000, 0x6666, 0xCCCC, 0x0000 }, /* 200, 0xC8 */ { 0x0000, 0x6666, 0x9999, 0x0000 }, /* 201, 0xC9 */ { 0x0000, 0x6666, 0x6666, 0x0000 }, /* 202, 0xCA */ { 0x0000, 0x6666, 0x3333, 0x0000 }, /* 203, 0xCB */ { 0x0000, 0x6666, 0x0000, 0x0000 }, /* 204, 0xCC */ { 0x0000, 0x3333, 0xFFFF, 0x0000 }, /* 205, 0xCD */ { 0x0000, 0x3333, 0xCCCC, 0x0000 }, /* 206, 0xCE */ { 0x0000, 0x3333, 0x9999, 0x0000 }, /* 207, 0xCF */ { 0x0000, 0x3333, 0x6666, 0x0000 }, /* 208, 0xD0 */ { 0x0000, 0x3333, 0x3333, 0x0000 }, /* 209, 0xD1 */ { 0x0000, 0x3333, 0x0000, 0x0000 }, /* 210, 0xD2 */ { 0x0000, 0x0000, 0xFFFF, 0x0000 }, /* 211, 0xD3 */ { 0x0000, 0x0000, 0xCCCC, 0x0000 }, /* 212, 0xD4 */ { 0x0000, 0x0000, 0x9999, 0x0000 }, /* 213, 0xD5 */ { 0x0000, 0x0000, 0x6666, 0x0000 }, /* 214, 0xD6 */ { 0x0000, 0x0000, 0x3333, 0x0000 }, /* 215, 0xD7 */ { 0xEEEE, 0x0000, 0x0000, 0x0000 }, /* 216, 0xD8 */ { 0xDDDD, 0x0000, 0x0000, 0x0000 }, /* 217, 0xD9 */ { 0xBBBB, 0x0000, 0x0000, 0x0000 }, /* 218, 0xDA */ { 0xAAAA, 0x0000, 0x0000, 0x0000 }, /* 219, 0xDB */ { 0x8888, 0x0000, 0x0000, 0x0000 }, /* 220, 0xDC */ { 0x7777, 0x0000, 0x0000, 0x0000 }, /* 221, 0xDD */ { 0x5555, 0x0000, 0x0000, 0x0000 }, /* 222, 0xDE */ { 0x4444, 0x0000, 0x0000, 0x0000 }, /* 223, 0xDF */ { 0x2222, 0x0000, 0x0000, 0x0000 }, /* 224, 0xE0 */ { 0x1111, 0x0000, 0x0000, 0x0000 }, /* 225, 0xE1 */ { 0x0000, 0xEEEE, 0x0000, 0x0000 }, /* 226, 0xE2 */ { 0x0000, 0xDDDD, 0x0000, 0x0000 }, /* 227, 0xE3 */ { 0x0000, 0xBBBB, 0x0000, 0x0000 }, /* 228, 0xE4 */ { 0x0000, 0xAAAA, 0x0000, 0x0000 }, /* 229, 0xE5 */ { 0x0000, 0x8888, 0x0000, 0x0000 }, /* 230, 0xE6 */ { 0x0000, 0x7777, 0x0000, 0x0000 }, /* 231, 0xE7 */ { 0x0000, 0x5555, 0x0000, 0x0000 }, /* 232, 0xE8 */ { 0x0000, 0x4444, 0x0000, 0x0000 }, /* 233, 0xE9 */ { 0x0000, 0x2222, 0x0000, 0x0000 }, /* 234, 0xEA */ { 0x0000, 0x1111, 0x0000, 0x0000 }, /* 235, 0xEB */ { 0x0000, 0x0000, 0xEEEE, 0x0000 }, /* 236, 0xEC */ { 0x0000, 0x0000, 0xDDDD, 0x0000 }, /* 237, 0xED */ { 0x0000, 0x0000, 0xBBBB, 0x0000 }, /* 238, 0xEE */ { 0x0000, 0x0000, 0xAAAA, 0x0000 }, /* 239, 0xEF */ { 0x0000, 0x0000, 0x8888, 0x0000 }, /* 240, 0xF0 */ { 0x0000, 0x0000, 0x7777, 0x0000 }, /* 241, 0xF1 */ { 0x0000, 0x0000, 0x5555, 0x0000 }, /* 242, 0xF2 */ { 0x0000, 0x0000, 0x4444, 0x0000 }, /* 243, 0xF3 */ { 0x0000, 0x0000, 0x2222, 0x0000 }, /* 244, 0xF4 */ { 0x0000, 0x0000, 0x1111, 0x0000 }, /* 245, 0xF5 */ { 0xEEEE, 0xEEEE, 0xEEEE, 0x0000 }, /* 246, 0xF6 */ { 0xDDDD, 0xDDDD, 0xDDDD, 0x0000 }, /* 247, 0xF7 */ { 0xBBBB, 0xBBBB, 0xBBBB, 0x0000 }, /* 248, 0xF8 */ { 0xAAAA, 0xAAAA, 0xAAAA, 0x0000 }, /* 249, 0xF9 */ { 0x8888, 0x8888, 0x8888, 0x0000 }, /* 250, 0xFA */ { 0x7777, 0x7777, 0x7777, 0x0000 }, /* 251, 0xFB */ { 0x5555, 0x5555, 0x5555, 0x0000 }, /* 252, 0xFC */ { 0x4444, 0x4444, 0x4444, 0x0000 }, /* 253, 0xFD */ { 0x2222, 0x2222, 0x2222, 0x0000 }, /* 254, 0xFE */ { 0x1111, 0x1111, 0x1111, 0x0000 }, /* 255, 0xFF */ { 0x0000, 0x0000, 0x0000, 0x0000 } }; palette_entry qt_default_palette_4_gray[] = { { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF }, { 0xAAAA, 0xAAAA, 0xAAAA, 0xFFFF }, { 0x5555, 0x5555, 0x5555, 0xFFFF }, { 0x0000, 0x0000, 0x0000, 0xFFFF }, }; palette_entry qt_default_palette_16_gray[] = { { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF }, { 0xEEEE, 0xEEEE, 0xEEEE, 0xFFFF }, { 0xDDDD, 0xDDDD, 0xDDDD, 0xFFFF }, { 0xCCCC, 0xCCCC, 0xCCCC, 0xFFFF }, { 0xBBBB, 0xBBBB, 0xBBBB, 0xFFFF }, { 0xAAAA, 0xAAAA, 0xAAAA, 0xFFFF }, { 0x9999, 0x9999, 0x9999, 0xFFFF }, { 0x8888, 0x8888, 0x8888, 0xFFFF }, { 0x7777, 0x7777, 0x7777, 0xFFFF }, { 0x6666, 0x6666, 0x6666, 0xFFFF }, { 0x5555, 0x5555, 0x5555, 0xFFFF }, { 0x4444, 0x4444, 0x4444, 0xFFFF }, { 0x3333, 0x3333, 0x3333, 0xFFFF }, { 0x2222, 0x2222, 0x2222, 0xFFFF }, { 0x1111, 0x1111, 0x1111, 0xFFFF }, { 0x0000, 0x0000, 0x0000, 0xFFFF }, }; palette_entry qt_default_palette_256_gray[] = { { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF }, { 0xFEFE, 0xFEFE, 0xFEFE, 0xFFFF }, { 0xFDFD, 0xFDFD, 0xFDFD, 0xFFFF }, { 0xFCFC, 0xFCFC, 0xFCFC, 0xFFFF }, { 0xFBFB, 0xFBFB, 0xFBFB, 0xFFFF }, { 0xFAFA, 0xFAFA, 0xFAFA, 0xFFFF }, { 0xF9F9, 0xF9F9, 0xF9F9, 0xFFFF }, { 0xF8F8, 0xF8F8, 0xF8F8, 0xFFFF }, { 0xF7F7, 0xF7F7, 0xF7F7, 0xFFFF }, { 0xF6F6, 0xF6F6, 0xF6F6, 0xFFFF }, { 0xF5F5, 0xF5F5, 0xF5F5, 0xFFFF }, { 0xF4F4, 0xF4F4, 0xF4F4, 0xFFFF }, { 0xF3F3, 0xF3F3, 0xF3F3, 0xFFFF }, { 0xF2F2, 0xF2F2, 0xF2F2, 0xFFFF }, { 0xF1F1, 0xF1F1, 0xF1F1, 0xFFFF }, { 0xF0F0, 0xF0F0, 0xF0F0, 0xFFFF }, { 0xEFEF, 0xEFEF, 0xEFEF, 0xFFFF }, { 0xEEEE, 0xEEEE, 0xEEEE, 0xFFFF }, { 0xEDED, 0xEDED, 0xEDED, 0xFFFF }, { 0xECEC, 0xECEC, 0xECEC, 0xFFFF }, { 0xEBEB, 0xEBEB, 0xEBEB, 0xFFFF }, { 0xEAEA, 0xEAEA, 0xEAEA, 0xFFFF }, { 0xE9E9, 0xE9E9, 0xE9E9, 0xFFFF }, { 0xE8E8, 0xE8E8, 0xE8E8, 0xFFFF }, { 0xE7E7, 0xE7E7, 0xE7E7, 0xFFFF }, { 0xE6E6, 0xE6E6, 0xE6E6, 0xFFFF }, { 0xE5E5, 0xE5E5, 0xE5E5, 0xFFFF }, { 0xE4E4, 0xE4E4, 0xE4E4, 0xFFFF }, { 0xE3E3, 0xE3E3, 0xE3E3, 0xFFFF }, { 0xE2E2, 0xE2E2, 0xE2E2, 0xFFFF }, { 0xE1E1, 0xE1E1, 0xE1E1, 0xFFFF }, { 0xE0E0, 0xE0E0, 0xE0E0, 0xFFFF }, { 0xDFDF, 0xDFDF, 0xDFDF, 0xFFFF }, { 0xDEDE, 0xDEDE, 0xDEDE, 0xFFFF }, { 0xDDDD, 0xDDDD, 0xDDDD, 0xFFFF }, { 0xDCDC, 0xDCDC, 0xDCDC, 0xFFFF }, { 0xDBDB, 0xDBDB, 0xDBDB, 0xFFFF }, { 0xDADA, 0xDADA, 0xDADA, 0xFFFF }, { 0xD9D9, 0xD9D9, 0xD9D9, 0xFFFF }, { 0xD8D8, 0xD8D8, 0xD8D8, 0xFFFF }, { 0xD7D7, 0xD7D7, 0xD7D7, 0xFFFF }, { 0xD6D6, 0xD6D6, 0xD6D6, 0xFFFF }, { 0xD5D5, 0xD5D5, 0xD5D5, 0xFFFF }, { 0xD4D4, 0xD4D4, 0xD4D4, 0xFFFF }, { 0xD3D3, 0xD3D3, 0xD3D3, 0xFFFF }, { 0xD2D2, 0xD2D2, 0xD2D2, 0xFFFF }, { 0xD1D1, 0xD1D1, 0xD1D1, 0xFFFF }, { 0xD0D0, 0xD0D0, 0xD0D0, 0xFFFF }, { 0xCFCF, 0xCFCF, 0xCFCF, 0xFFFF }, { 0xCECE, 0xCECE, 0xCECE, 0xFFFF }, { 0xCDCD, 0xCDCD, 0xCDCD, 0xFFFF }, { 0xCCCC, 0xCCCC, 0xCCCC, 0xFFFF }, { 0xCBCB, 0xCBCB, 0xCBCB, 0xFFFF }, { 0xCACA, 0xCACA, 0xCACA, 0xFFFF }, { 0xC9C9, 0xC9C9, 0xC9C9, 0xFFFF }, { 0xC8C8, 0xC8C8, 0xC8C8, 0xFFFF }, { 0xC7C7, 0xC7C7, 0xC7C7, 0xFFFF }, { 0xC6C6, 0xC6C6, 0xC6C6, 0xFFFF }, { 0xC5C5, 0xC5C5, 0xC5C5, 0xFFFF }, { 0xC4C4, 0xC4C4, 0xC4C4, 0xFFFF }, { 0xC3C3, 0xC3C3, 0xC3C3, 0xFFFF }, { 0xC2C2, 0xC2C2, 0xC2C2, 0xFFFF }, { 0xC1C1, 0xC1C1, 0xC1C1, 0xFFFF }, { 0xC0C0, 0xC0C0, 0xC0C0, 0xFFFF }, { 0xBFBF, 0xBFBF, 0xBFBF, 0xFFFF }, { 0xBEBE, 0xBEBE, 0xBEBE, 0xFFFF }, { 0xBDBD, 0xBDBD, 0xBDBD, 0xFFFF }, { 0xBCBC, 0xBCBC, 0xBCBC, 0xFFFF }, { 0xBBBB, 0xBBBB, 0xBBBB, 0xFFFF }, { 0xBABA, 0xBABA, 0xBABA, 0xFFFF }, { 0xB9B9, 0xB9B9, 0xB9B9, 0xFFFF }, { 0xB8B8, 0xB8B8, 0xB8B8, 0xFFFF }, { 0xB7B7, 0xB7B7, 0xB7B7, 0xFFFF }, { 0xB6B6, 0xB6B6, 0xB6B6, 0xFFFF }, { 0xB5B5, 0xB5B5, 0xB5B5, 0xFFFF }, { 0xB4B4, 0xB4B4, 0xB4B4, 0xFFFF }, { 0xB3B3, 0xB3B3, 0xB3B3, 0xFFFF }, { 0xB2B2, 0xB2B2, 0xB2B2, 0xFFFF }, { 0xB1B1, 0xB1B1, 0xB1B1, 0xFFFF }, { 0xB0B0, 0xB0B0, 0xB0B0, 0xFFFF }, { 0xAFAF, 0xAFAF, 0xAFAF, 0xFFFF }, { 0xAEAE, 0xAEAE, 0xAEAE, 0xFFFF }, { 0xADAD, 0xADAD, 0xADAD, 0xFFFF }, { 0xACAC, 0xACAC, 0xACAC, 0xFFFF }, { 0xABAB, 0xABAB, 0xABAB, 0xFFFF }, { 0xAAAA, 0xAAAA, 0xAAAA, 0xFFFF }, { 0xA9A9, 0xA9A9, 0xA9A9, 0xFFFF }, { 0xA8A8, 0xA8A8, 0xA8A8, 0xFFFF }, { 0xA7A7, 0xA7A7, 0xA7A7, 0xFFFF }, { 0xA6A6, 0xA6A6, 0xA6A6, 0xFFFF }, { 0xA5A5, 0xA5A5, 0xA5A5, 0xFFFF }, { 0xA4A4, 0xA4A4, 0xA4A4, 0xFFFF }, { 0xA3A3, 0xA3A3, 0xA3A3, 0xFFFF }, { 0xA2A2, 0xA2A2, 0xA2A2, 0xFFFF }, { 0xA1A1, 0xA1A1, 0xA1A1, 0xFFFF }, { 0xA0A0, 0xA0A0, 0xA0A0, 0xFFFF }, { 0x9F9F, 0x9F9F, 0x9F9F, 0xFFFF }, { 0x9E9E, 0x9E9E, 0x9E9E, 0xFFFF }, { 0x9D9D, 0x9D9D, 0x9D9D, 0xFFFF }, { 0x9C9C, 0x9C9C, 0x9C9C, 0xFFFF }, { 0x9B9B, 0x9B9B, 0x9B9B, 0xFFFF }, { 0x9A9A, 0x9A9A, 0x9A9A, 0xFFFF }, { 0x9999, 0x9999, 0x9999, 0xFFFF }, { 0x9898, 0x9898, 0x9898, 0xFFFF }, { 0x9797, 0x9797, 0x9797, 0xFFFF }, { 0x9696, 0x9696, 0x9696, 0xFFFF }, { 0x9595, 0x9595, 0x9595, 0xFFFF }, { 0x9494, 0x9494, 0x9494, 0xFFFF }, { 0x9393, 0x9393, 0x9393, 0xFFFF }, { 0x9292, 0x9292, 0x9292, 0xFFFF }, { 0x9191, 0x9191, 0x9191, 0xFFFF }, { 0x9090, 0x9090, 0x9090, 0xFFFF }, { 0x8F8F, 0x8F8F, 0x8F8F, 0xFFFF }, { 0x8E8E, 0x8E8E, 0x8E8E, 0xFFFF }, { 0x8D8D, 0x8D8D, 0x8D8D, 0xFFFF }, { 0x8C8C, 0x8C8C, 0x8C8C, 0xFFFF }, { 0x8B8B, 0x8B8B, 0x8B8B, 0xFFFF }, { 0x8A8A, 0x8A8A, 0x8A8A, 0xFFFF }, { 0x8989, 0x8989, 0x8989, 0xFFFF }, { 0x8888, 0x8888, 0x8888, 0xFFFF }, { 0x8787, 0x8787, 0x8787, 0xFFFF }, { 0x8686, 0x8686, 0x8686, 0xFFFF }, { 0x8585, 0x8585, 0x8585, 0xFFFF }, { 0x8484, 0x8484, 0x8484, 0xFFFF }, { 0x8383, 0x8383, 0x8383, 0xFFFF }, { 0x8282, 0x8282, 0x8282, 0xFFFF }, { 0x8181, 0x8181, 0x8181, 0xFFFF }, { 0x8080, 0x8080, 0x8080, 0xFFFF }, { 0x7F7F, 0x7F7F, 0x7F7F, 0xFFFF }, { 0x7E7E, 0x7E7E, 0x7E7E, 0xFFFF }, { 0x7D7D, 0x7D7D, 0x7D7D, 0xFFFF }, { 0x7C7C, 0x7C7C, 0x7C7C, 0xFFFF }, { 0x7B7B, 0x7B7B, 0x7B7B, 0xFFFF }, { 0x7A7A, 0x7A7A, 0x7A7A, 0xFFFF }, { 0x7979, 0x7979, 0x7979, 0xFFFF }, { 0x7878, 0x7878, 0x7878, 0xFFFF }, { 0x7777, 0x7777, 0x7777, 0xFFFF }, { 0x7676, 0x7676, 0x7676, 0xFFFF }, { 0x7575, 0x7575, 0x7575, 0xFFFF }, { 0x7474, 0x7474, 0x7474, 0xFFFF }, { 0x7373, 0x7373, 0x7373, 0xFFFF }, { 0x7272, 0x7272, 0x7272, 0xFFFF }, { 0x7171, 0x7171, 0x7171, 0xFFFF }, { 0x7070, 0x7070, 0x7070, 0xFFFF }, { 0x6F6F, 0x6F6F, 0x6F6F, 0xFFFF }, { 0x6E6E, 0x6E6E, 0x6E6E, 0xFFFF }, { 0x6D6D, 0x6D6D, 0x6D6D, 0xFFFF }, { 0x6C6C, 0x6C6C, 0x6C6C, 0xFFFF }, { 0x6B6B, 0x6B6B, 0x6B6B, 0xFFFF }, { 0x6A6A, 0x6A6A, 0x6A6A, 0xFFFF }, { 0x6969, 0x6969, 0x6969, 0xFFFF }, { 0x6868, 0x6868, 0x6868, 0xFFFF }, { 0x6767, 0x6767, 0x6767, 0xFFFF }, { 0x6666, 0x6666, 0x6666, 0xFFFF }, { 0x6565, 0x6565, 0x6565, 0xFFFF }, { 0x6464, 0x6464, 0x6464, 0xFFFF }, { 0x6363, 0x6363, 0x6363, 0xFFFF }, { 0x6262, 0x6262, 0x6262, 0xFFFF }, { 0x6161, 0x6161, 0x6161, 0xFFFF }, { 0x6060, 0x6060, 0x6060, 0xFFFF }, { 0x5F5F, 0x5F5F, 0x5F5F, 0xFFFF }, { 0x5E5E, 0x5E5E, 0x5E5E, 0xFFFF }, { 0x5D5D, 0x5D5D, 0x5D5D, 0xFFFF }, { 0x5C5C, 0x5C5C, 0x5C5C, 0xFFFF }, { 0x5B5B, 0x5B5B, 0x5B5B, 0xFFFF }, { 0x5A5A, 0x5A5A, 0x5A5A, 0xFFFF }, { 0x5959, 0x5959, 0x5959, 0xFFFF }, { 0x5858, 0x5858, 0x5858, 0xFFFF }, { 0x5757, 0x5757, 0x5757, 0xFFFF }, { 0x5656, 0x5656, 0x5656, 0xFFFF }, { 0x5555, 0x5555, 0x5555, 0xFFFF }, { 0x5454, 0x5454, 0x5454, 0xFFFF }, { 0x5353, 0x5353, 0x5353, 0xFFFF }, { 0x5252, 0x5252, 0x5252, 0xFFFF }, { 0x5151, 0x5151, 0x5151, 0xFFFF }, { 0x5050, 0x5050, 0x5050, 0xFFFF }, { 0x4F4F, 0x4F4F, 0x4F4F, 0xFFFF }, { 0x4E4E, 0x4E4E, 0x4E4E, 0xFFFF }, { 0x4D4D, 0x4D4D, 0x4D4D, 0xFFFF }, { 0x4C4C, 0x4C4C, 0x4C4C, 0xFFFF }, { 0x4B4B, 0x4B4B, 0x4B4B, 0xFFFF }, { 0x4A4A, 0x4A4A, 0x4A4A, 0xFFFF }, { 0x4949, 0x4949, 0x4949, 0xFFFF }, { 0x4848, 0x4848, 0x4848, 0xFFFF }, { 0x4747, 0x4747, 0x4747, 0xFFFF }, { 0x4646, 0x4646, 0x4646, 0xFFFF }, { 0x4545, 0x4545, 0x4545, 0xFFFF }, { 0x4444, 0x4444, 0x4444, 0xFFFF }, { 0x4343, 0x4343, 0x4343, 0xFFFF }, { 0x4242, 0x4242, 0x4242, 0xFFFF }, { 0x4141, 0x4141, 0x4141, 0xFFFF }, { 0x4040, 0x4040, 0x4040, 0xFFFF }, { 0x3F3F, 0x3F3F, 0x3F3F, 0xFFFF }, { 0x3E3E, 0x3E3E, 0x3E3E, 0xFFFF }, { 0x3D3D, 0x3D3D, 0x3D3D, 0xFFFF }, { 0x3C3C, 0x3C3C, 0x3C3C, 0xFFFF }, { 0x3B3B, 0x3B3B, 0x3B3B, 0xFFFF }, { 0x3A3A, 0x3A3A, 0x3A3A, 0xFFFF }, { 0x3939, 0x3939, 0x3939, 0xFFFF }, { 0x3838, 0x3838, 0x3838, 0xFFFF }, { 0x3737, 0x3737, 0x3737, 0xFFFF }, { 0x3636, 0x3636, 0x3636, 0xFFFF }, { 0x3535, 0x3535, 0x3535, 0xFFFF }, { 0x3434, 0x3434, 0x3434, 0xFFFF }, { 0x3333, 0x3333, 0x3333, 0xFFFF }, { 0x3232, 0x3232, 0x3232, 0xFFFF }, { 0x3131, 0x3131, 0x3131, 0xFFFF }, { 0x3030, 0x3030, 0x3030, 0xFFFF }, { 0x2F2F, 0x2F2F, 0x2F2F, 0xFFFF }, { 0x2E2E, 0x2E2E, 0x2E2E, 0xFFFF }, { 0x2D2D, 0x2D2D, 0x2D2D, 0xFFFF }, { 0x2C2C, 0x2C2C, 0x2C2C, 0xFFFF }, { 0x2B2B, 0x2B2B, 0x2B2B, 0xFFFF }, { 0x2A2A, 0x2A2A, 0x2A2A, 0xFFFF }, { 0x2929, 0x2929, 0x2929, 0xFFFF }, { 0x2828, 0x2828, 0x2828, 0xFFFF }, { 0x2727, 0x2727, 0x2727, 0xFFFF }, { 0x2626, 0x2626, 0x2626, 0xFFFF }, { 0x2525, 0x2525, 0x2525, 0xFFFF }, { 0x2424, 0x2424, 0x2424, 0xFFFF }, { 0x2323, 0x2323, 0x2323, 0xFFFF }, { 0x2222, 0x2222, 0x2222, 0xFFFF }, { 0x2121, 0x2121, 0x2121, 0xFFFF }, { 0x2020, 0x2020, 0x2020, 0xFFFF }, { 0x1F1F, 0x1F1F, 0x1F1F, 0xFFFF }, { 0x1E1E, 0x1E1E, 0x1E1E, 0xFFFF }, { 0x1D1D, 0x1D1D, 0x1D1D, 0xFFFF }, { 0x1C1C, 0x1C1C, 0x1C1C, 0xFFFF }, { 0x1B1B, 0x1B1B, 0x1B1B, 0xFFFF }, { 0x1A1A, 0x1A1A, 0x1A1A, 0xFFFF }, { 0x1919, 0x1919, 0x1919, 0xFFFF }, { 0x1818, 0x1818, 0x1818, 0xFFFF }, { 0x1717, 0x1717, 0x1717, 0xFFFF }, { 0x1616, 0x1616, 0x1616, 0xFFFF }, { 0x1515, 0x1515, 0x1515, 0xFFFF }, { 0x1414, 0x1414, 0x1414, 0xFFFF }, { 0x1313, 0x1313, 0x1313, 0xFFFF }, { 0x1212, 0x1212, 0x1212, 0xFFFF }, { 0x1111, 0x1111, 0x1111, 0xFFFF }, { 0x1010, 0x1010, 0x1010, 0xFFFF }, { 0x0F0F, 0x0F0F, 0x0F0F, 0xFFFF }, { 0x0E0E, 0x0E0E, 0x0E0E, 0xFFFF }, { 0x0D0D, 0x0D0D, 0x0D0D, 0xFFFF }, { 0x0C0C, 0x0C0C, 0x0C0C, 0xFFFF }, { 0x0B0B, 0x0B0B, 0x0B0B, 0xFFFF }, { 0x0A0A, 0x0A0A, 0x0A0A, 0xFFFF }, { 0x0909, 0x0909, 0x0909, 0xFFFF }, { 0x0808, 0x0808, 0x0808, 0xFFFF }, { 0x0707, 0x0707, 0x0707, 0xFFFF }, { 0x0606, 0x0606, 0x0606, 0xFFFF }, { 0x0505, 0x0505, 0x0505, 0xFFFF }, { 0x0404, 0x0404, 0x0404, 0xFFFF }, { 0x0303, 0x0303, 0x0303, 0xFFFF }, { 0x0202, 0x0202, 0x0202, 0xFFFF }, { 0x0101, 0x0101, 0x0101, 0xFFFF }, { 0x0000, 0x0000, 0x0000, 0xFFFF }, }; void quicktime_default_ctab(quicktime_ctab_t * ctab, int depth) { palette_entry * e; int i; switch(depth) { case 1: e = qt_default_palette_2; ctab->size = 2; break; case 2: e = qt_default_palette_4; ctab->size = 4; break; case 4: e = qt_default_palette_16; ctab->size = 16; break; case 8: e = qt_default_palette_256; ctab->size = 256; break; case 34: e = qt_default_palette_4_gray; ctab->size = 4; break; case 36: e = qt_default_palette_16_gray; ctab->size = 16; break; case 40: e = qt_default_palette_256_gray; ctab->size = 256; break; default: /* No palette available */ return; } ctab->alpha = malloc(sizeof(int16_t) * ctab->size); ctab->red = malloc(sizeof(int16_t) * ctab->size); ctab->green = malloc(sizeof(int16_t) * ctab->size); ctab->blue = malloc(sizeof(int16_t) * ctab->size); for(i = 0; i < ctab->size; i++) { ctab->alpha[i] = e[i].a; ctab->red[i] = e[i].r; ctab->green[i] = e[i].g; ctab->blue[i] = e[i].b; } } libquicktime-1.2.4/src/ctts.c0000644000175000017500000001061011511622756013035 00000000000000/******************************************************************************* ctts.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include void quicktime_ctts_init(quicktime_ctts_t *ctts) { } void quicktime_ctts_delete(quicktime_ctts_t *ctts) { if(ctts->table) free(ctts->table); } void quicktime_ctts_dump(quicktime_ctts_t *ctts) { int i; lqt_dump(" composition time to sample (ctts)\n"); lqt_dump(" version %d\n", ctts->version); lqt_dump(" flags %ld\n", ctts->flags); lqt_dump(" total_entries %ld\n", ctts->total_entries); for(i = 0; i < ctts->total_entries; i++) { lqt_dump(" count %d duration %d\n", ctts->table[i].sample_count, ctts->table[i].sample_duration); } } void quicktime_read_ctts(quicktime_t *file, quicktime_ctts_t *ctts) { int i; ctts->version = quicktime_read_char(file); ctts->flags = quicktime_read_int24(file); ctts->total_entries = quicktime_read_int32(file); ctts->table = malloc(sizeof(quicktime_ctts_table_t) * ctts->total_entries); for(i = 0; i < ctts->total_entries; i++) { ctts->table[i].sample_count = quicktime_read_int32(file); ctts->table[i].sample_duration = quicktime_read_int32(file); } } void quicktime_write_ctts(quicktime_t *file, quicktime_ctts_t *ctts) { int i; quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "ctts"); quicktime_write_char(file, ctts->version); quicktime_write_int24(file, ctts->flags); quicktime_write_int32(file, ctts->total_entries); for(i = 0; i < ctts->total_entries; i++) { quicktime_write_int32(file, ctts->table[i].sample_count); quicktime_write_int32(file, ctts->table[i].sample_duration); } quicktime_atom_write_footer(file, &atom); } void quicktime_update_ctts(quicktime_ctts_t *ctts, long sample, long duration) { if(sample >= ctts->entries_allocated) { ctts->entries_allocated = sample + 1024; ctts->table = realloc(ctts->table, ctts->entries_allocated * sizeof(*(ctts->table))); } ctts->table[sample].sample_count = 1; ctts->table[sample].sample_duration = duration; if(sample >= ctts->total_entries) ctts->total_entries = sample + 1; } void quicktime_compress_ctts(quicktime_ctts_t *ctts) { long sample = 0; long i; while(sample < ctts->total_entries) { i = 1; while(sample + i < ctts->total_entries) { if(ctts->table[sample + i].sample_duration == ctts->table[sample].sample_duration) { ctts->table[sample].sample_count++; } else { break; } i++; } if(ctts->table[sample].sample_count > 1) { /* Compress */ if(ctts->total_entries - sample - i) memmove(&ctts->table[sample + 1], &ctts->table[sample + i], sizeof(ctts->table[sample + i]) * (ctts->total_entries - sample - i)); ctts->total_entries -= ctts->table[sample].sample_count-1; } sample++; } } void quicktime_fix_ctts(quicktime_ctts_t *ctts) { int min_ctts = 0, i; for(i = 0; i < ctts->total_entries; i++) { if((int)(ctts->table[i].sample_duration) < min_ctts) min_ctts = (int)(ctts->table[i].sample_duration); } if(!min_ctts) return; min_ctts = -min_ctts; for(i = 0; i < ctts->total_entries; i++) { ctts->table[i].sample_duration = (int)(ctts->table[i].sample_duration) + min_ctts; } } libquicktime-1.2.4/src/workarounds.c0000644000175000017500000000242711511622757014446 00000000000000/******************************************************************************* workarounds.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include "workarounds.h" int64_t quicktime_add(int64_t a, int64_t b) { return a + b; } int64_t quicktime_add3(int64_t a, int64_t b, int64_t c) { return a + b + c; } libquicktime-1.2.4/src/timecode.c0000644000175000017500000001636211511622757013664 00000000000000/******************************************************************************* timecode.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include #include #include "lqt_private.h" #define TIMECODES_PER_CHUNK 16 void lqt_add_timecode_track(quicktime_t * file, int track, uint32_t flags, int framerate) { quicktime_video_map_t * vm = file->vtracks + track; int time_scale, frame_duration, constant; int width, height; double fps; time_scale = lqt_video_time_scale(file, track); width = quicktime_video_width(file, track); height = quicktime_video_height(file, track); frame_duration = lqt_frame_duration(file, track, &constant); fps = (double)(time_scale) / (double)(frame_duration); vm->timecode_track = quicktime_add_track(file); quicktime_trak_init_timecode(file, vm->timecode_track, time_scale, frame_duration, framerate, width, height, flags); /* reference timecode track */ quicktime_tref_init_tmcd(&vm->track->tref, vm->timecode_track->tkhd.track_id); vm->track->has_tref = 1; vm->timecodes = malloc(TIMECODES_PER_CHUNK * sizeof(*vm->timecodes)); vm->cur_timecode_chunk = 0; } void lqt_write_timecode(quicktime_t * file, int track, uint32_t timecode) { quicktime_video_map_t * vm = file->vtracks + track; vm->encode_timecode = timecode; vm->has_encode_timecode = 1; /* Rest is done by lqt_flush_timecode (see below) */ } int lqt_has_timecode_track(quicktime_t * file, int track, uint32_t * flags, int * framerate) { quicktime_video_map_t * vm = file->vtracks + track; if(vm->timecode_track) { if(flags) *flags = vm->timecode_track->mdia.minf.stbl.stsd.table[0].tmcd.flags; if(framerate) *framerate = vm->timecode_track->mdia.minf.stbl.stsd.table[0].tmcd.numframes; return 1; } else return 0; } static uint32_t * cache_timecodes(quicktime_t * file, quicktime_trak_t * trak, int * total) { uint32_t * ret; int i, j; int num_read = 0, num; int stsc_pos = 0; *total = quicktime_track_samples(file, trak); ret = malloc(*total * sizeof(*ret)); for(i = 0; i < trak->mdia.minf.stbl.stco.total_entries; i++) { if((stsc_pos < trak->mdia.minf.stbl.stsc.total_entries-1) && /* chunks start with 1 */ (i + 2 == trak->mdia.minf.stbl.stsc.table[stsc_pos+1].chunk)) { stsc_pos++; } num = trak->mdia.minf.stbl.stsc.table[stsc_pos].samples; /* fprintf(stderr, "Reading timecode chunk: num: %d off: %ld samples: %d\n", i, trak->mdia.minf.stbl.stco.table[i].offset, num); */ quicktime_set_position(file, trak->mdia.minf.stbl.stco.table[i].offset); for(j = 0; j < num; j++) { ret[num_read + j] = quicktime_read_int32(file); // quicktime_read_data(file, (uint8_t*)(ret + num_read), num * sizeof(*ret)); } num_read += num; } return ret; } int lqt_read_timecode(quicktime_t * file, int track, uint32_t * timecode) { int64_t sample; int64_t time; int64_t stts_index; int64_t stts_count; quicktime_video_map_t * vm = file->vtracks + track; if(!vm->timecode_track) return 0; /* Read all timecodes at once */ if(!vm->timecodes) { vm->timecodes = cache_timecodes(file, vm->timecode_track, &vm->num_timecodes); } time = vm->timestamp; sample = quicktime_time_to_sample(&vm->timecode_track->mdia.minf.stbl.stts, &time, &stts_index, &stts_count); /* Got a timecode */ if(time == vm->timestamp) { *timecode = vm->timecodes[sample]; return 1; } return 0; } /* private to lqt */ void lqt_flush_timecode(quicktime_t * file, int track, int64_t time, int force) { int i; quicktime_video_map_t * vm = file->vtracks + track; quicktime_stts_t * stts; if(file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML)) return; if(!force) { if(!vm->has_encode_timecode) return; /* Append to array */ vm->timecodes[vm->num_timecodes] = vm->encode_timecode; vm->has_encode_timecode = 0; vm->num_timecodes++; /* Update stts */ if(vm->timecodes_written) { stts = &vm->timecode_track->mdia.minf.stbl.stts; quicktime_update_stts(stts, vm->timecodes_written-1, time - vm->timecode_timestamp); vm->timecode_timestamp = time; } vm->timecodes_written++; } else { if(vm->timecodes_written) { stts = &vm->timecode_track->mdia.minf.stbl.stts; quicktime_update_stts(stts, vm->timecodes_written-1, time - vm->timecode_timestamp); vm->timecode_timestamp = time; } } /* Write chunk */ if(vm->num_timecodes && ((vm->num_timecodes >= TIMECODES_PER_CHUNK) || force)) { quicktime_write_chunk_header(file, vm->timecode_track); for(i = 0; i < vm->num_timecodes; i++) quicktime_write_int32(file, vm->timecodes[i]); vm->timecode_track->chunk_samples = vm->num_timecodes; quicktime_write_chunk_footer(file, vm->timecode_track); vm->cur_timecode_chunk++; vm->num_timecodes = 0; } } const char * lqt_get_timecode_tape_name(quicktime_t * file, int track) { quicktime_video_map_t * vm = file->vtracks + track; return vm->timecode_track->mdia.minf.stbl.stsd.table[0].tmcd.name; } void lqt_set_timecode_tape_name(quicktime_t * file, int track, const char * tapename) { quicktime_video_map_t * vm = file->vtracks + track; if(vm->timecode_track->mdia.minf.stbl.stsd.table[0].tmcd.name) free(vm->timecode_track->mdia.minf.stbl.stsd.table[0].tmcd.name); vm->timecode_track->mdia.minf.stbl.stsd.table[0].tmcd.name = strdup(tapename); } int lqt_get_timecode_track_enabled(quicktime_t * file, int track) { quicktime_video_map_t * vm = file->vtracks + track; return vm->timecode_track->tkhd.flags & 1; } void lqt_set_timecode_track_enabled(quicktime_t * file, int track, int enabled) { quicktime_video_map_t * vm = file->vtracks + track; if(enabled) vm->timecode_track->tkhd.flags |= 1; else vm->timecode_track->tkhd.flags &= ~1; } libquicktime-1.2.4/src/avi_guid.c0000644000175000017500000000410611511622756013652 00000000000000/******************************************************************************* avi_guid.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include void quicktime_GUID_dump(quicktime_GUID_t * g) { lqt_dump("%08x-%04x-%04x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n", g->v1, g->v2, g->v3, g->v4[0], g->v4[1], g->v4[2], g->v4[3], g->v4[4], g->v4[5], g->v4[6], g->v4[7]); } int quicktime_GUID_equal(const quicktime_GUID_t * g1, const quicktime_GUID_t * g2) { return (g1->v1 == g2->v1) && (g1->v2 == g2->v2) && (g1->v3 == g2->v3) && !memcmp(g1->v4, g2->v4, 8); } void quicktime_GUID_read(quicktime_t * file, quicktime_GUID_t * guid) { guid->v1 = quicktime_read_int32_le(file); guid->v2 = quicktime_read_int16_le(file); guid->v3 = quicktime_read_int16_le(file); quicktime_read_data(file, guid->v4, 8); } void quicktime_GUID_write(quicktime_t * file, quicktime_GUID_t * guid) { quicktime_write_int32_le(file, guid->v1); quicktime_write_int16_le(file, guid->v2); quicktime_write_int16_le(file, guid->v3); quicktime_write_data(file, guid->v4, 8); } libquicktime-1.2.4/src/cmodel_yuv420p.c0000644000175000017500000010606411670173743014650 00000000000000/******************************************************************************* cmodel_yuv420p.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #define HAVE_RGB_16_TO_RGB_24 #define HAVE_RGB_TO_YUV #define HAVE_RGB_TO_YUVJ #define HAVE_YUV_TO_RGB #define HAVE_YUVJ_TO_RGB #define HAVE_YUV_8_TO_YUVJ #define HAVE_YUVJ_TO_YUV_8 #include "lqt_private.h" #include "cmodel_permutation.h" #define TRANSFER_FRAME_DEFAULT(output, \ y_in_offset, \ u_in_offset, \ v_in_offset, \ input_column) \ { \ register int i, j; \ \ switch(in_colormodel) \ { \ case BC_YUV420P: \ switch(out_colormodel) \ { \ case BC_BGR565: \ TRANSFER_YUV420P_IN_HEAD_16 \ transfer_YUV422P_to_BGR565((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB565: \ TRANSFER_YUV420P_IN_HEAD_16 \ transfer_YUV422P_to_RGB565((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR888: \ TRANSFER_YUV420P_IN_HEAD \ transfer_YUV422P_to_BGR888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR8888: \ TRANSFER_YUV420P_IN_HEAD \ transfer_YUV422P_to_BGR8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV420P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i / 2 * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i / 2 * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] / 2 * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] / 2 * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P_to_YUV420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_YUV422: \ TRANSFER_YUV420P_IN_HEAD \ transfer_YUV422P_to_YUV422((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] / 2 * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] / 2 * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P_to_YUV420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_YUV444P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] / 2 * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] / 2 * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P_to_YUV444P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_RGB888: \ TRANSFER_YUV420P_IN_HEAD \ transfer_YUV422P_to_RGB888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_YUV420P_IN_HEAD \ transfer_YUV422P_to_RGBA8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB161616: \ TRANSFER_YUV420P_IN_HEAD_16 \ transfer_YUV422P_to_RGB161616((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA16161616: \ TRANSFER_YUV420P_IN_HEAD_16 \ transfer_YUV422P_to_RGBA16161616((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVA8888: \ TRANSFER_YUV420P_IN_HEAD \ transfer_YUV422P_to_YUVA8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ } \ break; \ case BC_YUV411P: \ switch(out_colormodel) \ { \ case BC_RGB888: \ TRANSFER_YUV411P_IN_HEAD \ transfer_YUV411P_to_RGB888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_YUV411P_IN_HEAD \ transfer_YUV411P_to_RGBA8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ } \ break; \ \ case BC_YUVJ444P: \ switch(out_colormodel) \ { \ case BC_RGB888: \ TRANSFER_YUV444P_IN_HEAD \ transfer_YUVJ444P_to_RGB888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_YUV444P_IN_HEAD \ transfer_YUVJ444P_to_RGBA8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVJ444P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV444P_to_YUV444P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ } \ break; \ \ case BC_YUVJ422P: \ switch(out_colormodel) \ { \ case BC_RGB888: \ TRANSFER_YUV422P_IN_HEAD \ transfer_YUVJ422P_to_RGB888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_YUV422P_IN_HEAD \ transfer_YUVJ422P_to_RGBA8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVJ422P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P_to_YUV420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_YUV420P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i / 2 * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i / 2 * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUVJ422P_to_YUV420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_YUV422P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUVJ422P_to_YUV420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_YUV422: \ TRANSFER_YUV422_IN_HEAD \ transfer_YUVJ422P_to_YUV422((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ j); \ TRANSFER_FRAME_TAIL \ break; \ } \ break; \ \ case BC_YUVJ420P: \ switch(out_colormodel) \ { \ case BC_RGB888: \ TRANSFER_YUV420P_IN_HEAD \ transfer_YUVJ420P_to_RGB888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_YUV420P_IN_HEAD \ transfer_YUVJ420P_to_RGBA8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVJ420P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i / 2 * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i / 2 * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] / 2 * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] / 2 * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P_to_YUV420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ } \ break; \ \ case BC_YUV422P: \ switch(out_colormodel) \ { \ case BC_BGR565: \ TRANSFER_YUV422P_IN_HEAD_16 \ transfer_YUV422P_to_BGR565((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB565: \ TRANSFER_YUV422P_IN_HEAD_16 \ transfer_YUV422P_to_RGB565((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR888: \ TRANSFER_YUV422P_IN_HEAD \ transfer_YUV422P_to_BGR888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR8888: \ TRANSFER_YUV422P_IN_HEAD \ transfer_YUV422P_to_BGR8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB888: \ TRANSFER_YUV422P_IN_HEAD \ transfer_YUV422P_to_RGB888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_YUV422P_IN_HEAD \ transfer_YUV422P_to_RGBA8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB161616: \ TRANSFER_YUV422P_IN_HEAD_16 \ transfer_YUV422P_to_RGB161616((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA16161616: \ TRANSFER_YUV422P_IN_HEAD_16 \ transfer_YUV422P_to_RGBA16161616((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVA8888: \ TRANSFER_YUV422P_IN_HEAD \ transfer_YUV422P_to_YUVA8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV420P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i / 2 * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i / 2 * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P_to_YUV420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_YUV422: \ TRANSFER_YUV422_IN_HEAD \ transfer_YUV422P_to_YUV422((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P_to_YUV420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_YUV444P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P_to_YUV444P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_YUVJ422P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P_to_YUVJ420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ } \ break; \ \ case BC_YUV422P16: \ switch(out_colormodel) \ { \ case BC_RGB888: \ TRANSFER_YUV422P16_IN_HEAD \ transfer_YUV422P16_to_RGB888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_YUV422P16_IN_HEAD \ transfer_YUV422P16_to_RGBA8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB161616: \ TRANSFER_YUV422P16_IN_HEAD_16 \ transfer_YUV422P16_to_RGB161616((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P16: \ for(i = 0; i < out_h; i++) \ { \ uint16_t *output_y = (uint16_t *)(output_rows[0] + i * out_rowspan); \ uint16_t *output_u = (uint16_t *)(output_rows[1] + i * out_rowspan_uv); \ uint16_t *output_v = (uint16_t *)(output_rows[2] + i * out_rowspan_uv); \ uint16_t *input_y = (uint16_t *)(input_rows[0] + row_table[i] * in_rowspan); \ uint16_t *input_u = (uint16_t *)(input_rows[1] + row_table[i] * in_rowspan_uv); \ uint16_t *input_v = (uint16_t *)(input_rows[2] + row_table[i] * in_rowspan_uv); \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P16_to_YUV420P16(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_YUV422P: \ for(i = 0; i < out_h; i++) \ { \ uint8_t *output_y = (uint8_t *)(output_rows[0] + i * out_rowspan); \ uint8_t *output_u = (uint8_t *)(output_rows[1] + i * out_rowspan_uv); \ uint8_t *output_v = (uint8_t *)(output_rows[2] + i * out_rowspan_uv); \ uint16_t *input_y = (uint16_t *)(input_rows[0] + row_table[i] * in_rowspan); \ uint16_t *input_u = (uint16_t *)(input_rows[1] + row_table[i] * in_rowspan_uv); \ uint16_t *input_v = (uint16_t *)(input_rows[2] + row_table[i] * in_rowspan_uv); \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P16_to_YUV420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ } \ break; \ case BC_YUV422P10: \ switch(out_colormodel) \ { \ case BC_RGB888: \ TRANSFER_YUV422P16_IN_HEAD \ transfer_YUV422P10_to_RGB888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB161616: \ TRANSFER_YUV422P16_IN_HEAD_16 \ transfer_YUV422P10_to_RGB161616((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P10: \ for(i = 0; i < out_h; i++) \ { \ uint16_t *output_y = (uint16_t *)(output_rows[0] + i * out_rowspan); \ uint16_t *output_u = (uint16_t *)(output_rows[1] + i * out_rowspan_uv); \ uint16_t *output_v = (uint16_t *)(output_rows[2] + i * out_rowspan_uv); \ uint16_t *input_y = (uint16_t *)(input_rows[0] + row_table[i] * in_rowspan); \ uint16_t *input_u = (uint16_t *)(input_rows[1] + row_table[i] * in_rowspan_uv); \ uint16_t *input_v = (uint16_t *)(input_rows[2] + row_table[i] * in_rowspan_uv); \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P16_to_YUV420P16(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ } \ break; \ case BC_YUVJ422P10: \ switch(out_colormodel) \ { \ case BC_RGB888: \ TRANSFER_YUV422P16_IN_HEAD \ transfer_YUVJ422P10_to_RGB888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB161616: \ TRANSFER_YUV422P16_IN_HEAD_16 \ transfer_YUVJ422P10_to_RGB161616((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVJ422P10: \ for(i = 0; i < out_h; i++) \ { \ uint16_t *output_y = (uint16_t *)(output_rows[0] + i * out_rowspan); \ uint16_t *output_u = (uint16_t *)(output_rows[1] + i * out_rowspan_uv); \ uint16_t *output_v = (uint16_t *)(output_rows[2] + i * out_rowspan_uv); \ uint16_t *input_y = (uint16_t *)(input_rows[0] + row_table[i] * in_rowspan); \ uint16_t *input_u = (uint16_t *)(input_rows[1] + row_table[i] * in_rowspan_uv); \ uint16_t *input_v = (uint16_t *)(input_rows[2] + row_table[i] * in_rowspan_uv); \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P16_to_YUV420P16(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ } \ break; \ case BC_YUV444P16: \ switch(out_colormodel) \ { \ case BC_RGB888: \ TRANSFER_YUV444P16_IN_HEAD \ transfer_YUV444P16_to_RGB888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_YUV444P16_IN_HEAD \ transfer_YUV444P16_to_RGBA8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB161616: \ TRANSFER_YUV444P16_IN_HEAD_16 \ transfer_YUV444P16_to_RGB161616((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV444P16: \ for(i = 0; i < out_h; i++) \ { \ uint16_t *output_y = (uint16_t *)(output_rows[0] + i * out_rowspan); \ uint16_t *output_u = (uint16_t *)(output_rows[1] + i * out_rowspan_uv); \ uint16_t *output_v = (uint16_t *)(output_rows[2] + i * out_rowspan_uv); \ uint16_t *input_y = (uint16_t *)(input_rows[0] + row_table[i] * in_rowspan); \ uint16_t *input_u = (uint16_t *)(input_rows[1] + row_table[i] * in_rowspan_uv); \ uint16_t *input_v = (uint16_t *)(input_rows[2] + row_table[i] * in_rowspan_uv); \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV444P16_to_YUV444P16(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_YUV444P: \ for(i = 0; i < out_h; i++) \ { \ uint8_t *output_y = (uint8_t *)(output_rows[0] + i * out_rowspan); \ uint8_t *output_u = (uint8_t *)(output_rows[1] + i * out_rowspan_uv); \ uint8_t *output_v = (uint8_t *)(output_rows[2] + i * out_rowspan_uv); \ uint16_t *input_y = (uint16_t *)(input_rows[0] + row_table[i] * in_rowspan); \ uint16_t *input_u = (uint16_t *)(input_rows[1] + row_table[i] * in_rowspan_uv); \ uint16_t *input_v = (uint16_t *)(input_rows[2] + row_table[i] * in_rowspan_uv); \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV444P16_to_YUV444P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ } \ break; \ case BC_YUV444P: \ switch(out_colormodel) \ { \ case BC_BGR565: \ TRANSFER_YUV444P_IN_HEAD_16 \ transfer_YUV422P_to_BGR565((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB565: \ TRANSFER_YUV444P_IN_HEAD_16 \ transfer_YUV422P_to_RGB565((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR888: \ TRANSFER_YUV444P_IN_HEAD \ transfer_YUV422P_to_BGR888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR8888: \ TRANSFER_YUV444P_IN_HEAD \ transfer_YUV422P_to_BGR8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB888: \ TRANSFER_YUV444P_IN_HEAD \ transfer_YUV422P_to_RGB888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_YUV444P_IN_HEAD \ transfer_YUV422P_to_RGBA8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB161616: \ TRANSFER_YUV444P_IN_HEAD_16 \ transfer_YUV422P_to_RGB161616((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA16161616: \ TRANSFER_YUV444P_IN_HEAD_16 \ transfer_YUV422P_to_RGBA16161616((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVA8888: \ TRANSFER_YUV444P_IN_HEAD \ transfer_YUV422P_to_YUVA8888((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV420P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i / 2 * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i / 2 * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P_to_YUV420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_YUV422: \ TRANSFER_YUV444P_IN_HEAD \ transfer_YUV422P_to_YUV422((output), \ input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV422P_to_YUV420P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ case BC_YUV444P: \ for(i = 0; i < out_h; i++) \ { \ unsigned char *output_y = output_rows[0] + i * out_rowspan; \ unsigned char *output_u = output_rows[1] + i * out_rowspan_uv; \ unsigned char *output_v = output_rows[2] + i * out_rowspan_uv; \ unsigned char *input_y = input_rows[0] + row_table[i] * in_rowspan; \ unsigned char *input_u = input_rows[1] + row_table[i] * in_rowspan_uv; \ unsigned char *input_v = input_rows[2] + row_table[i] * in_rowspan_uv; \ for(j = 0; j < out_w; j++) \ { \ transfer_YUV444P_to_YUV444P(input_y + (y_in_offset), \ input_u + (u_in_offset), \ input_v + (v_in_offset), \ output_y, \ output_u, \ output_v, \ j); \ } \ } \ break; \ } \ break; \ } \ } void cmodel_yuv420p(PERMUTATION_ARGS) { if(scale) { TRANSFER_FRAME_DEFAULT(&output_row, column_table[j], column_table[j] / 2, column_table[j] / 2, 0); } else { TRANSFER_FRAME_DEFAULT(&output_row, j, j / 2, j / 2, 0); } } void cmodel_yuv411p(PERMUTATION_ARGS) { if(scale) { TRANSFER_FRAME_DEFAULT(&output_row, column_table[j], column_table[j] / 4, column_table[j] / 4, 0); } else { TRANSFER_FRAME_DEFAULT(&output_row, j, j / 4, j / 4, 0); } } void cmodel_yuv444p(PERMUTATION_ARGS) { if(scale) { TRANSFER_FRAME_DEFAULT(&output_row, column_table[j], column_table[j], column_table[j], 0); } else { TRANSFER_FRAME_DEFAULT(&output_row, j, j, j, 0); } } libquicktime-1.2.4/src/cmodel_yuv422.c0000644000175000017500000000771211511622756014467 00000000000000/******************************************************************************* cmodel_yuv422.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #define HAVE_RGB_16_TO_RGB_24 #define HAVE_RGB_TO_YUV #define HAVE_RGB_TO_YUVJ #define HAVE_YUV_TO_RGB #define HAVE_YUVJ_TO_RGB #define HAVE_YUV_8_TO_YUVJ #define HAVE_YUVJ_TO_YUV_8 #include "lqt_private.h" #include "cmodel_permutation.h" #define TRANSFER_FRAME_DEFAULT(output, \ input, \ y_in_offset, \ u_in_offset, \ v_in_offset, \ input_column) \ { \ register int i, j; \ \ switch(out_colormodel) \ { \ case BC_BGR565: \ TRANSFER_FRAME_HEAD_16 \ transfer_YUV422_to_BGR565((output), (input), (input_column)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB565: \ TRANSFER_FRAME_HEAD_16 \ transfer_YUV422_to_RGB565((output), (input), (input_column)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB888: \ TRANSFER_FRAME_HEAD \ transfer_YUV422_to_RGB888((output), (input), (input_column)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA8888: \ TRANSFER_FRAME_HEAD \ transfer_YUV422_to_RGBA8888((output), (input), (input_column)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVA8888: \ TRANSFER_FRAME_HEAD \ transfer_YUV422_to_YUVA8888((output), (input), (input_column)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGB161616: \ TRANSFER_FRAME_HEAD_16 \ transfer_YUV422_to_RGB161616((output), (input), (input_column)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_RGBA16161616: \ TRANSFER_FRAME_HEAD_16 \ transfer_YUV422_to_RGBA16161616((output), (input), (input_column)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR888: \ TRANSFER_FRAME_HEAD \ transfer_YUV422_to_BGR888((output), (input), (input_column)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_BGR8888: \ TRANSFER_FRAME_HEAD \ transfer_YUV422_to_BGR8888((output), (input), (input_column)); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422P: \ TRANSFER_YUV422P_OUT_HEAD \ transfer_YUV422_to_YUV422P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUVJ422P: \ TRANSFER_YUV422P_OUT_HEAD \ transfer_YUV422_to_YUVJ422P(output_y, \ output_u, \ output_v, \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV422: \ TRANSFER_FRAME_HEAD \ transfer_YUV422_to_YUV422((output), \ (input), \ j); \ TRANSFER_FRAME_TAIL \ break; \ case BC_YUV420P: \ TRANSFER_YUV420P_OUT_HEAD \ transfer_YUV422_to_YUV420P(output_y, \ output_u, \ output_v, \ (input), \ j, \ i); \ TRANSFER_FRAME_TAIL \ break; \ } \ } void cmodel_yuv422(PERMUTATION_ARGS) { if(scale) { TRANSFER_FRAME_DEFAULT(&output_row, input_row + ((column_table[j] * in_pixelsize) & 0xfffffffc), 0, 0, 0, column_table[j]); } else { TRANSFER_FRAME_DEFAULT(&output_row, input_row + ((j * in_pixelsize) & 0xfffffffc), 0, 0, 0, j); } } libquicktime-1.2.4/src/pdat.c0000644000175000017500000001373711511622757013026 00000000000000/******************************************************************************* pdat.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" int quicktime_pdat_init(quicktime_pdat_t *pdat) { pdat->version = 2; pdat->revision = 0; pdat->imageRefTrackIndex = 1; pdat->hotSpotRefTrackIndex = 0; pdat->minPan = 0; pdat->maxPan = 360; pdat->defaultPan = 0; pdat->minTilt = 72; pdat->maxTilt = -72; pdat->defaultTilt = 0; pdat->minFOV = 0; pdat->maxFOV = 64; pdat->defaultFOV = 64; pdat->imageSizeX = 0; pdat->imageSizeY = 0; pdat->imageNumFramesX = 1; pdat->imageNumFramesY = 1; pdat->hotSpotSizeX = 0; pdat->hotSpotSizeY = 0; pdat->hotSpotNumFramesX = 0; pdat->hotSpotNumFramesY = 0; pdat->flags = 0; pdat->panoType[0] = '\0'; pdat->panoType[1] = '\0'; pdat->panoType[2] = '\0'; pdat->panoType[3] = '\0'; return 0; } int quicktime_pdat_delete(quicktime_pdat_t *pdat) { return 0; } void quicktime_pdat_dump(quicktime_pdat_t *pdat) { lqt_dump("object node (pdat)\n"); lqt_dump(" version %i\n", pdat->version ); lqt_dump(" revision %i\n", pdat->revision ); lqt_dump(" image track index %ld\n", pdat->imageRefTrackIndex ); lqt_dump(" hotspot track index %ld\n", pdat->hotSpotRefTrackIndex ); lqt_dump(" minimum pan %f\n", pdat->minPan ); lqt_dump(" maximum pan %f\n", pdat->maxPan ); lqt_dump(" minimum tilt %f\n", pdat->minTilt ); lqt_dump(" maximum tilt %f\n", pdat->maxTilt ); lqt_dump(" minimum fov %f\n", pdat->minFOV ); lqt_dump(" fov %f\n", pdat->maxFOV ); lqt_dump(" default pan %f\n", pdat->defaultPan ); lqt_dump(" default tilt %f\n", pdat->defaultTilt ); lqt_dump(" default fov %f\n", pdat->defaultFOV ); lqt_dump(" image size x %ld\n", pdat->imageSizeX ); lqt_dump(" image size y %ld\n", pdat->imageSizeY ); lqt_dump(" image frames x %i\n", pdat->imageNumFramesX ); lqt_dump(" image frames y %i\n", pdat->imageNumFramesY ); lqt_dump(" hotspot size x %ld\n", pdat->hotSpotSizeX ); lqt_dump(" hotspot size y %ld\n", pdat->hotSpotSizeY ); lqt_dump(" hotspot frames x %i\n", pdat->hotSpotNumFramesX ); lqt_dump(" hotspot frames y %i\n", pdat->hotSpotNumFramesY ); lqt_dump(" flags %ld\n", pdat->flags ); lqt_dump(" panorama type %c%c%c%c\n", pdat->panoType[0], pdat->panoType[1], pdat->panoType[2], pdat->panoType[3]); } int quicktime_read_pdat(quicktime_t *file, quicktime_pdat_t *pdat) { pdat->version = quicktime_read_int16(file); pdat->revision = quicktime_read_int16(file); pdat->imageRefTrackIndex = quicktime_read_int32(file); pdat->hotSpotRefTrackIndex = quicktime_read_int32(file); pdat->minPan = quicktime_read_float32(file); pdat->maxPan = quicktime_read_float32(file); pdat->minTilt = quicktime_read_float32(file); pdat->maxTilt = quicktime_read_float32(file); pdat->minFOV = quicktime_read_float32(file); pdat->maxFOV = quicktime_read_float32(file); pdat->defaultPan = quicktime_read_float32(file); pdat->defaultTilt = quicktime_read_float32(file); pdat->defaultFOV = quicktime_read_float32(file); pdat->imageSizeX = quicktime_read_int32(file); pdat->imageSizeY = quicktime_read_int32(file); pdat->imageNumFramesX = quicktime_read_int16(file); pdat->imageNumFramesY = quicktime_read_int16(file); pdat->hotSpotSizeX = quicktime_read_int32(file); pdat->hotSpotSizeY = quicktime_read_int32(file); pdat->hotSpotNumFramesX = quicktime_read_int16(file); pdat->hotSpotNumFramesY = quicktime_read_int16(file); pdat->flags = quicktime_read_int32(file); quicktime_read_char32(file, pdat->panoType); pdat->reserved = quicktime_read_int32(file); return 0; } void quicktime_write_pdat(quicktime_t *file, quicktime_pdat_t *pdat) { quicktime_write_int16(file, pdat->version); quicktime_write_int16(file, pdat->revision); quicktime_write_int32(file, pdat->imageRefTrackIndex); quicktime_write_int32(file, pdat->hotSpotRefTrackIndex); quicktime_write_float32(file, pdat->minPan); quicktime_write_float32(file, pdat->maxPan); quicktime_write_float32(file, pdat->minTilt); quicktime_write_float32(file, pdat->maxTilt); quicktime_write_float32(file, pdat->minFOV); quicktime_write_float32(file, pdat->maxFOV); quicktime_write_float32(file, pdat->defaultPan); quicktime_write_float32(file, pdat->defaultPan); quicktime_write_float32(file, pdat->defaultPan); quicktime_write_int32(file, pdat->imageSizeX); quicktime_write_int32(file, pdat->imageSizeY); quicktime_write_int16(file, pdat->imageNumFramesX); quicktime_write_int16(file, pdat->imageNumFramesY); quicktime_write_int32(file, pdat->hotSpotSizeX); quicktime_write_int32(file, pdat->hotSpotSizeY); quicktime_write_int16(file, pdat->hotSpotNumFramesX); quicktime_write_int16(file, pdat->hotSpotNumFramesY); quicktime_write_int32(file, pdat->flags); quicktime_write_char32(file, pdat->panoType); quicktime_write_int32(file, pdat->reserved); return; } libquicktime-1.2.4/src/compression.c0000644000175000017500000003311711735135634014432 00000000000000/******************************************************************************* compression.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include #include #include #include void lqt_compression_info_free(lqt_compression_info_t * info) { if(info->global_header) free(info->global_header); } void lqt_packet_alloc(lqt_packet_t * p, int bytes) { if(p->data_alloc < bytes) { p->data_alloc = bytes + 1024; p->data = realloc(p->data, p->data_alloc); } } void lqt_packet_free(lqt_packet_t * p) { if(p->data) free(p->data); } /* Reading */ const lqt_compression_info_t * lqt_get_audio_compression_info(quicktime_t * file, int track) { quicktime_audio_map_t * atrack; atrack = &file->atracks[track]; if(atrack->ci.id == LQT_COMPRESSION_NONE) return NULL; if(!atrack->ci.samplerate) { atrack->ci.samplerate = quicktime_sample_rate(file, track); atrack->ci.num_channels = quicktime_track_channels(file, track); } return &atrack->ci; } const lqt_compression_info_t * lqt_get_video_compression_info(quicktime_t * file, int track) { quicktime_video_map_t * vtrack; vtrack = &file->vtracks[track]; if(vtrack->ci.id == LQT_COMPRESSION_NONE) return NULL; if(!vtrack->ci.width) { vtrack->ci.width = quicktime_video_width(file, track); vtrack->ci.height = quicktime_video_height(file, track); lqt_get_pixel_aspect(file, track, &vtrack->ci.pixel_width, &vtrack->ci.pixel_height); vtrack->ci.colormodel = vtrack->stream_cmodel; vtrack->ci.video_timescale = lqt_video_time_scale(file, track); if(vtrack->track->mdia.minf.stbl.stss.total_entries) vtrack->ci.flags |= LQT_COMPRESSION_HAS_P_FRAMES; if(vtrack->track->mdia.minf.stbl.ctts.total_entries) vtrack->ci.flags |= LQT_COMPRESSION_HAS_B_FRAMES; } return &vtrack->ci; } int lqt_read_audio_packet(quicktime_t * file, lqt_packet_t * p, int track) { quicktime_audio_map_t *atrack = &file->atracks[track]; if(atrack->codec->read_packet) { return atrack->codec->read_packet(file, p, track); } else if(atrack->block_align) { int bytes_from_samples; p->data_len = lqt_read_audio_chunk(file, track, atrack->cur_chunk, &p->data, &p->data_alloc, &p->duration); if(!p->data_len) return 0; bytes_from_samples = p->duration * atrack->block_align; if(p->data_len > bytes_from_samples) p->data_len = bytes_from_samples; p->timestamp = atrack->current_position; atrack->current_position += p->duration; atrack->cur_chunk++; return 1; } else if(lqt_audio_is_vbr(file, track)) { /* First chunk */ if(!atrack->total_vbr_packets) { atrack->cur_chunk = 0; atrack->total_vbr_packets = lqt_audio_num_vbr_packets(file, track, atrack->cur_chunk, NULL); atrack->cur_vbr_packet = 0; } /* Next chunk */ else if(atrack->cur_vbr_packet == atrack->total_vbr_packets) { atrack->cur_chunk++; atrack->total_vbr_packets = lqt_audio_num_vbr_packets(file, track, atrack->cur_chunk, NULL); atrack->cur_vbr_packet = 0; } if(!atrack->total_vbr_packets) return 0; p->data_len = lqt_audio_read_vbr_packet(file, track, atrack->cur_chunk, atrack->cur_vbr_packet, &p->data, &p->data_alloc, &p->duration); if(atrack->ci.flags & LQT_COMPRESSION_SBR) p->duration *= 2; p->timestamp = atrack->current_position; atrack->current_position += p->duration; atrack->cur_vbr_packet++; return 1; } return 0; } int lqt_read_video_packet(quicktime_t * file, lqt_packet_t * p, int track) { quicktime_video_map_t *vtrack = &file->vtracks[track]; if(vtrack->current_position >= quicktime_track_samples(file, vtrack->track)) return 0; p->flags = 0; if(lqt_is_keyframe(file, track, vtrack->current_position)) p->flags |= LQT_PACKET_KEYFRAME; p->data_len = 0; if(vtrack->codec->read_packet) { if(!vtrack->codec->read_packet(file, p, track)) return 0; } else { p->data_len = lqt_read_video_frame(file, &p->data, &p->data_alloc, vtrack->current_position, NULL, track); } /* PTS = DTS if there are no B-frames */ p->timestamp = vtrack->timestamp; /* PTS = DTS + CTS if there are B-frames */ if(vtrack->track->mdia.minf.stbl.has_ctts) { quicktime_ctts_t * ctts = &vtrack->track->mdia.minf.stbl.ctts; p->timestamp += ctts->table[vtrack->ctts_index].sample_duration - ctts->table[0].sample_duration; } p->duration = vtrack->track->mdia.minf.stbl.stts.table[vtrack->stts_index].sample_duration; lqt_update_frame_position(vtrack); return 1; } /* Writing */ int lqt_writes_compressed(lqt_file_type_t type, const lqt_compression_info_t * ci, lqt_codec_info_t * codec_info) { int ret = 0; quicktime_codec_t * codec; if(codec_info->compression_id != ci->id) return 0; codec = quicktime_load_codec(codec_info, NULL, NULL); if(!codec->writes_compressed || codec->writes_compressed(type, ci)) ret = 1; quicktime_delete_codec(codec); return ret; } int lqt_add_audio_track_compressed(quicktime_t * file, const lqt_compression_info_t * ci, lqt_codec_info_t * codec_info) { quicktime_audio_map_t *atrack; int samplerate = ci->samplerate; if(ci->flags & LQT_COMPRESSION_SBR) samplerate /= 2; if(lqt_add_audio_track_internal(file, ci->num_channels, samplerate, 16, codec_info, ci)) return 1; atrack = &file->atracks[file->total_atracks-1]; if(atrack->codec->init_compressed) atrack->codec->init_compressed(file, file->total_atracks-1); return 0; } int lqt_add_video_track_compressed(quicktime_t * file, const lqt_compression_info_t * ci, lqt_codec_info_t * codec_info) { quicktime_video_map_t *vtrack; if(lqt_add_video_track_internal(file, ci->width, ci->height, 0, ci->video_timescale, codec_info, ci)) return 1; vtrack = &file->vtracks[file->total_vtracks-1]; if(vtrack->ci.flags & LQT_COMPRESSION_HAS_B_FRAMES) vtrack->track->mdia.minf.stbl.has_ctts = 1; if(vtrack->codec->init_compressed) vtrack->codec->init_compressed(file, file->total_vtracks-1); return 0; } int lqt_write_audio_packet(quicktime_t * file, lqt_packet_t * p, int track) { int result; int samples; quicktime_audio_map_t *atrack = &file->atracks[track]; lqt_start_encoding(file); samples = p->duration; if(atrack->ci.flags & LQT_COMPRESSION_SBR) samples /= 2; // if(atrack->codec->write_packet) // return atrack->codec->write_packet(file, p, track); if(atrack->codec->write_packet) { return atrack->codec->write_packet(file, p, track); } else if(lqt_audio_is_vbr(file, track)) { if(file->write_trak != atrack->track) quicktime_write_chunk_header(file, atrack->track); lqt_start_audio_vbr_frame(file, track); result = !quicktime_write_data(file, p->data, p->data_len); lqt_finish_audio_vbr_frame(file, track, samples); if(result) return 0; else return 1; } else { quicktime_write_chunk_header(file, atrack->track); result = quicktime_write_data(file, p->data, p->data_len); atrack->track->chunk_samples = samples; quicktime_write_chunk_footer(file, atrack->track); atrack->cur_chunk++; if(result) return 0; else return 1; } return 0; } int lqt_write_video_packet(quicktime_t * file, lqt_packet_t * p, int track) { int result; quicktime_video_map_t *vtrack = &file->vtracks[track]; quicktime_trak_t * trak = vtrack->track; // fprintf(stderr, "lqt_write_video_packet %ld %d\n", // p->timestamp, p->duration); lqt_start_encoding(file); /* Must set valid timestamp for encoders */ quicktime_write_chunk_header(file, vtrack->track); if(vtrack->codec->write_packet) result = vtrack->codec->write_packet(file, p, track); else result = !quicktime_write_data(file, p->data, p->data_len); trak->chunk_samples = 1; quicktime_write_chunk_footer(file, trak); if(p->flags && LQT_PACKET_KEYFRAME) quicktime_insert_keyframe(file, vtrack->current_position, track); /* Update stts */ quicktime_update_stts(&trak->mdia.minf.stbl.stts, vtrack->current_position, p->duration); if(vtrack->ci.flags & LQT_COMPRESSION_HAS_B_FRAMES) { /* CTS = PTS - DTS */ quicktime_update_ctts(&trak->mdia.minf.stbl.ctts, vtrack->current_position, p->timestamp - vtrack->timestamp); } vtrack->timestamp += p->duration; vtrack->cur_chunk++; vtrack->current_position++; return result; } static const struct { lqt_compression_id_t id; const char * name; } compression_ids[] = { /* Audio */ { LQT_COMPRESSION_ALAW, "alaw" }, { LQT_COMPRESSION_ULAW, "ulaw" }, { LQT_COMPRESSION_MP3, "mp3" }, { LQT_COMPRESSION_AC3, "ac3" }, { LQT_COMPRESSION_AAC, "aac" }, /* Video */ { LQT_COMPRESSION_JPEG, "jpeg" }, { LQT_COMPRESSION_PNG, "png" }, { LQT_COMPRESSION_TIFF, "tiff" }, { LQT_COMPRESSION_TGA, "tga" }, { LQT_COMPRESSION_MPEG4_ASP, "mpeg4" }, { LQT_COMPRESSION_H264, "h264" }, { LQT_COMPRESSION_DIRAC, "dirac" }, { LQT_COMPRESSION_D10, "d10" }, { LQT_COMPRESSION_DV, "dv" }, }; const char * lqt_compression_id_to_string(lqt_compression_id_t id) { int i; for(i = 0; i < sizeof(compression_ids)/sizeof(compression_ids[0]); i++) { if(compression_ids[i].id == id) return compression_ids[i].name; } return NULL; } lqt_compression_id_t lqt_compression_id_from_string(const char * str) { int i; for(i = 0; i < sizeof(compression_ids)/sizeof(compression_ids[0]); i++) { if(!strcmp(compression_ids[i].name, str)) return compression_ids[i].id; } return LQT_COMPRESSION_NONE; } void lqt_compression_info_dump(const lqt_compression_info_t * ci) { int is_video = (ci->id >= 0x10000); lqt_dump("%s compression info\n", (is_video ? "Video" : "Audio")); lqt_dump(" Codec: %s\n", lqt_compression_id_to_string(ci->id)); if(ci->bitrate) { if(ci->bitrate < 0) lqt_dump(" Bitrate: Variable\n"); else lqt_dump(" Bitrate: %d\n", ci->bitrate); } if(is_video) { lqt_dump(" Image size: %d x %d\n", ci->width, ci->height); lqt_dump(" Pixel size: %d x %d\n", ci->pixel_width, ci->pixel_height); lqt_dump(" Colormodel: %s\n", lqt_colormodel_to_string(ci->colormodel)); lqt_dump(" Frame types: I"); if(ci->flags & LQT_COMPRESSION_HAS_P_FRAMES) lqt_dump(", P"); if(ci->flags & LQT_COMPRESSION_HAS_B_FRAMES) lqt_dump(", B"); lqt_dump("\n"); } else { lqt_dump(" Samplerate: %d\n", ci->samplerate); lqt_dump(" Channels: %d\n", ci->num_channels); lqt_dump(" SBR: %s\n", (ci->flags & LQT_COMPRESSION_SBR ? "Yes" : "No")); } } void lqt_compression_info_copy(lqt_compression_info_t * dst, const lqt_compression_info_t * src) { memcpy(dst, src, sizeof(*dst)); if(dst->global_header) { dst->global_header = malloc(dst->global_header_len); memcpy(dst->global_header, src->global_header, dst->global_header_len); } } void lqt_compression_info_set_header(lqt_compression_info_t * info, uint8_t * header, int header_len) { info->global_header = malloc(header_len); memcpy(info->global_header, header, header_len); info->global_header_len = header_len; } void lqt_packet_dump(const lqt_packet_t * p) { lqt_dump("Packet: %d bytes, Time: %"PRId64", Duration: %d, Keyframe: %d\n", p->data_len, p->timestamp, p->duration, !!(p->flags & LQT_PACKET_KEYFRAME)); lqt_hexdump(p->data, p->data_len > 16 ? 16 : p->data_len, 16); } libquicktime-1.2.4/src/nmhd.c0000644000175000017500000000360611511622757013016 00000000000000/******************************************************************************* nmhd.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" int quicktime_nmhd_init(quicktime_nmhd_t *nmhd) { return 0; } int quicktime_nmhd_delete(quicktime_nmhd_t *nmhd) { return 0; } void quicktime_nmhd_dump(quicktime_nmhd_t *nmhd) { lqt_dump(" null media header (nmhd)\n"); lqt_dump(" version %d\n", nmhd->version); lqt_dump(" flags %ld\n", nmhd->flags); } int quicktime_read_nmhd(quicktime_t *file, quicktime_nmhd_t *nmhd) { nmhd->version = quicktime_read_char(file); nmhd->flags = quicktime_read_int24(file); return 0; } void quicktime_write_nmhd(quicktime_t *file, quicktime_nmhd_t *nmhd) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "nmhd"); quicktime_write_char(file, nmhd->version); quicktime_write_int24(file, nmhd->flags); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/matrix.c0000644000175000017500000000354211511622756013372 00000000000000/******************************************************************************* matrix.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" void quicktime_matrix_init(quicktime_matrix_t *matrix) { int i; for(i = 0; i < 9; i++) matrix->values[i] = 0; matrix->values[0] = matrix->values[4] = 1; matrix->values[8] = 16384; } void quicktime_matrix_delete(quicktime_matrix_t *matrix) { } void quicktime_read_matrix(quicktime_t *file, quicktime_matrix_t *matrix) { int i = 0; for(i = 0; i < 9; i++) { matrix->values[i] = quicktime_read_fixed32(file); } } void quicktime_matrix_dump(quicktime_matrix_t *matrix) { int i; lqt_dump(" matrix"); for(i = 0; i < 9; i++) lqt_dump(" %f", matrix->values[i]); lqt_dump("\n"); } void quicktime_write_matrix(quicktime_t *file, quicktime_matrix_t *matrix) { int i; for(i = 0; i < 9; i++) { quicktime_write_fixed32(file, matrix->values[i]); } } libquicktime-1.2.4/src/clap.c0000644000175000017500000000731711511622756013011 00000000000000/******************************************************************************* clap.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ /* Init, read, write handler for the "clap" (Clean Aperture) atom. */ #include "lqt_private.h" #include void quicktime_clap_init(quicktime_clap_t *clap) { memset(clap, 0, sizeof (*clap)); } void quicktime_clap_delete(quicktime_clap_t *clap) { } void quicktime_clap_dump(quicktime_clap_t *clap) { lqt_dump(" clean aperture (clap)\n"); lqt_dump(" cleanApertureWidthN %d\n", clap->cleanApertureWidthN); lqt_dump(" cleanApertureWidthD %d\n", clap->cleanApertureWidthD); lqt_dump(" cleanApertureHeightN %d\n", clap->cleanApertureHeightN); lqt_dump(" cleanApertureHeightD %d\n", clap->cleanApertureHeightD); lqt_dump(" horizOffN %d\n", clap->horizOffN); lqt_dump(" horizOffD %d\n", clap->horizOffD); lqt_dump(" vertOffN %d\n", clap->vertOffN); lqt_dump(" vertOffD %d\n", clap->vertOffD); } void quicktime_read_clap(quicktime_t *file, quicktime_clap_t *clap) { clap->cleanApertureWidthN = quicktime_read_int32(file); clap->cleanApertureWidthD = quicktime_read_int32(file); clap->cleanApertureHeightN = quicktime_read_int32(file); clap->cleanApertureHeightD = quicktime_read_int32(file); clap->horizOffN = quicktime_read_int32(file); clap->horizOffD = quicktime_read_int32(file); clap->vertOffN = quicktime_read_int32(file); clap->vertOffD = quicktime_read_int32(file); } void quicktime_write_clap(quicktime_t *file, quicktime_clap_t *clap) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "clap"); quicktime_write_int32(file, clap->cleanApertureWidthN); quicktime_write_int32(file, clap->cleanApertureWidthD); quicktime_write_int32(file, clap->cleanApertureHeightN); quicktime_write_int32(file, clap->cleanApertureHeightD); quicktime_write_int32(file, clap->horizOffN); quicktime_write_int32(file, clap->horizOffD); quicktime_write_int32(file, clap->vertOffN); quicktime_write_int32(file, clap->vertOffD); quicktime_atom_write_footer(file, &atom); } int lqt_set_clap(quicktime_t *file, int track, quicktime_clap_t *clap) { quicktime_clap_t *trk_clap; if ((track < 0) || (track >= file->total_vtracks)) return 0; trk_clap = &file->vtracks[track].track->mdia.minf.stbl.stsd.table->clap; *trk_clap = *clap; file->vtracks[track].track->mdia.minf.stbl.stsd.table->has_clap = 1; return 1; } int lqt_get_clap(quicktime_t *file, int track, quicktime_clap_t *clap) { quicktime_clap_t *trk_clap; if ((track < 0) || (track >= file->total_vtracks)) return 0; if (!file->vtracks[track].track->mdia.minf.stbl.stsd.table->has_clap) return 0; trk_clap = &file->vtracks[track].track->mdia.minf.stbl.stsd.table->clap; *clap = *trk_clap; return 1; } libquicktime-1.2.4/src/audio.c0000644000175000017500000003507011511622756013170 00000000000000/******************************************************************************* audio.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #define LOG_DOMAIN "audio" /*************************************************** * Audio conversion functions ***************************************************/ #define RECLIP(val, min, max) (valmax)?max:val)) /* Conversion Macros */ /* int8 -> */ #define INT8_TO_INT16(src, dst) dst = src * 0x0101 #define INT8_TO_FLOAT(src, dst) dst = (float)src / 128.0 /* uint8 -> */ #define UINT8_TO_INT16(src, dst) dst = (src - 128) * 0x0101 #define UINT8_TO_FLOAT(src, dst) dst = (float)src / 127.0 - 1.0 /* int16 -> */ #define INT16_TO_INT8(src, dst) dst = src >> 8 #define INT16_TO_UINT8(src, dst) dst = (src ^ 0x8000) >> 8 #define INT16_TO_INT16(src, dst) dst = src #define INT16_TO_INT32(src, dst) dst = src * 0x00010001 #define INT16_TO_FLOAT(src, dst) dst = (float)src / 32767.0f #define INT16_TO_DOUBLE(src, dst) dst = (double)src / 32767.0 /* int32 -> */ #define INT32_TO_INT16(src, dst) dst = src >> 16 #define INT32_TO_FLOAT(src, dst) dst = (float)src / 2147483647.0 /* float -> */ #define FLOAT_TO_INT8(src, dst) tmp = (int)(src * 127.0); dst = RECLIP(tmp, -128, 127) #define FLOAT_TO_UINT8(src, dst) tmp = (int)((src + 1.0) * 127.0); dst = RECLIP(tmp, 0, 255) #define FLOAT_TO_INT16(src, dst) tmp = (int)((src) * 32767.0); dst = RECLIP(tmp, -32768, 32767) #define FLOAT_TO_INT32(src, dst) tmp = (int64_t)((src) * 2147483647.0); dst = RECLIP(tmp, -2147483648LL, 2147483647LL) #define FLOAT_TO_FLOAT(src, dst) dst = src #define FLOAT_TO_DOUBLE(src, dst) dst = src #define DOUBLE_TO_INT16(src, dst) tmp = (int)((src) * 32767.0); dst = RECLIP(tmp, -32768, 32767) #define DOUBLE_TO_FLOAT(src, dst) dst = src /* Encoding */ static void encode_int16_to_int8(int16_t ** in, void * _out, int num_channels, int num_samples) { int i, j; int8_t * out; for(i = 0; i < num_channels; i++) { out = ((int8_t*)_out) + i; for(j = 0; j < num_samples; j++) { INT16_TO_INT8(in[i][j], (*out)); out+=num_channels; } } } static void encode_int16_to_uint8(int16_t ** in, void * _out, int num_channels, int num_samples) { int i, j; uint8_t * out; for(i = 0; i < num_channels; i++) { out = ((uint8_t*)_out) + i; for(j = 0; j < num_samples; j++) { INT16_TO_UINT8(in[i][j], (*out)); out+=num_channels; } } } static void encode_int16_to_int16(int16_t ** in, void * _out, int num_channels, int num_samples) { int i, j; int16_t * out; for(i = 0; i < num_channels; i++) { out = ((int16_t*)_out) + i; for(j = 0; j < num_samples; j++) { INT16_TO_INT16(in[i][j], (*out)); out+=num_channels; } } } static void encode_int16_to_int32(int16_t ** in, void * _out, int num_channels, int num_samples) { int i, j; int32_t * out; for(i = 0; i < num_channels; i++) { out = ((int32_t*)_out) + i; for(j = 0; j < num_samples; j++) { INT16_TO_INT32(in[i][j], (*out)); out+=num_channels; } } } static void encode_int16_to_float(int16_t ** in, void * _out, int num_channels, int num_samples) { int i, j; float * out; for(i = 0; i < num_channels; i++) { out = ((float*)_out) + i; for(j = 0; j < num_samples; j++) { INT16_TO_FLOAT(in[i][j], (*out)); out+=num_channels; } } } static void encode_int16_to_double(int16_t ** in, void * _out, int num_channels, int num_samples) { int i, j; double * out; for(i = 0; i < num_channels; i++) { out = ((double*)_out) + i; for(j = 0; j < num_samples; j++) { INT16_TO_DOUBLE(in[i][j], (*out)); out+=num_channels; } } } static void encode_float_to_int8(float ** in, void * _out, int num_channels, int num_samples) { int i, j, tmp; int8_t * out; for(i = 0; i < num_channels; i++) { out = ((int8_t*)_out) + i; for(j = 0; j < num_samples; j++) { FLOAT_TO_INT8(in[i][j], (*out)); out+=num_channels; } } } static void encode_float_to_uint8(float ** in, void * _out, int num_channels, int num_samples) { int i, j, tmp; uint8_t * out; for(i = 0; i < num_channels; i++) { out = ((uint8_t*)_out) + i; for(j = 0; j < num_samples; j++) { FLOAT_TO_UINT8(in[i][j], (*out)); out+=num_channels; } } } static void encode_float_to_int16(float ** in, void * _out, int num_channels, int num_samples) { int i, j, tmp; int16_t * out; for(i = 0; i < num_channels; i++) { out = ((int16_t*)_out) + i; for(j = 0; j < num_samples; j++) { FLOAT_TO_INT16(in[i][j], (*out)); out+=num_channels; } } } static void encode_float_to_int32(float ** in, void * _out, int num_channels, int num_samples) { int i, j; int64_t tmp; int32_t * out; for(i = 0; i < num_channels; i++) { out = ((int32_t*)_out) + i; for(j = 0; j < num_samples; j++) { FLOAT_TO_INT32(in[i][j], (*out)); out+=num_channels; } } } static void encode_float_to_float(float ** in, void * _out, int num_channels, int num_samples) { int i, j; float * out; for(i = 0; i < num_channels; i++) { out = ((float*)_out) + i; for(j = 0; j < num_samples; j++) { FLOAT_TO_FLOAT(in[i][j], (*out)); out+=num_channels; } } } static void encode_float_to_double(float ** in, void * _out, int num_channels, int num_samples) { int i, j; double * out; for(i = 0; i < num_channels; i++) { out = ((double*)_out) + i; for(j = 0; j < num_samples; j++) { FLOAT_TO_DOUBLE(in[i][j], (*out)); out+=num_channels; } } } void lqt_convert_audio_encode(quicktime_t * file, int16_t ** in_int, float ** in_float, void * out, int num_channels, int num_samples, lqt_sample_format_t stream_format) { switch(stream_format) { case LQT_SAMPLE_INT8: if(in_int) encode_int16_to_int8(in_int, out, num_channels, num_samples); else if(in_float) encode_float_to_int8(in_float, out, num_channels, num_samples); break; case LQT_SAMPLE_UINT8: if(in_int) encode_int16_to_uint8(in_int, out, num_channels, num_samples); else if(in_float) encode_float_to_uint8(in_float, out, num_channels, num_samples); break; case LQT_SAMPLE_INT16: if(in_int) encode_int16_to_int16(in_int, out, num_channels, num_samples); else if(in_float) encode_float_to_int16(in_float, out, num_channels, num_samples); break; case LQT_SAMPLE_INT32: if(in_int) encode_int16_to_int32(in_int, out, num_channels, num_samples); else if(in_float) encode_float_to_int32(in_float, out, num_channels, num_samples); break; case LQT_SAMPLE_FLOAT: if(in_int) encode_int16_to_float(in_int, out, num_channels, num_samples); else if(in_float) encode_float_to_float(in_float, out, num_channels, num_samples); break; case LQT_SAMPLE_DOUBLE: if(in_int) encode_int16_to_double(in_int, out, num_channels, num_samples); else if(in_float) encode_float_to_double(in_float, out, num_channels, num_samples); break; case LQT_SAMPLE_UNDEFINED: lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "Cannot encode samples: Stream format undefined"); break; } } /* Decoding */ static void decode_int8_to_int16(void * _in, int16_t ** out, int num_channels, int num_samples) { int i, j; int8_t * in; for(i = 0; i < num_channels; i++) { if(out[i]) { in = ((int8_t*)_in) + i; for(j = 0; j < num_samples; j++) { INT8_TO_INT16((*in), out[i][j]); in += num_channels; } } } } static void decode_uint8_to_int16(void * _in, int16_t ** out, int num_channels, int num_samples) { int i, j; uint8_t * in; for(i = 0; i < num_channels; i++) { if(out[i]) { in = ((uint8_t*)_in) + i; for(j = 0; j < num_samples; j++) { UINT8_TO_INT16((*in), out[i][j]); in += num_channels; } } } } static void decode_int16_to_int16(void * _in, int16_t ** out, int num_channels, int num_samples) { int i, j; int16_t * in; for(i = 0; i < num_channels; i++) { if(out[i]) { in = ((int16_t*)_in) + i; for(j = 0; j < num_samples; j++) { INT16_TO_INT16((*in), out[i][j]); in += num_channels; } } } } static void decode_int32_to_int16(void * _in, int16_t ** out, int num_channels, int num_samples) { int i, j; int32_t * in; for(i = 0; i < num_channels; i++) { if(out[i]) { in = ((int32_t*)_in) + i; for(j = 0; j < num_samples; j++) { INT32_TO_INT16((*in), out[i][j]); in += num_channels; } } } } static void decode_float_to_int16(void * _in, int16_t ** out, int num_channels, int num_samples) { int i, j, tmp; float * in; for(i = 0; i < num_channels; i++) { if(out[i]) { in = ((float*)_in) + i; for(j = 0; j < num_samples; j++) { FLOAT_TO_INT16((*in), out[i][j]); in += num_channels; } } } } static void decode_double_to_int16(void * _in, int16_t ** out, int num_channels, int num_samples) { int i, j, tmp; double * in; for(i = 0; i < num_channels; i++) { if(out[i]) { in = ((double*)_in) + i; for(j = 0; j < num_samples; j++) { DOUBLE_TO_INT16((*in), out[i][j]); in += num_channels; } } } } static void decode_int8_to_float(void * _in, float ** out, int num_channels, int num_samples) { int i, j; int8_t * in; for(i = 0; i < num_channels; i++) { if(out[i]) { in = ((int8_t*)_in) + i; for(j = 0; j < num_samples; j++) { INT8_TO_FLOAT((*in), out[i][j]); in += num_channels; } } } } static void decode_uint8_to_float(void * _in, float ** out, int num_channels, int num_samples) { int i, j; uint8_t * in; for(i = 0; i < num_channels; i++) { if(out[i]) { in = ((uint8_t*)_in) + i; for(j = 0; j < num_samples; j++) { UINT8_TO_FLOAT((*in), out[i][j]); in += num_channels; } } } } static void decode_int16_to_float(void * _in, float ** out, int num_channels, int num_samples) { int i, j; int16_t * in; for(i = 0; i < num_channels; i++) { if(out[i]) { in = ((int16_t*)_in) + i; for(j = 0; j < num_samples; j++) { INT16_TO_FLOAT((*in), out[i][j]); in += num_channels; } } } } static void decode_int32_to_float(void * _in, float ** out, int num_channels, int num_samples) { int i, j; int32_t * in; for(i = 0; i < num_channels; i++) { if(out[i]) { in = ((int32_t*)_in) + i; for(j = 0; j < num_samples; j++) { INT32_TO_FLOAT((*in), out[i][j]); in += num_channels; } } } } static void decode_float_to_float(void * _in, float ** out, int num_channels, int num_samples) { int i, j; float * in; for(i = 0; i < num_channels; i++) { if(out[i]) { in = ((float*)_in) + i; for(j = 0; j < num_samples; j++) { FLOAT_TO_FLOAT((*in), out[i][j]); in += num_channels; } } } } static void decode_double_to_float(void * _in, float ** out, int num_channels, int num_samples) { int i, j; double * in; for(i = 0; i < num_channels; i++) { if(out[i]) { in = ((double*)_in) + i; for(j = 0; j < num_samples; j++) { DOUBLE_TO_FLOAT((*in), out[i][j]); in += num_channels; } } } } void lqt_convert_audio_decode(quicktime_t * file, void * in, int16_t ** out_int, float ** out_float, int num_channels, int num_samples, lqt_sample_format_t stream_format) { switch(stream_format) { case LQT_SAMPLE_INT8: if(out_int) decode_int8_to_int16(in, out_int, num_channels, num_samples); if(out_float) decode_int8_to_float(in, out_float, num_channels, num_samples); break; case LQT_SAMPLE_UINT8: if(out_int) decode_uint8_to_int16(in, out_int, num_channels, num_samples); if(out_float) decode_uint8_to_float(in, out_float, num_channels, num_samples); break; case LQT_SAMPLE_INT16: if(out_int) decode_int16_to_int16(in, out_int, num_channels, num_samples); if(out_float) decode_int16_to_float(in, out_float, num_channels, num_samples); break; case LQT_SAMPLE_INT32: if(out_int) decode_int32_to_int16(in, out_int, num_channels, num_samples); if(out_float) decode_int32_to_float(in, out_float, num_channels, num_samples); break; case LQT_SAMPLE_FLOAT: /* Float is ALWAYS machine native */ if(out_int) decode_float_to_int16(in, out_int, num_channels, num_samples); if(out_float) decode_float_to_float(in, out_float, num_channels, num_samples); break; case LQT_SAMPLE_DOUBLE: /* Float is ALWAYS machine native */ if(out_int) decode_double_to_int16(in, out_int, num_channels, num_samples); if(out_float) decode_double_to_float(in, out_float, num_channels, num_samples); break; case LQT_SAMPLE_UNDEFINED: lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "Cannot decode samples: Stream format undefined"); break; } } libquicktime-1.2.4/src/avi_riff.c0000644000175000017500000003226611511622756013660 00000000000000/******************************************************************************* avi_riff.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include #define LOG_DOMAIN "avi_riff" void quicktime_read_riff(quicktime_t *file, quicktime_atom_t *parent_atom) { quicktime_riff_t *riff = quicktime_new_riff(file); quicktime_atom_t leaf_atom; int result = 0; uint8_t data[5]; riff->atom = *parent_atom; // AVI quicktime_read_data(file, data, 4); // Certain AVI parameters must be copied over to quicktime objects: // hdrl -> moov // movi -> mdat // idx1 -> moov do { result = quicktime_atom_read_header(file, &leaf_atom); if(!result) { if(quicktime_atom_is(&leaf_atom, "LIST")) { data[4] = 0; result = !quicktime_read_data(file, data, 4); if(!result) { // Got LIST 'hdrl' if(quicktime_match_32(data, "hdrl")) { // No size here. quicktime_read_hdrl(file, &riff->hdrl, &leaf_atom); riff->have_hdrl = 1; } else if(quicktime_match_32(data, "movi")) // Got LIST 'movi' { quicktime_read_movi(file, &leaf_atom, &riff->movi); } else if(quicktime_match_32(data, "INFO")) { quicktime_read_riffinfo(file, &riff->info, &leaf_atom); riff->have_info = 1; } else // Skip it quicktime_atom_skip(file, &leaf_atom); } } else // Got 'movi' if(quicktime_atom_is(&leaf_atom, "movi")) { quicktime_read_movi(file, &leaf_atom, &riff->movi); } // Got 'idx1' original index else if(quicktime_atom_is(&leaf_atom, "idx1")) { // Preload idx1 here int64_t start_position = quicktime_position(file); long temp_size = leaf_atom.end - start_position; unsigned char *temp = malloc(temp_size); quicktime_set_preload(file, (temp_size < 0x100000) ? 0x100000 : temp_size); quicktime_read_data(file, temp, temp_size); quicktime_set_position(file, start_position); free(temp); // Read idx1 quicktime_read_idx1(file, riff, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "INFO")) { quicktime_read_riffinfo(file, &riff->info, &leaf_atom); riff->have_info = 1; } else /* Skip it */ { quicktime_atom_skip(file, &leaf_atom); } } }while(!result && quicktime_position(file) < parent_atom->end); } quicktime_riff_t* quicktime_new_riff(quicktime_t *file) { if(file->total_riffs >= MAX_RIFFS) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "file->total_riffs >= MAX_RIFFS"); return 0; } else { quicktime_riff_t *riff = calloc(1, sizeof(quicktime_riff_t)); file->riff[file->total_riffs++] = riff; return riff; } } void quicktime_delete_riff(quicktime_t *file, quicktime_riff_t *riff) { if(riff->have_hdrl) quicktime_delete_hdrl(file, &riff->hdrl); quicktime_delete_movi(file, &riff->movi); quicktime_delete_idx1(&riff->idx1); quicktime_delete_riffinfo(&riff->info); free(riff); } void quicktime_init_riff(quicktime_t *file) { // quicktime_atom_t junk_atom; int i; // Create new RIFF quicktime_riff_t *riff = quicktime_new_riff(file); // Write riff header // RIFF 'AVI ' quicktime_atom_write_header(file, &riff->atom, "RIFF"); // Write header list in first RIFF only if(file->total_riffs < 2) { quicktime_write_char32(file, "AVI "); quicktime_init_hdrl(file, &riff->hdrl); riff->have_hdrl = 1; quicktime_init_riffinfo(&riff->info); #if 1 quicktime_udta_2_riffinfo(&file->moov.udta, &riff->info); quicktime_write_riffinfo(file, &riff->info); riff->have_info = 1; #endif #if 0 /* Write JUNK once more */ quicktime_atom_write_header(file, &junk_atom, "JUNK"); for(i = 0; i < 256; i++) { quicktime_write_int32(file, 0); } quicktime_atom_write_footer(file, &junk_atom); #endif } else quicktime_write_char32(file, "AVIX"); quicktime_init_movi(file, riff); if(file->file_type == LQT_FILE_AVI_ODML) { for(i = 0; i < file->moov.total_tracks; i++) { quicktime_indx_init_riff(file, file->moov.trak[i]); } } } void quicktime_finalize_riff(quicktime_t *file, quicktime_riff_t *riff) { int i; // Write partial indexes if(file->file_type == LQT_FILE_AVI_ODML) { for(i = 0; i < file->moov.total_tracks; i++) { quicktime_indx_finalize_riff(file, file->moov.trak[i]); } } quicktime_finalize_movi(file, &riff->movi); if(riff->have_hdrl) { quicktime_finalize_hdrl(file, &riff->hdrl); // Write original index for first RIFF quicktime_write_idx1(file, &riff->idx1); } quicktime_atom_write_footer(file, &riff->atom); } /* * Get the number of audio samples corresponding to a number of bytes * in an audio stream. * * Update all arguments for which pointers are passed */ static int bytes_to_samples(quicktime_strl_t * strl, int bytes, int samplerate) { int64_t total_samples; int ret; strl->total_bytes += bytes; if(strl->strf.wf.f.WAVEFORMAT.nBlockAlign) { strl->total_blocks = (strl->total_bytes + strl->strf.wf.f.WAVEFORMAT.nBlockAlign - 1) / strl->strf.wf.f.WAVEFORMAT.nBlockAlign; } else strl->total_blocks++; if((strl->strh.dwSampleSize == 0) && (strl->strh.dwScale > 1)) { /* variable bitrate */ total_samples = (samplerate * strl->total_blocks * strl->strh.dwScale) / strl->strh.dwRate; } else { /* constant bitrate */ if(strl->strf.wf.f.WAVEFORMAT.nBlockAlign) { total_samples = (strl->total_bytes * strl->strh.dwScale * samplerate) / (strl->strf.wf.f.WAVEFORMAT.nBlockAlign * strl->strh.dwRate); } else { total_samples = (samplerate * strl->total_bytes * strl->strh.dwScale) / (strl->strh.dwSampleSize * strl->strh.dwRate); } } /* Update stuff */ ret = total_samples - strl->total_samples; strl->total_samples = total_samples; return ret; } /* Insert audio chunk from idx1 into quicktime indices */ #define NUM_ALLOC 1024 static void insert_audio_packet(quicktime_trak_t * trak, int64_t offset, int size) { int num_samples; quicktime_stco_t *stco; quicktime_stsc_t *stsc; quicktime_stts_t *stts = &trak->mdia.minf.stbl.stts; /* Update stco */ stco = &trak->mdia.minf.stbl.stco; quicktime_update_stco(stco, stco->total_entries, offset); /* Update stsc */ num_samples = bytes_to_samples(trak->strl, size, trak->mdia.minf.stbl.stsd.table[0].samplerate); stsc = &trak->mdia.minf.stbl.stsc; /* stsc will be initialized with 1 entry and zero samples */ if(stsc->table[0].samples == 0) quicktime_update_stsc(stsc, 0, num_samples); else quicktime_update_stsc(stsc, stsc->total_entries, num_samples); /* Update total samples */ stts->table[0].sample_count += num_samples; if(trak->chunk_sizes_alloc < stco->total_entries) { trak->chunk_sizes = realloc(trak->chunk_sizes, sizeof(*trak->chunk_sizes) * (trak->chunk_sizes_alloc + NUM_ALLOC)); memset(trak->chunk_sizes + trak->chunk_sizes_alloc, 0, sizeof(*trak->chunk_sizes) * NUM_ALLOC); trak->chunk_sizes_alloc += NUM_ALLOC; } trak->chunk_sizes[stco->total_entries - 1] = size; } #undef NUM_ALLOC /* Insert video chunk from idx1 into quicktime indices */ static void insert_video_packet(quicktime_trak_t * trak, int64_t offset, int size, int keyframe) { quicktime_stss_t *stss; quicktime_stco_t *stco = &trak->mdia.minf.stbl.stco; quicktime_stsz_t *stsz = &trak->mdia.minf.stbl.stsz; quicktime_stts_t *stts = &trak->mdia.minf.stbl.stts; /* If size is zero, the last frame will be repeated */ if(!size) { stts->table[stts->total_entries-1].sample_duration += stts->default_duration; return; } /* Update stco */ quicktime_update_stco(stco, stco->total_entries, offset); /* Update stss */ if(keyframe) { stss = &trak->mdia.minf.stbl.stss; if(stss->entries_allocated <= stss->total_entries) { stss->entries_allocated += 16; stss->table = realloc(stss->table, sizeof(quicktime_stss_table_t) * stss->entries_allocated); } stss->table[stss->total_entries++].sample = stsz->total_entries+1; } /* Update sample duration */ quicktime_update_stts(stts, stsz->total_entries, 0); /* Update sample size */ quicktime_update_stsz(stsz, stsz->total_entries, size); } /* Build index tables from an idx1 index */ static void idx1_build_index(quicktime_t *file) { int i; quicktime_idx1table_t *idx1table; quicktime_trak_t * trak; quicktime_riff_t *first_riff = file->riff[0]; quicktime_idx1_t *idx1 = &first_riff->idx1; int track_number; int64_t base_offset; if(idx1->table[0].offset == 4) base_offset = 8 + first_riff->movi.atom.start; else /* For invalid files, which have the index relative to file start */ base_offset = 8 + first_riff->movi.atom.start - (idx1->table[0].offset - 4); for(i = 0; i < idx1->table_size; i++) { idx1table = idx1->table + i; track_number = (idx1table->tag[0] - '0') * 10 + (idx1table->tag[1] - '0'); if((track_number < 0) || (track_number >= file->moov.total_tracks)) continue; trak = file->moov.trak[track_number]; if(trak->mdia.minf.is_audio) insert_audio_packet(trak, idx1table->offset + base_offset, idx1table->size); else if(trak->mdia.minf.is_video) insert_video_packet(trak, idx1table->offset + base_offset, idx1table->size, !!(idx1table->flags & AVI_KEYFRAME)); } } /* Build index tables from an indx index */ static void indx_build_index(quicktime_t *file) { int i, j, k; quicktime_trak_t * trak; quicktime_indx_t * indx; quicktime_ix_t *ix; for(i = 0; i < file->moov.total_tracks; i++) { trak = file->moov.trak[i]; indx = &trak->strl->indx; for(j = 0; j < indx->table_size; j++) { ix = indx->table[j].ix; for(k = 0; k < ix->table_size; k++) { if(trak->mdia.minf.is_audio) insert_audio_packet(trak, ix->base_offset + ix->table[k].relative_offset, ix->table[k].size & 0x7FFFFFFF); else if(trak->mdia.minf.is_video) insert_video_packet(trak, ix->base_offset + ix->table[k].relative_offset, ix->table[k].size & 0x7FFFFFFF, !(ix->table[k].size & 0x80000000)); } } } } /* * Import index tables */ int quicktime_import_avi(quicktime_t *file) { int i; quicktime_riff_t *first_riff = file->riff[0]; quicktime_idx1_t *idx1 = &first_riff->idx1; if(file->file_type == LQT_FILE_AVI) { if(!idx1->table_size) return 1; idx1_build_index(file); } else if(file->file_type == LQT_FILE_AVI_ODML) { indx_build_index(file); } /* Compress stts */ for(i = 0; i < file->moov.total_tracks; i++) { if(file->moov.trak[i]->mdia.minf.is_video) quicktime_compress_stts(&file->moov.trak[i]->mdia.minf.stbl.stts); } if(first_riff->have_info) { quicktime_riffinfo_2_udta(&first_riff->info, &file->moov.udta); } // quicktime_moov_dump(&file->moov); return 0; } void quicktime_riff_dump(quicktime_riff_t * riff) { int i = 0; if(riff->have_hdrl) { quicktime_avih_dump(&riff->hdrl.avih); while(riff->hdrl.strl[i]) { quicktime_strl_dump(riff->hdrl.strl[i]); i++; } if(riff->idx1.table_size) quicktime_idx1_dump(&riff->idx1); } } libquicktime-1.2.4/src/pasp.c0000644000175000017500000000771711511622757013042 00000000000000/******************************************************************************* pasp.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ /* Init, read, write handler for the "pasp" (Pixel Aspect) atom. */ #include "lqt_private.h" void quicktime_pasp_init(quicktime_pasp_t *pasp) { /* We use this also, if no pasp atom is explicitely present, since some codecs also set the pixel aspect ratio */ pasp->hSpacing = 1; pasp->vSpacing = 1; } void quicktime_pasp_delete(quicktime_pasp_t *pasp) { } void quicktime_pasp_dump(quicktime_pasp_t *pasp) { lqt_dump(" pixel aspect (pasp)\n"); lqt_dump(" hSpacing %d\n", pasp->hSpacing); lqt_dump(" vSpacing %d\n", pasp->vSpacing); } void quicktime_read_pasp(quicktime_t *file, quicktime_pasp_t *pasp) { pasp->hSpacing = quicktime_read_int32(file); pasp->vSpacing = quicktime_read_int32(file); } void quicktime_write_pasp(quicktime_t *file, quicktime_pasp_t *pasp) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "pasp"); quicktime_write_int32(file, pasp->hSpacing); quicktime_write_int32(file, pasp->vSpacing); quicktime_atom_write_footer(file, &atom); } int lqt_set_pasp(quicktime_t *file, int track, quicktime_pasp_t *pasp) { quicktime_pasp_t *trk_pasp; if ((track < 0) || (track >= file->total_vtracks)) return 0; trk_pasp = &file->vtracks[track].track->mdia.minf.stbl.stsd.table->pasp; trk_pasp->hSpacing = pasp->hSpacing; trk_pasp->vSpacing = pasp->vSpacing; file->vtracks[track].track->mdia.minf.stbl.stsd.table->has_pasp = 1; return 1; } int lqt_get_pasp(quicktime_t *file, int track, quicktime_pasp_t *pasp) { quicktime_pasp_t *trk_pasp; if ((track < 0) || (track >= file->total_vtracks)) return 0; if (!file->vtracks[track].track->mdia.minf.stbl.stsd.table->has_pasp) return 0; trk_pasp = &file->vtracks[track].track->mdia.minf.stbl.stsd.table->pasp; pasp->hSpacing = trk_pasp->hSpacing; pasp->vSpacing = trk_pasp->vSpacing; return 1; } int lqt_get_pixel_aspect(quicktime_t *file, int track, int * pixel_width, int * pixel_height) { quicktime_pasp_t *pasp; if ((track < 0) || (track >= file->total_vtracks)) return 0; pasp = &file->vtracks[track].track->mdia.minf.stbl.stsd.table->pasp; *pixel_width = pasp->hSpacing; *pixel_height = pasp->vSpacing; return 1; } int lqt_set_pixel_aspect(quicktime_t *file, int track, int pixel_width, int pixel_height) { quicktime_pasp_t *pasp; if ((track < 0) || (track >= file->total_vtracks)) return 0; pasp = &file->vtracks[track].track->mdia.minf.stbl.stsd.table->pasp; if(pixel_width == pixel_height) /* Don't write pasp atom */ { pasp->hSpacing = 1; pasp->vSpacing = 1; } else { pasp->hSpacing = pixel_width; pasp->vSpacing = pixel_height; file->vtracks[track].track->mdia.minf.stbl.stsd.table->has_pasp = 1; } return 1; } libquicktime-1.2.4/src/vmhd.c0000644000175000017500000000525011511622757013023 00000000000000/******************************************************************************* vmhd.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" void quicktime_vmhd_init(quicktime_vmhd_t *vmhd) { vmhd->version = 0; vmhd->flags = 1; vmhd->graphics_mode = 64; vmhd->opcolor[0] = 32768; vmhd->opcolor[1] = 32768; vmhd->opcolor[2] = 32768; } void quicktime_vmhd_init_video(quicktime_t *file, quicktime_vmhd_t *vmhd, int frame_w, int frame_h, int frame_duration, int timescale) { } void quicktime_vmhd_delete(quicktime_vmhd_t *vmhd) { } void quicktime_vmhd_dump(quicktime_vmhd_t *vmhd) { lqt_dump(" video media header (vmhd)\n"); lqt_dump(" version %d\n", vmhd->version); lqt_dump(" flags %ld\n", vmhd->flags); lqt_dump(" graphics_mode %d\n", vmhd->graphics_mode); lqt_dump(" opcolor %d %d %d\n", vmhd->opcolor[0], vmhd->opcolor[1], vmhd->opcolor[2]); } void quicktime_read_vmhd(quicktime_t *file, quicktime_vmhd_t *vmhd) { int i; vmhd->version = quicktime_read_char(file); vmhd->flags = quicktime_read_int24(file); vmhd->graphics_mode = quicktime_read_int16(file); for(i = 0; i < 3; i++) vmhd->opcolor[i] = quicktime_read_int16(file); } void quicktime_write_vmhd(quicktime_t *file, quicktime_vmhd_t *vmhd) { quicktime_atom_t atom; int i; quicktime_atom_write_header(file, &atom, "vmhd"); quicktime_write_char(file, vmhd->version); quicktime_write_int24(file, vmhd->flags); quicktime_write_int16(file, vmhd->graphics_mode); for(i = 0; i < 3; i++) quicktime_write_int16(file, vmhd->opcolor[i]); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/gmhd.c0000644000175000017500000000563311511622756013010 00000000000000/******************************************************************************* gmhd.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" void quicktime_gmhd_init(quicktime_gmhd_t *gmhd) { quicktime_gmin_init(&gmhd->gmin); } void quicktime_gmhd_init_timecode(quicktime_gmhd_t *gmhd) { quicktime_gmin_init(&gmhd->gmin); quicktime_tmcd_init(&gmhd->tmcd); gmhd->has_tmcd = 1; } void quicktime_gmhd_delete(quicktime_gmhd_t *gmhd) { quicktime_gmin_delete(&gmhd->gmin); quicktime_tmcd_delete(&gmhd->tmcd); } void quicktime_gmhd_dump(quicktime_gmhd_t *gmhd) { lqt_dump(" base media header (gmhd)\n"); quicktime_gmin_dump(&gmhd->gmin); if(gmhd->has_gmhd_text) quicktime_gmhd_text_dump(&gmhd->gmhd_text); if (gmhd->has_tmcd) quicktime_tmcd_dump(&gmhd->tmcd); } void quicktime_read_gmhd(quicktime_t *file, quicktime_gmhd_t *gmhd, quicktime_atom_t *parent_atom) { quicktime_atom_t leaf_atom; do { quicktime_atom_read_header(file, &leaf_atom); if(quicktime_atom_is(&leaf_atom, "gmin")) quicktime_read_gmin(file, &gmhd->gmin); else if(quicktime_atom_is(&leaf_atom, "text")) { quicktime_read_gmhd_text(file, &gmhd->gmhd_text, &leaf_atom); gmhd->has_gmhd_text = 1; } else if(quicktime_atom_is(&leaf_atom, "tmcd")) { quicktime_read_tmcd(file, &gmhd->tmcd, &leaf_atom); gmhd->has_tmcd = 1; } else quicktime_atom_skip(file, &leaf_atom); }while(quicktime_position(file) < parent_atom->end); } void quicktime_write_gmhd(quicktime_t *file, quicktime_gmhd_t *gmhd) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "gmhd"); quicktime_write_gmin(file, &gmhd->gmin); if(gmhd->has_gmhd_text) quicktime_write_gmhd_text(file, &gmhd->gmhd_text); if (gmhd->has_tmcd) quicktime_write_tmcd(file, &gmhd->tmcd); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/avi_strl.c0000644000175000017500000002671211511622756013715 00000000000000/******************************************************************************* avi_strl.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include // Update during close: // length // samples per chunk #define PADDING_SIZE 2048 /* Must be increased for codecs with really large extradata (like Vorbis in AVI), but we won't do such nonsense, will we? */ quicktime_strl_t* quicktime_new_strl() { quicktime_strl_t *strl = calloc(1, sizeof(quicktime_strl_t)); return strl; } void quicktime_init_strl(quicktime_t *file, quicktime_audio_map_t *atrack, quicktime_video_map_t *vtrack, quicktime_trak_t *trak, quicktime_strl_t *strl) { quicktime_atom_t list_atom; quicktime_atom_t junk_atom; int i; trak->strl = strl; /* Construct tag */ if(vtrack) { strl->tag[0] = '0' + (trak->tkhd.track_id - 1) / 10; strl->tag[1] = '0' + (trak->tkhd.track_id - 1) % 10; strl->tag[2] = 'd'; strl->tag[3] = 'c'; } else if(atrack) { strl->tag[0] = '0' + (trak->tkhd.track_id - 1) / 10; strl->tag[1] = '0' + (trak->tkhd.track_id - 1) % 10; strl->tag[2] = 'w'; strl->tag[3] = 'b'; } /* LIST 'strl' */ quicktime_atom_write_header(file, &list_atom, "LIST"); quicktime_write_char32(file, "strl"); /* vids */ if(vtrack) { strncpy(strl->strh.fccType, "vids", 4); strncpy(strl->strh.fccHandler, trak->mdia.minf.stbl.stsd.table[0].format, 4); /* framerate denominator */ strl->strh.dwScale = trak->mdia.minf.stbl.stts.table[0].sample_duration; /* framerate numerator */ strl->strh.dwRate = trak->mdia.mdhd.time_scale; strl->strh.dwQuality = 10000; // strl->strh.dwSampleSize = (int)(trak->tkhd.track_width * trak->tkhd.track_height) * 3; strl->strh.rcFrame.right = trak->tkhd.track_width; strl->strh.rcFrame.bottom = trak->tkhd.track_height; strl->is_video = 1; } else if(atrack) { strncpy(strl->strh.fccType, "auds", 4); strl->strh.dwQuality = -1; strl->is_audio = 1; } strl->strh_offset = quicktime_position(file); quicktime_write_strh(file, &strl->strh); /* strf */ if(vtrack) { strl->strf.bh.biSize = 40; strl->strf.bh.biWidth = trak->tkhd.track_width; strl->strf.bh.biHeight = trak->tkhd.track_height; strl->strf.bh.biPlanes = 1; strl->strf.bh.biBitCount = 24; strncpy(strl->strf.bh.biCompression, trak->mdia.minf.stbl.stsd.table[0].format, 4); strl->strf.bh.biSizeImage = trak->tkhd.track_width * trak->tkhd.track_height * 3; // biSizeImage quicktime_write_strf_video(file, &strl->strf); } else if(atrack) { /* By now the codec is instantiated so the WAV ID is available. */ strl->strf.wf.type = LQT_WAVEFORMAT_WAVEFORMATEX; strl->strf.wf.f.WAVEFORMAT.wFormatTag = atrack->wav_id; strl->strf.wf.f.WAVEFORMAT.nChannels = trak->mdia.minf.stbl.stsd.table[0].channels; strl->strf.wf.f.WAVEFORMAT.nSamplesPerSec = atrack->samplerate; quicktime_write_strf_audio(file, &strl->strf); } strl->end_pos = quicktime_position(file); /* We write junk for 2 reasons: * * 1. The strf chunks might grow * 2. The indx chunk might come as well */ quicktime_atom_write_header(file, &junk_atom, "JUNK"); for(i = 0; i < PADDING_SIZE; i ++) quicktime_write_char(file, 0); quicktime_atom_write_footer(file, &junk_atom); /* Initialize super index */ if(file->file_type == LQT_FILE_AVI_ODML) quicktime_init_indx(file, &strl->indx, strl); quicktime_atom_write_footer(file, &list_atom); } void quicktime_delete_strl(quicktime_strl_t *strl) { if(strl->is_video) quicktime_strf_delete_video(&strl->strf); if(strl->is_audio) quicktime_strf_delete_audio(&strl->strf); quicktime_delete_indx(&strl->indx); free(strl); } void quicktime_read_strl(quicktime_t *file, quicktime_strl_t *strl, quicktime_atom_t *parent_atom) { quicktime_atom_t leaf_atom; /* AVI translation: */ /* vids -> trak */ /* auds -> trak */ /* Only one track is in each strl object */ do { quicktime_atom_read_header(file, &leaf_atom); // strh if(quicktime_atom_is(&leaf_atom, "strh")) { quicktime_read_strh(file, &strl->strh, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "strf")) { if(quicktime_match_32(strl->strh.fccType, "vids")) quicktime_read_strf_video(file, &strl->strf, &leaf_atom); else if(quicktime_match_32(strl->strh.fccType, "auds")) quicktime_read_strf_audio(file, &strl->strf, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "indx")) // Super index. // Read the super index + all the partial indexes now { quicktime_read_indx(file, strl, &leaf_atom); strl->have_indx = 1; } quicktime_atom_skip(file, &leaf_atom); } while(quicktime_position(file) < parent_atom->end); } void quicktime_strl_2_qt(quicktime_t *file, quicktime_strl_t *strl) { // These are 0 if no track is currently being processed. // Set to 1 if audio or video track is being processed. uint8_t codec[4] = { 0x00, 0x00, 0x00, 0x00 }; // int denominator; // int numerator; int frame_duration = 0; int timescale = 0; int width = 0; int height = 0; int depth = 0; int frames = 0; int bytes_per_sample = 0; int bits_per_sample = 0; int samples; // int samples_per_chunk = 0; int channels = 0; int sample_rate = 0; // int bytes_per_second; quicktime_trak_t *trak = 0; /* AVI translation: */ /* vids -> trak */ /* auds -> trak */ /* Only one track is in each strl object */ if(quicktime_match_32(strl->strh.fccType, "vids")) { /* Video */ trak = quicktime_add_trak(file); trak->strl = strl; width = 0; height = 0; depth = 24; frames = 0; strl->is_video = 1; trak->tkhd.track_id = file->moov.mvhd.next_track_id; file->moov.mvhd.next_track_id++; if(strl->strh.dwScale != 0) { timescale = strl->strh.dwRate; frame_duration = strl->strh.dwScale; // frame_rate = (double)strl->dwRate / strl->dwScale; } else { // frame_rate = strl->dwRate; timescale = strl->strh.dwRate; frame_duration = 1; } frames = strl->strh.dwLength; // dwLength width = strl->strf.bh.biWidth; height = strl->strf.bh.biHeight; /* Depth in bits */ depth = strl->strf.bh.biBitCount; /* Generate quicktime structures */ quicktime_trak_init_video(file, trak, width, height, frame_duration, timescale, strl->strf.bh.biCompression); quicktime_mhvd_init_video(file, &file->moov.mvhd, timescale); trak->mdia.mdhd.duration = frames; // trak->mdia.mdhd.time_scale = 1; trak->mdia.minf.stbl.stsd.table[0].depth = depth; } else if(quicktime_match_32(strl->strh.fccType, "auds")) { trak = quicktime_add_trak(file); trak->strl = strl; channels = 2; sample_rate = 0; strl->is_audio = 1; trak->tkhd.track_id = file->moov.mvhd.next_track_id; file->moov.mvhd.next_track_id++; samples = strl->strh.dwLength; // dwLength bytes_per_sample = strl->strh.dwSampleSize; // dwSampleSize if(strl->strf.wf.type != LQT_WAVEFORMAT_WAVEFORMAT) { bits_per_sample = strl->strf.wf.f.PCMWAVEFORMAT.wBitsPerSample; } else bits_per_sample = 8; channels = strl->strf.wf.f.WAVEFORMAT.nChannels; sample_rate = strl->strf.wf.f.WAVEFORMAT.nSamplesPerSec; quicktime_trak_init_audio(file, trak, channels, sample_rate, bits_per_sample, (char*)codec); if((strl->strh.dwSampleSize == 0) && (strl->strh.dwScale > 1)) trak->mdia.minf.is_audio_vbr = 1; // We store a constant samples per chunk based on the // packet size if sample_size zero // and calculate the samples per chunk based on the chunk size if sample_size // is nonzero. // trak->mdia.minf.stbl.stsd.table[0].sample_size = bytes_per_sample; trak->mdia.minf.stbl.stsd.table[0].compression_id = strl->strf.wf.f.WAVEFORMAT.wFormatTag; /* Synthesize stsc table for constant samples per chunk */ if(!bytes_per_sample) { /* Should be enough entries allocated in quicktime_stsc_init_table */ trak->mdia.minf.stbl.stsc.table[0].samples = strl->strh.dwScale; trak->mdia.minf.stbl.stsc.total_entries = 1; } } } void quicktime_finalize_strl(quicktime_t *file, quicktime_trak_t * trak, quicktime_strl_t *strl) { int i; quicktime_atom_t junk_atom; int64_t old_pos, end_pos; /* Rewrite stream headers */ if(!strl->strh.dwLength) strl->strh.dwLength = quicktime_track_samples(file, trak); // if(trak->mdia.minf.is_audio) // strl->strh.dwSuggestedBufferSize = strl->strf.wf.f.WAVEFORMAT.nAvgBytesPerSec / 2; old_pos = quicktime_position(file); quicktime_set_position(file, strl->strh_offset); quicktime_write_strh(file, &strl->strh); if(trak->mdia.minf.is_video) { quicktime_write_strf_video(file, &strl->strf); } else if(trak->mdia.minf.is_audio) { quicktime_write_strf_audio(file, &strl->strf); } end_pos = quicktime_position(file); // Finalize super indexes if(file->file_type == LQT_FILE_AVI_ODML) strl->indx.offset = end_pos; quicktime_atom_write_header(file, &junk_atom, "JUNK"); for(i = 0; i < PADDING_SIZE - (end_pos - strl->end_pos); i ++) quicktime_write_char(file, 0); quicktime_atom_write_footer(file, &junk_atom); strl->indx.size = quicktime_position(file) - strl->indx.offset; } void quicktime_strl_dump(quicktime_strl_t *strl) { lqt_dump("strl\n"); quicktime_strh_dump(&strl->strh); if(!strncmp(strl->strh.fccType, "auds", 4)) quicktime_strf_dump_audio(&strl->strf); if(!strncmp(strl->strh.fccType, "vids", 4)) quicktime_strf_dump_video(&strl->strf); if(strl->have_indx) { quicktime_indx_dump(&strl->indx); } } libquicktime-1.2.4/src/Makefile.in0000644000175000017500000007257411735135716014005 00000000000000# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/avcodec.m4 \ $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/iconv.m4 \ $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/lqt_opt_cflags.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/vorbis.m4 \ $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libquicktime_la_DEPENDENCIES = am__libquicktime_la_SOURCES_DIST = audio.c lqt_codecs.c \ lqt_quicktime.c lqt_fseeko.c atom.c avi_avih.c avi_guid.c \ avi_hdrl.c avi_idx1.c avi_info.c avi_indx.c avi_ix.c \ avi_movi.c avi_odml.c avi_riff.c avi_strf.c avi_strh.c \ avi_strl.c chan.c charset.c clap.c cmodel_default.c \ cmodel_yuv420p.c cmodel_yuv422.c colormodels.c colr.c \ compression.c ctab.c ctts.c dinf.c dref.c edts.c elst.c enda.c \ esds.c fiel.c frma.c ftab.c ftyp.c gama.c gmhd.c gmhd_text.c \ gmin.c hdlr.c imgp.c impn.c iods.c language.c log.c matrix.c \ mdat.c mdhd.c mdia.c minf.c moov.c mvhd.c multichannel.c \ navg.c ndhd.c nloc.c nmhd.c obji.c pano.c pasp.c pdat.c pHdr.c \ qtatom.c qtvr.c smhd.c stbl.c stco.c stsc.c stsd.c stsdtable.c \ stss.c stsz.c stts.c texttrack.c timecode.c tkhd.c trak.c \ translation.c tcmi.c tmcd.c tref.c udta.c useratoms.c util.c \ vmhd.c vrsc.c vrnp.c vrni.c wave.c workarounds.c \ lqt_bufalloc.c lqt_codecfile.c lqt_color.c lqt_codecinfo.c \ lqt_divx.c lqt_qtvr.c @HAVE_FSEEKO_FALSE@am__objects_1 = lqt_fseeko.lo am__objects_2 = lqt_codecs.lo lqt_quicktime.lo $(am__objects_1) am_libquicktime_la_OBJECTS = audio.lo $(am__objects_2) atom.lo \ avi_avih.lo avi_guid.lo avi_hdrl.lo avi_idx1.lo avi_info.lo \ avi_indx.lo avi_ix.lo avi_movi.lo avi_odml.lo avi_riff.lo \ avi_strf.lo avi_strh.lo avi_strl.lo chan.lo charset.lo clap.lo \ cmodel_default.lo cmodel_yuv420p.lo cmodel_yuv422.lo \ colormodels.lo colr.lo compression.lo ctab.lo ctts.lo dinf.lo \ dref.lo edts.lo elst.lo enda.lo esds.lo fiel.lo frma.lo \ ftab.lo ftyp.lo gama.lo gmhd.lo gmhd_text.lo gmin.lo hdlr.lo \ imgp.lo impn.lo iods.lo language.lo log.lo matrix.lo mdat.lo \ mdhd.lo mdia.lo minf.lo moov.lo mvhd.lo multichannel.lo \ navg.lo ndhd.lo nloc.lo nmhd.lo obji.lo pano.lo pasp.lo \ pdat.lo pHdr.lo qtatom.lo qtvr.lo smhd.lo stbl.lo stco.lo \ stsc.lo stsd.lo stsdtable.lo stss.lo stsz.lo stts.lo \ texttrack.lo timecode.lo tkhd.lo trak.lo translation.lo \ tcmi.lo tmcd.lo tref.lo udta.lo useratoms.lo util.lo vmhd.lo \ vrsc.lo vrnp.lo vrni.lo wave.lo workarounds.lo lqt_bufalloc.lo \ lqt_codecfile.lo lqt_color.lo lqt_codecinfo.lo lqt_divx.lo \ lqt_qtvr.lo libquicktime_la_OBJECTS = $(am_libquicktime_la_OBJECTS) libquicktime_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libquicktime_la_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(libquicktime_la_SOURCES) DIST_SOURCES = $(am__libquicktime_la_SOURCES_DIST) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALSA_CFLAGS = @ALSA_CFLAGS@ ALSA_LIBS = @ALSA_LIBS@ AMTAR = @AMTAR@ AR = @AR@ AS = @AS@ ASFLAGS = @ASFLAGS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AVCODEC_CFLAGS = @AVCODEC_CFLAGS@ AVCODEC_LIBS = @AVCODEC_LIBS@ AVCODEC_REQUIRED = @AVCODEC_REQUIRED@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FAAC_CFLAGS = @FAAC_CFLAGS@ FAAC_LIBS = @FAAC_LIBS@ FAAC_REQUIRED = @FAAC_REQUIRED@ FAAD2_CFLAGS = @FAAD2_CFLAGS@ FAAD2_LIBS = @FAAD2_LIBS@ FAAD2_REQUIRED = @FAAD2_REQUIRED@ FGREP = @FGREP@ GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ GL_LIBS = @GL_LIBS@ GMSGFMT = @GMSGFMT@ GMSGFMT_015 = @GMSGFMT_015@ GREP = @GREP@ GTKUTIL_LIBADD = @GTKUTIL_LIBADD@ GTK_CFLAGS = @GTK_CFLAGS@ GTK_LIBS = @GTK_LIBS@ GTK_REQUIRED = @GTK_REQUIRED@ ICONV_LIBS = @ICONV_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTLLIBS = @INTLLIBS@ INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ JPEG_CFLAGS = @JPEG_CFLAGS@ JPEG_LIBS = @JPEG_LIBS@ JPEG_REQUIRED = @JPEG_REQUIRED@ LAME_CFLAGS = @LAME_CFLAGS@ LAME_LIBS = @LAME_LIBS@ LAME_REQUIRED = @LAME_REQUIRED@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDV_CFLAGS = @LIBDV_CFLAGS@ LIBDV_LIBS = @LIBDV_LIBS@ LIBDV_REQUIRED = @LIBDV_REQUIRED@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBOBJS = @LIBOBJS@ LIBPNG_CFLAGS = @LIBPNG_CFLAGS@ LIBPNG_LIBS = @LIBPNG_LIBS@ LIBS = @LIBS@ LIBSWSCALE_CFLAGS = @LIBSWSCALE_CFLAGS@ LIBSWSCALE_LIBS = @LIBSWSCALE_LIBS@ LIBSWSCALE_REQUIRED = @LIBSWSCALE_REQUIRED@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LQT_CFLAGS = @LQT_CFLAGS@ LQT_CODEC_API_VERSION = @LQT_CODEC_API_VERSION@ LQT_LIBS = @LQT_LIBS@ LQT_VERSION = @LQT_VERSION@ LQT_VERSION_MAJOR = @LQT_VERSION_MAJOR@ LQT_VERSION_MICRO = @LQT_VERSION_MICRO@ LQT_VERSION_MINOR = @LQT_VERSION_MINOR@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MODULE_LIBADD = @MODULE_LIBADD@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OSSAUDIO_LIBS = @OSSAUDIO_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PLUGIN_DIR = @PLUGIN_DIR@ PNG_REQUIRED = @PNG_REQUIRED@ POSUB = @POSUB@ RANLIB = @RANLIB@ SCHROEDINGER_CFLAGS = @SCHROEDINGER_CFLAGS@ SCHROEDINGER_LIBS = @SCHROEDINGER_LIBS@ SCHROEDINGER_REQUIRED = @SCHROEDINGER_REQUIRED@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SNDIO_CFLAGS = @SNDIO_CFLAGS@ SNDIO_LIBS = @SNDIO_LIBS@ STRIP = @STRIP@ TOP_SRCDIR = @TOP_SRCDIR@ USE_NLS = @USE_NLS@ UTIL_LIBADD = @UTIL_LIBADD@ VERSION = @VERSION@ VORBISENC_LIBS = @VORBISENC_LIBS@ VORBISFILE_LIBS = @VORBISFILE_LIBS@ VORBIS_CFLAGS = @VORBIS_CFLAGS@ VORBIS_LIBS = @VORBIS_LIBS@ VORBIS_REQUIRED = @VORBIS_REQUIRED@ X264_CFLAGS = @X264_CFLAGS@ X264_LIBS = @X264_LIBS@ X264_REQUIRED = @X264_REQUIRED@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ XMKMF = @XMKMF@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = $(datadir)/locale localstatedir = @localstatedir@ lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ lib_LTLIBRARIES = libquicktime.la AM_CFLAGS = -DLOCALE_DIR=\"$(localedir)\" # # Library dependencies # Maybe we need zlib to read compressed quicktime headers # libquicktime_la_LIBADD = @ICONV_LIBS@ @LTLIBINTL@ libquicktime_la_LDFLAGS = -export-dynamic @HAVE_FSEEKO_FALSE@FSEEKO_SRC = lqt_fseeko.c # build only the files, which can be compiled # Different files for dynamic plugins and others @HAVE_FSEEKO_TRUE@FSEEKO_SRC = lqt_sources = lqt_codecs.c lqt_quicktime.c $(FSEEKO_SRC) # lqt_sources = codecs.c plugin.c quicktime.c libquicktime_la_SOURCES = \ audio.c \ $(lqt_sources) \ atom.c \ avi_avih.c \ avi_guid.c \ avi_hdrl.c \ avi_idx1.c \ avi_info.c \ avi_indx.c \ avi_ix.c \ avi_movi.c \ avi_odml.c \ avi_riff.c \ avi_strf.c \ avi_strh.c \ avi_strl.c \ chan.c \ charset.c \ clap.c \ cmodel_default.c \ cmodel_yuv420p.c \ cmodel_yuv422.c \ colormodels.c \ colr.c \ compression.c \ ctab.c \ ctts.c \ dinf.c \ dref.c \ edts.c \ elst.c \ enda.c \ esds.c \ fiel.c \ frma.c \ ftab.c \ ftyp.c \ gama.c \ gmhd.c \ gmhd_text.c \ gmin.c \ hdlr.c \ imgp.c \ impn.c \ iods.c \ language.c \ log.c \ matrix.c \ mdat.c \ mdhd.c \ mdia.c \ minf.c \ moov.c \ mvhd.c \ multichannel.c \ navg.c \ ndhd.c \ nloc.c \ nmhd.c \ obji.c \ pano.c \ pasp.c \ pdat.c \ pHdr.c \ qtatom.c \ qtvr.c \ smhd.c \ stbl.c \ stco.c \ stsc.c \ stsd.c \ stsdtable.c \ stss.c \ stsz.c \ stts.c \ texttrack.c \ timecode.c \ tkhd.c \ trak.c \ translation.c \ tcmi.c \ tmcd.c \ tref.c \ udta.c \ useratoms.c \ util.c \ vmhd.c \ vrsc.c \ vrnp.c \ vrni.c \ wave.c \ workarounds.c \ lqt_bufalloc.c \ lqt_codecfile.c \ lqt_color.c \ lqt_codecinfo.c \ lqt_divx.c \ lqt_qtvr.c INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libquicktime.la: $(libquicktime_la_OBJECTS) $(libquicktime_la_DEPENDENCIES) $(libquicktime_la_LINK) -rpath $(libdir) $(libquicktime_la_OBJECTS) $(libquicktime_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avi_avih.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avi_guid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avi_hdrl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avi_idx1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avi_indx.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avi_info.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avi_ix.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avi_movi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avi_odml.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avi_riff.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avi_strf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avi_strh.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avi_strl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chan.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/charset.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clap.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmodel_default.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmodel_yuv420p.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmodel_yuv422.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/colormodels.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/colr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compression.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctab.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctts.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dinf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dref.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edts.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elst.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enda.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/esds.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fiel.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/frma.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftab.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftyp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gama.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gmhd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gmhd_text.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gmin.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hdlr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imgp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/impn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iods.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/language.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqt_bufalloc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqt_codecfile.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqt_codecinfo.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqt_codecs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqt_color.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqt_divx.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqt_fseeko.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqt_qtvr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqt_quicktime.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/matrix.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mdat.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mdhd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mdia.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/minf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/moov.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multichannel.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mvhd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/navg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ndhd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nloc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nmhd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/obji.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pHdr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pano.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pasp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdat.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtatom.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtvr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/smhd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stbl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stco.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stsc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stsd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stsdtable.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stss.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stsz.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stts.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcmi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/texttrack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timecode.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tkhd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tmcd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trak.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/translation.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tref.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/udta.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/useratoms.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vmhd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vrni.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vrnp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vrsc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wave.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/workarounds.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libquicktime-1.2.4/src/navg.c0000644000175000017500000001035011511622757013015 00000000000000/******************************************************************************* navg.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" int quicktime_navg_init(quicktime_navg_t *navg) { navg->version = 1; navg->columns = 1; navg->rows = 1; navg->reserved = 0; navg->loop_frames = 1; navg->loop_dur = 75; navg->movietype = 1; navg->loop_timescale = 0; navg->fieldofview = 180; navg->startHPan = 0; navg->endHPan = 360; navg->endVPan = -90; navg->startVPan = 90; navg->initialHPan = 180; navg->initialVPan = 30; navg->reserved2 = 0; return 0; } int quicktime_navg_delete(quicktime_navg_t *navg) { return 0; } void quicktime_navg_dump(quicktime_navg_t *navg) { lqt_dump(" object parameters (navg)\n"); lqt_dump(" version %i\n", navg->version); lqt_dump(" columns %i\n", navg->columns); lqt_dump(" rows %i\n", navg->rows); lqt_dump(" loop frames %i\n", navg->loop_frames); lqt_dump(" loop frame duration %i\n", navg->loop_dur); lqt_dump(" movie type %i\n", navg->movietype); lqt_dump(" loop timescale %i\n", navg->loop_timescale); lqt_dump(" field of view %f\n", navg->fieldofview); lqt_dump(" horizontal start pan %f\n", navg->startHPan); lqt_dump(" horizontal end pan %f\n", navg->endHPan); lqt_dump(" vertical end pan %f\n", navg->endVPan); lqt_dump(" vertical start pan %f\n", navg->startVPan); lqt_dump(" initial horizontal pan %f\n", navg->initialHPan); lqt_dump(" initial vertical pan %f\n", navg->initialVPan); } int quicktime_read_navg(quicktime_t *file, quicktime_navg_t *navg, quicktime_atom_t *navg_atom) { navg->version = quicktime_read_int16(file); navg->columns = quicktime_read_int16(file); navg->rows = quicktime_read_int16(file); navg->reserved = quicktime_read_int16(file); navg->loop_frames = quicktime_read_int16(file); navg->loop_dur = quicktime_read_int16(file); navg->movietype = quicktime_read_int16(file); navg->loop_timescale = quicktime_read_int16(file); navg->fieldofview = quicktime_read_fixed32(file); navg->startHPan = quicktime_read_fixed32(file); navg->endHPan = quicktime_read_fixed32(file); navg->endVPan = quicktime_read_fixed32(file); navg->startVPan = quicktime_read_fixed32(file); navg->initialHPan = quicktime_read_fixed32(file); navg->initialVPan = quicktime_read_fixed32(file); navg->reserved2 = quicktime_read_int32(file); return 0; } void quicktime_write_navg(quicktime_t *file, quicktime_navg_t *navg) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "NAVG"); quicktime_write_int16(file, navg->version); quicktime_write_int16(file, navg->columns); quicktime_write_int16(file, navg->rows); quicktime_write_int16(file, navg->reserved); quicktime_write_int16(file, navg->loop_frames); quicktime_write_int16(file, navg->loop_dur); quicktime_write_int16(file, navg->movietype); quicktime_write_int16(file, navg->loop_timescale); quicktime_write_fixed32(file, navg->fieldofview); quicktime_write_fixed32(file, navg->startHPan); quicktime_write_fixed32(file, navg->endHPan); quicktime_write_fixed32(file, navg->endVPan); quicktime_write_fixed32(file, navg->startVPan); quicktime_write_fixed32(file, navg->initialHPan); quicktime_write_fixed32(file, navg->initialVPan); quicktime_write_fixed32(file, navg->reserved2); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/lqt_color.c0000644000175000017500000011672011670173743014072 00000000000000/******************************************************************************* lqt_color.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include "quicktime/colormodels.h" #include #include #define LOG_DOMAIN "color" typedef struct { char * name; int colormodel; } lqt_colormodel_tab; static lqt_colormodel_tab colormodel_table[] = { { "Compressed", BC_COMPRESSED }, { "16 bpp RGB 565", BC_RGB565 }, { "16 bpp BGR 565", BC_BGR565 }, { "24 bpp BGR", BC_BGR888 }, { "32 bpp BGR", BC_BGR8888 }, { "24 bpp RGB", BC_RGB888 }, { "32 bpp RGBA", BC_RGBA8888 }, { "48 bpp RGB", BC_RGB161616 }, { "64 bpp RGBA", BC_RGBA16161616 }, { "32 bpp YUVA", BC_YUVA8888 }, { "YUV 4:2:2 packed (YUY2)", BC_YUV422 }, { "YUV 4:2:0 planar", BC_YUV420P }, { "YUV 4:2:2 planar", BC_YUV422P }, { "YUV 4:4:4 planar", BC_YUV444P }, { "YUV 4:2:2 planar (16 bit)", BC_YUV422P16 }, { "YUV 4:4:4 planar (16 bit)", BC_YUV444P16 }, { "YUV 4:2:2 planar (10 bit)", BC_YUV422P10 }, { "YUV 4:2:2 planar (10 bit, jpeg)", BC_YUVJ422P10 }, { "YUV 4:2:0 planar (jpeg)", BC_YUVJ420P }, { "YUV 4:2:2 planar (jpeg)", BC_YUVJ422P }, { "YUV 4:4:4 planar (jpeg)", BC_YUVJ444P }, { "YUV 4:1:1 planar", BC_YUV411P }, { "Undefined", LQT_COLORMODEL_NONE } }; /* Some functions to find out, how cheap a colorspace conversion can be */ int lqt_colormodel_is_yuv(int colormodel) { switch(colormodel) { case BC_YUVA8888: case BC_YUV422: case BC_YUV420P: case BC_YUV422P: case BC_YUV444P: case BC_YUV422P16: case BC_YUV444P16: case BC_YUVJ420P: case BC_YUVJ422P: case BC_YUVJ444P: case BC_YUV411P: case BC_YUV422P10: case BC_YUVJ422P10: return 1; default: return 0; } } int lqt_colormodel_is_rgb(int colormodel) { switch(colormodel) { case BC_RGB565: case BC_BGR565: case BC_BGR888: case BC_BGR8888: case BC_RGB888: case BC_RGBA8888: case BC_RGB161616: case BC_RGBA16161616: return 1; default: return 0; } } int lqt_colormodel_has_alpha(int colormodel) { switch(colormodel) { case BC_RGBA8888: case BC_RGBA16161616: case BC_YUVA8888: return 1; default: return 0; } } int lqt_colormodel_is_planar(int colormodel) { switch(colormodel) { case BC_YUV420P: case BC_YUV422P: case BC_YUV444P: case BC_YUV422P16: case BC_YUV444P16: case BC_YUVJ422P: case BC_YUVJ444P: case BC_YUVJ420P: case BC_YUV411P: case BC_YUV422P10: case BC_YUVJ422P10: return 1; default: return 0; } } /* Get chroma subsampling factors */ void lqt_colormodel_get_chroma_sub(int colormodel, int * sub_h, int * sub_v) { switch(colormodel) { case BC_YUV420P: case BC_YUVJ420P: *sub_h = 2; *sub_v = 2; break; case BC_YUV422: case BC_YUV422P: case BC_YUVJ422P: case BC_YUV422P16: case BC_YUV422P10: case BC_YUVJ422P10: *sub_h = 2; *sub_v = 1; break; case BC_YUV411P: *sub_h = 4; *sub_v = 1; break; default: *sub_h = 1; *sub_v = 1; break; } } /* * Return the bits of a colormodel. This is used only internally * and returns the sum of the bits of all components. Downsampling isn't * taken into account here, YUV 420 has 24 bits. We need to test this, * because e.g. RGBA8888 -> RGBA16161616 cost extra. */ static int colormodel_get_bits(int colormodel) { switch(colormodel) { case BC_RGB565: case BC_BGR565: return 16; case BC_BGR888: case BC_BGR8888: case BC_RGB888: case BC_YUV422: case BC_YUV420P: case BC_YUV422P: case BC_YUV444P: case BC_YUVJ420P: case BC_YUVJ422P: case BC_YUVJ444P: case BC_YUV411P: return 24; case BC_RGBA8888: case BC_YUVA8888: return 32; case BC_RGB161616: case BC_YUV422P16: case BC_YUV444P16: return 48; case BC_YUV422P10: case BC_YUVJ422P10: return 30; case BC_RGBA16161616: return 64; default: lqt_log(NULL, LQT_LOG_WARNING, LOG_DOMAIN, "Unknown colormodel (%d)\n",colormodel); return 0; } } /* * Get the "Price" of a colormodel conversion */ static int get_conversion_price(int in_colormodel, int out_colormodel) { int input_is_rgb = lqt_colormodel_is_rgb(in_colormodel); int output_is_rgb = lqt_colormodel_is_rgb(out_colormodel); int input_is_yuv = lqt_colormodel_is_yuv(in_colormodel); int output_is_yuv = lqt_colormodel_is_yuv(out_colormodel); int input_has_alpha = lqt_colormodel_has_alpha(in_colormodel); int output_has_alpha = lqt_colormodel_has_alpha(out_colormodel); /* Zero conversions are for free :-) */ if(in_colormodel == out_colormodel) return 0; /* * Don't know what to do here. It can happen for very few * colormodels which aren't supported by any codecs. */ if(!input_is_rgb && !input_is_yuv) { lqt_log(NULL, LQT_LOG_WARNING, LOG_DOMAIN, "Input colorspace is neither RGB nor YUV, can't predict conversion price"); return 7; } if(!output_is_rgb && !output_is_yuv) { lqt_log(NULL, LQT_LOG_WARNING, LOG_DOMAIN, "Output colorspace is neither RGB nor YUV, can't predict conversion price"); return 7; } /* * Adding or removing the alpha channel means losing information or * adding unneccesary information -> too bad */ if(input_has_alpha != output_has_alpha) return 6; /* * YUV <-> RGB conversion costs 4-5 */ if((input_is_yuv && output_is_rgb) || (input_is_rgb && output_is_yuv)) { /* Added check to make sure that staying on the same bit depth is considered as "better" when doing a colorspace conversion. */ if(colormodel_get_bits(in_colormodel) != colormodel_get_bits(out_colormodel)) /* With bit conversion: 5 */ return 5; else /* No bit conversion is better: 4 */ return 4; } /* * Alpha blending is a bit more simple */ if((input_is_yuv && output_is_rgb) || (input_is_rgb && output_is_yuv)) return 3; /* Bit with conversion costs 2 */ if(colormodel_get_bits(in_colormodel) != colormodel_get_bits(out_colormodel)) return 2; /* Reordering of components is cheapest */ return 1; } int lqt_get_decoder_colormodel(quicktime_t * file, int track) { return file->vtracks[track].stream_cmodel; } int lqt_get_best_target_colormodel(int source, int const* target_options) { int conversion_price = 0, best_conversion_price = 10; int ret = LQT_COLORMODEL_NONE; int i; if (!target_options) { /* Undocumented behavior, but from inside libquicktime we rely on it. */ return ret; } for(i = 0; target_options[i] != LQT_COLORMODEL_NONE; ++i) { if (target_options[i] == source) return source; if(lqt_colormodel_has_conversion(source, target_options[i])) { conversion_price = get_conversion_price(source, target_options[i]); if(conversion_price < best_conversion_price) { best_conversion_price = conversion_price; ret = target_options[i]; } } } return ret; } int lqt_get_best_source_colormodel(int const* source_options, int target) { int conversion_price = 0, best_conversion_price = 10; int ret = LQT_COLORMODEL_NONE; int i; if (!source_options) { /* Undocumented behavior, but from inside libquicktime we rely on it. */ return ret; } for(i = 0; source_options[i] != LQT_COLORMODEL_NONE; ++i) { if(source_options[i] == target) return target; if(lqt_colormodel_has_conversion(source_options[i], target)) { conversion_price = get_conversion_price(source_options[i], target); if(conversion_price < best_conversion_price) { best_conversion_price = conversion_price; ret = source_options[i]; } } } return ret; } int lqt_get_best_colormodel(quicktime_t * file, int track, int * supported) { int ret; if((track >= file->total_vtracks) || (track < 0)) return LQT_COLORMODEL_NONE; if(file->wr) ret = lqt_get_best_source_colormodel(supported, file->vtracks[track].stream_cmodel); else ret = lqt_get_best_target_colormodel(file->vtracks[track].stream_cmodel, supported); if(ret == LQT_COLORMODEL_NONE) { /* Backwards compatibility. */ ret = BC_RGB888; } return ret; } static const int num_colormodels = sizeof(colormodel_table)/sizeof(colormodel_table[0])-1; const char * lqt_colormodel_to_string(int colormodel) { int i = 0; for(; i < num_colormodels; i++) if(colormodel_table[i].colormodel == colormodel) break; return colormodel_table[i].name; } int lqt_string_to_colormodel(const char * str) { int i = 0; for(; i < num_colormodels; i++) if(!strcmp(colormodel_table[i].name, str)) break; return colormodel_table[i].colormodel; } int lqt_num_colormodels() { return num_colormodels; } const char * lqt_get_colormodel_string(int index) { return colormodel_table[index].name; } int lqt_get_colormodel(int index) { return colormodel_table[index].colormodel; } static int get_bytes_per_element(int colormodel) { switch(colormodel) { case BC_RGB565: case BC_BGR565: case BC_YUV422: case BC_YUV422P16: case BC_YUV444P16: case BC_YUV422P10: case BC_YUVJ422P10: return 2; break; case BC_BGR888: case BC_RGB888: return 3; break; case BC_BGR8888: case BC_RGBA8888: case BC_YUVA8888: return 4; break; case BC_RGB161616: return 6; break; case BC_RGBA16161616: return 8; break; default: return 1; } } static int get_bytes_per_line(int colormodel, int width) { return get_bytes_per_element(colormodel) * width; } /* Allocate and free row_pointers for use with libquicktime */ uint8_t ** lqt_rows_alloc(int width, int height, int colormodel, int * rowspan, int * rowspan_uv) { int bytes_per_line = 0; int i; int y_size = 0, uv_size = 0; uint8_t ** video_buffer; int sub_h = 0, sub_v = 0; /* Allocate frame buffer */ bytes_per_line = get_bytes_per_line(colormodel, width); if(cmodel_is_planar(colormodel)) { lqt_colormodel_get_chroma_sub(colormodel, &sub_h, &sub_v); if(*rowspan <= 0) *rowspan = bytes_per_line; if(*rowspan_uv <= 0) *rowspan_uv = (*rowspan + sub_h - 1) / sub_h; y_size = *rowspan * height; uv_size = (*rowspan_uv * (height + sub_v - 1))/sub_v; video_buffer = malloc(3 * sizeof(unsigned char*)); video_buffer[0] = malloc(y_size + 2 * uv_size); video_buffer[1] = &video_buffer[0][y_size]; video_buffer[2] = &video_buffer[0][y_size+uv_size]; } else { video_buffer = malloc(height * sizeof(unsigned char*)); if(*rowspan <= 0) *rowspan = bytes_per_line; video_buffer[0] = malloc(height * bytes_per_line); for(i = 1; i < height; i++) video_buffer[i] = &video_buffer[0][i*bytes_per_line]; } return video_buffer; } void lqt_get_default_rowspan(int colormodel, int width, int * rowspan, int * rowspan_uv) { int bytes_per_line; int sub_h = 0, sub_v = 0; bytes_per_line = get_bytes_per_line(colormodel, width); lqt_colormodel_get_chroma_sub(colormodel, &sub_h, &sub_v); *rowspan = bytes_per_line; if(lqt_colormodel_is_planar(colormodel)) { *rowspan_uv = (bytes_per_line + sub_h - 1) / sub_h; } } void lqt_rows_free(uint8_t ** rows) { free(rows[0]); free(rows); } void lqt_rows_copy(uint8_t **out_rows, uint8_t **in_rows, int width, int height, int in_rowspan, int in_rowspan_uv, int out_rowspan, int out_rowspan_uv, int colormodel) { lqt_rows_copy_sub(out_rows, in_rows, width, height, in_rowspan, in_rowspan_uv, out_rowspan, out_rowspan_uv, colormodel, 0, 0, 0, 0); } void lqt_rows_clear(uint8_t **rows, int width, int height, int rowspan, int rowspan_uv, int colormodel) { int i, j, bits_per_sample, bytes_per_element, bytes_per_line; uint8_t * ptr; uint16_t * ptr_16; uint8_t * ptr_start; int sub_h, sub_v; uint16_t y_val, uv_val; bits_per_sample = colormodel_get_bits(colormodel) / (lqt_colormodel_has_alpha(colormodel) ? 4 : 3); bytes_per_element = get_bytes_per_element(colormodel); bytes_per_line = bytes_per_element * width; y_val = 1 << (bits_per_sample - 4); // This one is good for non-jpeg colormodels. uv_val = 1 << (bits_per_sample - 1); // This one is good for both jpeg and non-jpeg colormodels. switch(colormodel) { case BC_RGB565: case BC_BGR565: case BC_BGR888: case BC_BGR8888: case BC_RGB888: case BC_RGB161616: case BC_RGBA8888: case BC_RGBA16161616: if(rows[1]) { for(i = 0; i < height; i++) memset(rows[i], 0, bytes_per_line); } else { ptr = rows[0]; for(i = 0; i < height; i++) { memset(ptr, 0, bytes_per_line); ptr += rowspan; } } break; case BC_YUVA8888: if(rows[1]) { for(i = 0; i < height; i++) { ptr = rows[i]; for(j = 0; j < width; j++) { ptr[0] = 0x10; ptr[1] = 0x80; ptr[2] = 0x80; ptr[3] = 0x00; ptr += 4; } } } else { ptr_start = rows[0]; for(i = 0; i < height; i++) { ptr = ptr_start; for(j = 0; j < width; j++) { ptr[0] = 0x10; ptr[1] = 0x80; ptr[2] = 0x80; ptr[3] = 0x00; ptr += 4; } ptr_start += rowspan; } } break; case BC_YUV422: if(rows[1]) { for(i = 0; i < height; i++) { ptr = rows[i]; for(j = 0; j < width; j++) { ptr[0] = 0x10; ptr[1] = 0x80; ptr += 2; } } } else { ptr_start = rows[0]; for(i = 0; i < height; i++) { ptr = ptr_start; for(j = 0; j < width; j++) { ptr[0] = 0x10; ptr[1] = 0x80; ptr += 2; } ptr_start += rowspan; } } break; case BC_YUV420P: case BC_YUV422P: case BC_YUV444P: case BC_YUV411P: lqt_colormodel_get_chroma_sub(colormodel, &sub_h, &sub_v); /* Y */ ptr = rows[0]; for(i = 0; i < height; i++) { memset(ptr, 0x10, width); ptr += rowspan; } width /= sub_h; height /= sub_v; /* U */ ptr = rows[1]; for(i = 0; i < height; i++) { memset(ptr, 0x80, width); ptr += rowspan_uv; } /* V */ ptr = rows[2]; for(i = 0; i < height; i++) { memset(ptr, 0x80, width); ptr += rowspan_uv; } break; case BC_YUVJ420P: case BC_YUVJ422P: case BC_YUVJ444P: lqt_colormodel_get_chroma_sub(colormodel, &sub_h, &sub_v); /* Y */ ptr = rows[0]; for(i = 0; i < height; i++) { memset(ptr, 0x00, width); ptr += rowspan; } width /= sub_h; height /= sub_v; /* U */ ptr = rows[1]; for(i = 0; i < height; i++) { memset(ptr, 0x80, width); ptr += rowspan_uv; } /* V */ ptr = rows[2]; for(i = 0; i < height; i++) { memset(ptr, 0x80, width); ptr += rowspan_uv; } break; case BC_YUVJ422P10: y_val = 0; // For jpeg colormodels. case BC_YUV422P16: case BC_YUV444P16: case BC_YUV422P10: lqt_colormodel_get_chroma_sub(colormodel, &sub_h, &sub_v); /* Y */ ptr_start = rows[0]; for(i = 0; i < height; i++) { ptr_16 = (uint16_t*)ptr_start; for(j = 0; j < width; j++) { *ptr_16 = y_val; ptr_16++; } ptr_start += rowspan; } width /= sub_h; height /= sub_v; // Unneccesary actually /* U */ ptr_start = rows[1]; for(i = 0; i < height; i++) { ptr_16 = (uint16_t*)ptr_start; for(j = 0; j < width; j++) { *ptr_16 = uv_val; ptr_16++; } ptr_start += rowspan; } /* V */ ptr_start = rows[2]; for(i = 0; i < height; i++) { ptr_16 = (uint16_t*)ptr_start; for(j = 0; j < width; j++) { *ptr_16 = uv_val; ptr_16++; } ptr_start += rowspan; } break; } } void lqt_rows_copy_sub(uint8_t **out_rows, uint8_t **in_rows, int width, int height, int in_rowspan, int in_rowspan_uv, int out_rowspan, int out_rowspan_uv, int colormodel, int src_x, int src_y, int dst_x, int dst_y) { uint8_t * src_ptr, *dst_ptr; int i; int sub_h = 0, sub_v = 0; int bytes_per_line, bytes_per_element; bytes_per_line = get_bytes_per_line(colormodel, width); bytes_per_element = get_bytes_per_element(colormodel); if(lqt_colormodel_is_planar(colormodel)) { lqt_colormodel_get_chroma_sub(colormodel, &sub_h, &sub_v); /* Align */ src_x /= sub_h; src_x *= sub_h; src_y /= sub_v; src_y *= sub_v; /* Luma plane */ src_ptr = in_rows[0] + src_x * bytes_per_element + src_y * in_rowspan; dst_ptr = out_rows[0] + src_x * bytes_per_element + dst_y * out_rowspan; for(i = 0; i < height; i++) { memcpy(dst_ptr, src_ptr, bytes_per_line); src_ptr += in_rowspan; dst_ptr += out_rowspan; } /* Chroma planes */ src_ptr = in_rows[1] + src_x/sub_h * bytes_per_element + src_y * in_rowspan_uv; dst_ptr = out_rows[1] + dst_x/sub_h * bytes_per_element + dst_y * out_rowspan_uv; for(i = 0; i < (height + sub_v - 1)/sub_v; i++) { memcpy(dst_ptr, src_ptr, (bytes_per_line + sub_h - 1)/sub_h); src_ptr += in_rowspan_uv; dst_ptr += out_rowspan_uv; } src_ptr = in_rows[2] + src_x/sub_h * bytes_per_element + src_y * in_rowspan_uv; dst_ptr = out_rows[2] + dst_x/sub_h * bytes_per_element + dst_y * out_rowspan_uv; for(i = 0; i < (height + sub_v - 1)/sub_v; i++) { memcpy(dst_ptr, src_ptr, (bytes_per_line + sub_h - 1)/sub_h); src_ptr += in_rowspan_uv; dst_ptr += out_rowspan_uv; } } else /* Packed */ { /* This is nasty: We don't know, how the frames are allocated. We test rows[1] to check this and handle all 4 combinations separately */ if(in_rows[1] && out_rows[1]) { for(i = 0; i < height; i++) memcpy(out_rows[i + dst_y] + dst_x * bytes_per_element, in_rows[i + src_y] + src_x * bytes_per_element, bytes_per_line); } else if(in_rows[1]) { dst_ptr = out_rows[0] + dst_y * bytes_per_line + dst_x * bytes_per_element; for(i = 0; i < height; i++) { memcpy(dst_ptr, in_rows[i + src_y] + src_x * bytes_per_element, bytes_per_line); dst_ptr += out_rowspan; } } else if(out_rows[1]) { src_ptr = in_rows[0] + src_y * bytes_per_line + src_x * bytes_per_element; for(i = 0; i < height; i++) { memcpy(out_rows[i + dst_y] + dst_x * bytes_per_element, src_ptr, bytes_per_line); src_ptr += in_rowspan; } } else { src_ptr = in_rows[0] + src_y * bytes_per_line + src_x * bytes_per_element; dst_ptr = out_rows[0] + dst_y * bytes_per_line + dst_x * bytes_per_element; for(i = 0; i < height; i++) { memcpy(dst_ptr, src_ptr, bytes_per_line); src_ptr += in_rowspan; dst_ptr += out_rowspan; } } } } // for i in BC_RGB565 BC_BGR565 BC_BGR888 BC_BGR8888 BC_RGB888 BC_RGBA8888 BC_RGB161616 BC_RGBA16161616 BC_YUVA8888 BC_YUV422 BC_YUV420P BC_YUV422P BC_YUV444P BC_YUV411P BC_YUVJ420P BC_YUVJ422P BC_YUVJ444P BC_YUV422P16 BC_YUV444P16; do for j in BC_RGB565 BC_BGR565 BC_BGR888 BC_BGR8888 BC_RGB888 BC_RGBA8888 BC_RGB161616 BC_RGBA16161616 BC_YUVA8888 BC_YUV422 BC_YUV420P BC_YUV422P BC_YUV444P BC_YUV411P BC_YUVJ420P BC_YUVJ422P BC_YUVJ444P BC_YUV422P16 BC_YUV444P16; do echo $i"_to_"$j.png; gthumb $i"_to_"$j.png; done; done int lqt_colormodel_has_conversion(int in_cmodel, int out_cmodel) { if(in_cmodel == out_cmodel) return 1; switch(in_cmodel) { case BC_RGB565: switch(out_cmodel) { case BC_BGR565: return 0; break; case BC_BGR888: return 0; break; case BC_BGR8888: return 0; break; case BC_RGB888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGB161616: return 0; break; case BC_RGBA16161616: return 0; break; case BC_YUVA8888: return 0; break; case BC_YUV422: return 0; break; case BC_YUV420P: return 0; break; case BC_YUV422P: return 0; break; case BC_YUV444P: return 0; break; case BC_YUV411P: return 0; break; case BC_YUVJ420P: return 0; break; case BC_YUVJ422P: return 0; break; case BC_YUVJ444P: return 0; break; case BC_YUV422P16: return 0; break; case BC_YUV444P16: return 0; break; } break; case BC_BGR565: switch(out_cmodel) { case BC_RGB565: return 0; break; case BC_BGR888: return 0; break; case BC_BGR8888: return 0; break; case BC_RGB888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGB161616: return 0; break; case BC_RGBA16161616: return 0; break; case BC_YUVA8888: return 0; break; case BC_YUV422: return 0; break; case BC_YUV420P: return 0; break; case BC_YUV422P: return 0; break; case BC_YUV444P: return 0; break; case BC_YUV411P: return 0; break; case BC_YUVJ420P: return 0; break; case BC_YUVJ422P: return 0; break; case BC_YUVJ444P: return 0; break; case BC_YUV422P16: return 0; break; case BC_YUV444P16: return 0; break; } break; case BC_BGR888: switch(out_cmodel) { case BC_RGB565: return 1; break; case BC_BGR565: return 1; break; case BC_BGR8888: return 1; break; case BC_RGB888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGB161616: return 1; break; case BC_RGBA16161616: return 1; break; case BC_YUVA8888: return 1; break; case BC_YUV422: return 1; break; case BC_YUV420P: return 1; break; case BC_YUV422P: return 1; break; case BC_YUV444P: return 1; break; case BC_YUV411P: return 0; break; case BC_YUVJ420P: return 0; break; case BC_YUVJ422P: return 0; break; case BC_YUVJ444P: return 0; break; case BC_YUV422P16: return 0; break; case BC_YUV444P16: return 0; break; } break; case BC_BGR8888: switch(out_cmodel) { case BC_RGB565: return 0; break; case BC_BGR565: return 0; break; case BC_BGR888: return 0; break; case BC_RGB888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGB161616: return 0; break; case BC_RGBA16161616: return 0; break; case BC_YUVA8888: return 0; break; case BC_YUV422: return 0; break; case BC_YUV420P: return 1; break; case BC_YUV422P: return 0; break; case BC_YUV444P: return 0; break; case BC_YUV411P: return 0; break; case BC_YUVJ420P: return 0; break; case BC_YUVJ422P: return 0; break; case BC_YUVJ444P: return 0; break; case BC_YUV422P16: return 0; break; case BC_YUV444P16: return 0; break; } break; case BC_RGB888: switch(out_cmodel) { case BC_RGB565: return 1; break; case BC_BGR565: return 1; break; case BC_BGR888: return 1; break; case BC_BGR8888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGB161616: return 1; break; case BC_RGBA16161616: return 1; break; case BC_YUVA8888: return 1; break; case BC_YUV422: return 1; break; case BC_YUV420P: return 1; break; case BC_YUV422P: return 1; break; case BC_YUV444P: return 1; break; case BC_YUV411P: return 1; break; case BC_YUVJ420P: return 1; break; case BC_YUVJ422P: return 1; break; case BC_YUVJ444P: return 1; break; case BC_YUV422P16: return 1; break; case BC_YUV444P16: return 1; break; case BC_YUV422P10: return 1; break; case BC_YUVJ422P10: return 1; break; } break; case BC_RGBA8888: switch(out_cmodel) { case BC_RGB565: return 1; break; case BC_BGR565: return 1; break; case BC_BGR888: return 1; break; case BC_BGR8888: return 1; break; case BC_RGB888: return 1; break; case BC_RGB161616: return 1; break; case BC_RGBA16161616: return 1; break; case BC_YUVA8888: return 1; break; case BC_YUV422: return 1; break; case BC_YUV420P: return 1; break; case BC_YUV422P: return 1; break; case BC_YUV444P: return 1; break; case BC_YUV411P: return 1; break; case BC_YUVJ420P: return 1; break; case BC_YUVJ422P: return 1; break; case BC_YUVJ444P: return 1; break; case BC_YUV422P16: return 1; break; case BC_YUV444P16: return 1; break; } break; case BC_RGB161616: switch(out_cmodel) { case BC_RGB565: return 1; break; case BC_BGR565: return 1; break; case BC_BGR888: return 1; break; case BC_BGR8888: return 1; break; case BC_RGB888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGBA16161616: return 0; break; case BC_YUVA8888: return 1; break; case BC_YUV422: return 1; break; case BC_YUV420P: return 1; break; case BC_YUV422P: return 1; break; case BC_YUV444P: return 1; break; case BC_YUV411P: return 0; break; case BC_YUVJ420P: return 0; break; case BC_YUVJ422P: return 0; break; case BC_YUVJ444P: return 0; break; case BC_YUV422P16: return 1; break; case BC_YUV444P16: return 1; break; case BC_YUV422P10: return 1; break; case BC_YUVJ422P10: return 1; break; } break; case BC_RGBA16161616: switch(out_cmodel) { case BC_RGB565: return 1; break; case BC_BGR565: return 1; break; case BC_BGR888: return 1; break; case BC_BGR8888: return 1; break; case BC_RGB888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGB161616: return 0; break; case BC_YUVA8888: return 0; break; case BC_YUV422: return 0; break; case BC_YUV420P: return 1; break; case BC_YUV422P: return 1; break; case BC_YUV444P: return 1; break; case BC_YUV411P: return 0; break; case BC_YUVJ420P: return 0; break; case BC_YUVJ422P: return 0; break; case BC_YUVJ444P: return 0; break; case BC_YUV422P16: return 0; break; case BC_YUV444P16: return 0; break; } break; case BC_YUVA8888: switch(out_cmodel) { case BC_RGB565: return 1; break; case BC_BGR565: return 1; break; case BC_BGR888: return 1; break; case BC_BGR8888: return 1; break; case BC_RGB888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGB161616: return 0; break; case BC_RGBA16161616: return 0; break; case BC_YUV422: return 1; break; case BC_YUV420P: return 1; break; case BC_YUV422P: return 1; break; case BC_YUV444P: return 1; break; case BC_YUV411P: return 0; break; case BC_YUVJ420P: return 0; break; case BC_YUVJ422P: return 0; break; case BC_YUVJ444P: return 0; break; case BC_YUV422P16: return 0; break; case BC_YUV444P16: return 0; break; } break; case BC_YUV422: switch(out_cmodel) { case BC_RGB565: return 1; break; case BC_BGR565: return 1; break; case BC_BGR888: return 1; break; case BC_BGR8888: return 1; break; case BC_RGB888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGB161616: return 1; break; case BC_RGBA16161616: return 0; break; case BC_YUVA8888: return 1; break; case BC_YUV420P: return 1; break; case BC_YUV422P: return 1; break; case BC_YUV444P: return 0; break; case BC_YUV411P: return 0; break; case BC_YUVJ420P: return 0; break; case BC_YUVJ422P: return 1; break; case BC_YUVJ444P: return 0; break; case BC_YUV422P16: return 0; break; case BC_YUV444P16: return 0; break; } break; case BC_YUV420P: switch(out_cmodel) { case BC_RGB565: return 1; break; case BC_BGR565: return 1; break; case BC_BGR888: return 1; break; case BC_BGR8888: return 1; break; case BC_RGB888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGB161616: return 1; break; case BC_RGBA16161616: return 1; break; case BC_YUVA8888: return 1; break; case BC_YUV422: return 1; break; case BC_YUV422P: return 1; break; case BC_YUV444P: return 1; break; case BC_YUV411P: return 0; break; case BC_YUVJ420P: return 0; break; case BC_YUVJ422P: return 0; break; case BC_YUVJ444P: return 0; break; case BC_YUV422P16: return 0; break; case BC_YUV444P16: return 0; break; } break; case BC_YUV422P: switch(out_cmodel) { case BC_RGB565: return 1; break; case BC_BGR565: return 1; break; case BC_BGR888: return 1; break; case BC_BGR8888: return 1; break; case BC_RGB888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGB161616: return 1; break; case BC_RGBA16161616: return 1; break; case BC_YUVA8888: return 1; break; case BC_YUV422: return 1; break; case BC_YUV420P: return 1; break; case BC_YUV444P: return 1; break; case BC_YUV411P: return 0; break; case BC_YUVJ420P: return 0; break; case BC_YUVJ422P: return 1; break; case BC_YUVJ444P: return 0; break; case BC_YUV422P16: return 0; break; case BC_YUV444P16: return 0; break; } break; case BC_YUV444P: switch(out_cmodel) { case BC_RGB565: return 1; break; case BC_BGR565: return 1; break; case BC_BGR888: return 1; break; case BC_BGR8888: return 1; break; case BC_RGB888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGB161616: return 1; break; case BC_RGBA16161616: return 1; break; case BC_YUVA8888: return 1; break; case BC_YUV422: return 1; break; case BC_YUV420P: return 1; break; case BC_YUV422P: return 1; break; case BC_YUV411P: return 0; break; case BC_YUVJ420P: return 0; break; case BC_YUVJ422P: return 0; break; case BC_YUVJ444P: return 0; break; case BC_YUV422P16: return 0; break; case BC_YUV444P16: return 0; break; } break; case BC_YUV411P: switch(out_cmodel) { case BC_RGB565: return 0; break; case BC_BGR565: return 0; break; case BC_BGR888: return 0; break; case BC_BGR8888: return 0; break; case BC_RGB888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGB161616: return 0; break; case BC_RGBA16161616: return 0; break; case BC_YUVA8888: return 0; break; case BC_YUV422: return 0; break; case BC_YUV420P: return 0; break; case BC_YUV422P: return 0; break; case BC_YUV444P: return 0; break; case BC_YUVJ420P: return 0; break; case BC_YUVJ422P: return 0; break; case BC_YUVJ444P: return 0; break; case BC_YUV422P16: return 0; break; case BC_YUV444P16: return 0; break; } break; case BC_YUVJ420P: switch(out_cmodel) { case BC_RGB565: return 0; break; case BC_BGR565: return 0; break; case BC_BGR888: return 0; break; case BC_BGR8888: return 0; break; case BC_RGB888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGB161616: return 0; break; case BC_RGBA16161616: return 0; break; case BC_YUVA8888: return 0; break; case BC_YUV422: return 0; break; case BC_YUV420P: return 0; break; case BC_YUV422P: return 0; break; case BC_YUV444P: return 0; break; case BC_YUV411P: return 0; break; case BC_YUVJ422P: return 0; break; case BC_YUVJ444P: return 0; break; case BC_YUV422P16: return 0; break; case BC_YUV444P16: return 0; break; } break; case BC_YUVJ422P: switch(out_cmodel) { case BC_RGB565: return 0; break; case BC_BGR565: return 0; break; case BC_BGR888: return 0; break; case BC_BGR8888: return 0; break; case BC_RGB888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGB161616: return 0; break; case BC_RGBA16161616: return 0; break; case BC_YUVA8888: return 0; break; case BC_YUV422: return 1; break; case BC_YUV420P: return 1; break; case BC_YUV422P: return 1; break; case BC_YUV444P: return 0; break; case BC_YUV411P: return 0; break; case BC_YUVJ420P: return 0; break; case BC_YUVJ444P: return 0; break; case BC_YUV422P16: return 0; break; case BC_YUV444P16: return 0; break; } break; case BC_YUVJ444P: switch(out_cmodel) { case BC_RGB565: return 0; break; case BC_BGR565: return 0; break; case BC_BGR888: return 0; break; case BC_BGR8888: return 0; break; case BC_RGB888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGB161616: return 0; break; case BC_RGBA16161616: return 0; break; case BC_YUVA8888: return 0; break; case BC_YUV422: return 0; break; case BC_YUV420P: return 0; break; case BC_YUV422P: return 0; break; case BC_YUV444P: return 0; break; case BC_YUV411P: return 0; break; case BC_YUVJ420P: return 0; break; case BC_YUVJ422P: return 0; break; case BC_YUV422P16: return 0; break; case BC_YUV444P16: return 0; break; } break; case BC_YUV422P16: switch(out_cmodel) { case BC_RGB565: return 0; break; case BC_BGR565: return 0; break; case BC_BGR888: return 0; break; case BC_BGR8888: return 0; break; case BC_RGB888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGB161616: return 1; break; case BC_RGBA16161616: return 0; break; case BC_YUVA8888: return 0; break; case BC_YUV422: return 0; break; case BC_YUV420P: return 0; break; case BC_YUV422P: return 1; break; case BC_YUV444P: return 0; break; case BC_YUV411P: return 0; break; case BC_YUVJ420P: return 0; break; case BC_YUVJ422P: return 0; break; case BC_YUVJ444P: return 0; break; case BC_YUV444P16: return 0; break; } break; case BC_YUV444P16: switch(out_cmodel) { case BC_RGB565: return 0; break; case BC_BGR565: return 0; break; case BC_BGR888: return 0; break; case BC_BGR8888: return 0; break; case BC_RGB888: return 1; break; case BC_RGBA8888: return 1; break; case BC_RGB161616: return 1; break; case BC_RGBA16161616: return 0; break; case BC_YUVA8888: return 0; break; case BC_YUV422: return 0; break; case BC_YUV420P: return 0; break; case BC_YUV422P: return 0; break; case BC_YUV444P: return 1; break; case BC_YUV411P: return 0; break; case BC_YUVJ420P: return 0; break; case BC_YUVJ422P: return 0; break; case BC_YUVJ444P: return 0; break; case BC_YUV422P16: return 0; break; } break; case BC_YUV422P10: case BC_YUVJ422P10: switch(out_cmodel) { case BC_RGB888: return 1; break; case BC_RGB161616: return 1; break; } break; } return 0; } libquicktime-1.2.4/src/trak.c0000644000175000017500000004750211722235260013025 00000000000000/******************************************************************************* trak.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include int quicktime_trak_init(quicktime_trak_t *trak, lqt_file_type_t type) { quicktime_tkhd_init(&trak->tkhd, type); quicktime_edts_init(&trak->edts); quicktime_mdia_init(&trak->mdia); quicktime_tref_init(&trak->tref); trak->has_tref = 0; return 0; } int quicktime_trak_init_video(quicktime_t *file, quicktime_trak_t *trak, int frame_w, int frame_h, int frame_duration, int timescale, char *compressor) { quicktime_tkhd_init_video(file, &trak->tkhd, frame_w, frame_h); quicktime_mdia_init_video(file, &trak->mdia, frame_w, frame_h, frame_duration, timescale, compressor); if(!IS_MP4(file->file_type)) { quicktime_edts_init_table(&trak->edts); trak->has_edts = 1; } return 0; } int quicktime_trak_init_timecode(quicktime_t *file, quicktime_trak_t *trak, int time_scale, int frame_duration, int num_frames, int frame_w, int frame_h, uint32_t flags) { quicktime_tkhd_init_timecode(file, &trak->tkhd, frame_w, frame_h); quicktime_mdia_init_timecode(file, &trak->mdia, time_scale, frame_duration, num_frames, flags); quicktime_edts_init_table(&trak->edts); return 0; } int quicktime_trak_init_qtvr(quicktime_t *file, quicktime_trak_t *trak, int track_type, int width, int height, int frame_duration, int timescale) { quicktime_tkhd_init_video(file, &trak->tkhd, height, width); quicktime_mdia_init_qtvr(file, &trak->mdia, track_type, timescale, frame_duration); quicktime_edts_init_table(&trak->edts); trak->has_edts = 1; quicktime_tref_init_qtvr(&trak->tref, track_type); trak->has_tref = 1; return 0; } int quicktime_trak_init_panorama(quicktime_t *file, quicktime_trak_t *trak, int width, int height, int frame_duration, int timescale) { quicktime_tkhd_init_video(file, &trak->tkhd, height, height/2); quicktime_mdia_init_panorama(file, &trak->mdia, width, height, timescale, frame_duration); quicktime_edts_init_table(&trak->edts); trak->has_edts = 1; return 0; } int quicktime_trak_init_audio(quicktime_t *file, quicktime_trak_t *trak, int channels, int sample_rate, int bits, char *compressor) { quicktime_mdia_init_audio(file, &trak->mdia, channels, sample_rate, bits, compressor); if(!IS_MP4(file->file_type)) { quicktime_edts_init_table(&trak->edts); trak->has_edts = 1; } return 0; } int quicktime_trak_init_text(quicktime_t * file, quicktime_trak_t * trak, int timescale) { trak->tkhd.volume = 0; trak->tkhd.flags = 3; quicktime_mdia_init_text(file, &trak->mdia, timescale); if(!IS_MP4(file->file_type)) { quicktime_edts_init_table(&trak->edts); trak->has_edts = 1; } return 0; } int quicktime_trak_init_tx3g(quicktime_t * file, quicktime_trak_t * trak, int timescale) { trak->tkhd.volume = 0; trak->tkhd.flags = 1; quicktime_mdia_init_tx3g(file, &trak->mdia, timescale); return 0; } int quicktime_trak_delete(quicktime_trak_t *trak) { quicktime_mdia_delete(&trak->mdia); quicktime_edts_delete(&trak->edts); quicktime_tkhd_delete(&trak->tkhd); quicktime_tref_delete(&trak->tref); if(trak->chunk_sizes) free(trak->chunk_sizes); return 0; } int quicktime_trak_dump(quicktime_trak_t *trak) { lqt_dump(" track (trak)\n"); quicktime_tkhd_dump(&trak->tkhd); if(trak->has_edts) quicktime_edts_dump(&trak->edts); if(trak->has_tref) quicktime_tref_dump(&trak->tref); quicktime_mdia_dump(&trak->mdia); return 0; } // Used when reading a file quicktime_trak_t* quicktime_add_trak(quicktime_t *file) { quicktime_moov_t *moov = &file->moov; if(moov->total_tracks < MAXTRACKS) { moov->trak[moov->total_tracks] = calloc(1, sizeof(quicktime_trak_t)); quicktime_trak_init(moov->trak[moov->total_tracks], file->file_type); moov->total_tracks++; } return moov->trak[moov->total_tracks - 1]; } int quicktime_delete_trak(quicktime_moov_t *moov) { if(moov->total_tracks) { moov->total_tracks--; quicktime_trak_delete(moov->trak[moov->total_tracks]); free(moov->trak[moov->total_tracks]); } return 0; } static void fix_dirac_track(quicktime_trak_t *trak) { quicktime_stsz_t * stsz; quicktime_stts_t * stts; /* If the last sample is only the sequence end code, we must hide it (the codec will regenerate it) */ stsz = &trak->mdia.minf.stbl.stsz; stts = &trak->mdia.minf.stbl.stts; if(stsz->table[stsz->total_entries-1].size == 13) { if(stts->table[stts->total_entries-1].sample_count > 1) stts->table[stts->total_entries-1].sample_count--; else stts->total_entries--; } } int quicktime_read_trak(quicktime_t *file, quicktime_trak_t *trak, quicktime_atom_t *trak_atom) { quicktime_atom_t leaf_atom; do { quicktime_atom_read_header(file, &leaf_atom); /* mandatory */ if(quicktime_atom_is(&leaf_atom, "tkhd")) quicktime_read_tkhd(file, &trak->tkhd); else if(quicktime_atom_is(&leaf_atom, "mdia")) quicktime_read_mdia(file, trak, &trak->mdia, &leaf_atom); /* optional */ else if(quicktime_atom_is(&leaf_atom, "clip")) quicktime_atom_skip(file, &leaf_atom); else if(quicktime_atom_is(&leaf_atom, "matt")) quicktime_atom_skip(file, &leaf_atom); else if(quicktime_atom_is(&leaf_atom, "edts")) { quicktime_read_edts(file, &trak->edts, &leaf_atom); trak->has_edts = 1; } else if(quicktime_atom_is(&leaf_atom, "load")) quicktime_atom_skip(file, &leaf_atom); else if(quicktime_atom_is(&leaf_atom, "imap")) quicktime_atom_skip(file, &leaf_atom); else if(quicktime_atom_is(&leaf_atom, "udta")) quicktime_atom_skip(file, &leaf_atom); else if(quicktime_atom_is(&leaf_atom, "tref")) { trak->has_tref = 1; quicktime_read_tref(file, &trak->tref, &leaf_atom); } else quicktime_atom_skip(file, &leaf_atom); } while(quicktime_position(file) < trak_atom->end); #if 1 if(trak->mdia.minf.is_video && quicktime_match_32(trak->mdia.minf.stbl.stsd.table[0].format, "drac")) fix_dirac_track(trak); #endif return 0; } int quicktime_write_trak(quicktime_t *file, quicktime_trak_t *trak) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "trak"); quicktime_write_tkhd(file, &trak->tkhd); if(trak->has_edts) quicktime_write_edts(file, &trak->edts); quicktime_write_mdia(file, &trak->mdia); if (trak->has_tref) quicktime_write_tref(file, &trak->tref); quicktime_atom_write_footer(file, &atom); return 0; } int64_t quicktime_track_samples(quicktime_t *file, quicktime_trak_t *trak) { quicktime_stts_t *stts = &trak->mdia.minf.stbl.stts; int i; int64_t total = 0; if(trak->mdia.minf.is_audio) { for(i = 0; i < stts->total_entries; i++) { total += stts->table[i].sample_count * stts->table[i].sample_duration; } } else { for(i = 0; i < stts->total_entries; i++) { total += stts->table[i].sample_count; } } return total; } long quicktime_sample_of_chunk(quicktime_trak_t *trak, long chunk) { quicktime_stsc_table_t *table = trak->mdia.minf.stbl.stsc.table; long total_entries = trak->mdia.minf.stbl.stsc.total_entries; long chunk1entry, chunk2entry; long chunk1, chunk2, chunks, total = 0; for(chunk1entry = total_entries - 1, chunk2entry = total_entries; chunk1entry >= 0; chunk1entry--, chunk2entry--) { chunk1 = table[chunk1entry].chunk; if(chunk > chunk1) { if(chunk2entry < total_entries) { chunk2 = table[chunk2entry].chunk; if(chunk < chunk2) chunk2 = chunk; } else chunk2 = chunk; chunks = chunk2 - chunk1; total += chunks * table[chunk1entry].samples; } } return total; } // For AVI int quicktime_avg_chunk_samples(quicktime_t *file, quicktime_trak_t *trak) { int chunk = trak->mdia.minf.stbl.stco.total_entries - 1; long total_samples; if(chunk >= 0) { total_samples = quicktime_sample_of_chunk(trak, chunk); return total_samples / (chunk + 1); } else { total_samples = quicktime_track_samples(file, trak); return total_samples; } } int quicktime_chunk_of_sample(int64_t *chunk_sample, int64_t *chunk, quicktime_trak_t *trak, int64_t sample) { quicktime_stsc_table_t *table = trak->mdia.minf.stbl.stsc.table; long total_entries = trak->mdia.minf.stbl.stsc.total_entries; long chunk2entry; long chunk1, chunk2, chunk1samples, range_samples, total = 0; chunk1 = 0; chunk1samples = 0; chunk2entry = 0; if(!total_entries) { *chunk_sample = 0; *chunk = 0; return 0; } do { chunk2 = table[chunk2entry].chunk-1; *chunk = chunk2 - chunk1; range_samples = *chunk * chunk1samples; if(sample < total + range_samples) break; chunk1samples = table[chunk2entry].samples; chunk1 = chunk2; if(chunk2entry < total_entries) { chunk2entry++; total += range_samples; } }while(chunk2entry < total_entries); if(chunk1samples) *chunk = (sample - total) / chunk1samples + chunk1; else *chunk = 0; *chunk_sample = total + (*chunk - chunk1) * chunk1samples; return 0; } int64_t quicktime_chunk_to_offset(quicktime_t *file, quicktime_trak_t *trak, long chunk) { quicktime_stco_table_t *table = trak->mdia.minf.stbl.stco.table; int64_t result = 0; if(trak->mdia.minf.stbl.stco.total_entries && chunk > trak->mdia.minf.stbl.stco.total_entries) result = table[trak->mdia.minf.stbl.stco.total_entries - 1].offset; else if(trak->mdia.minf.stbl.stco.total_entries) result = table[chunk].offset; else result = HEADER_LENGTH * 2; return result; } int64_t quicktime_sample_range_size(quicktime_trak_t *trak, long chunk_sample, long sample) { int64_t i, total; /* LQT: For audio, quicktime_sample_rage_size makes no sense */ if(trak->mdia.minf.is_audio) return 0; else { /* All frames have the same size */ if(trak->mdia.minf.stbl.stsz.sample_size) { total = (sample - chunk_sample) * trak->mdia.minf.stbl.stsz.sample_size; } /* probably video */ else { for(i = chunk_sample, total = 0; i < sample; i++) { total += trak->mdia.minf.stbl.stsz.table[i].size; } } } return total; } int64_t quicktime_sample_to_offset(quicktime_t *file, quicktime_trak_t *trak, long sample) { int64_t chunk, chunk_sample, chunk_offset1, chunk_offset2; quicktime_chunk_of_sample(&chunk_sample, &chunk, trak, sample); chunk_offset1 = quicktime_chunk_to_offset(file, trak, chunk); chunk_offset2 = chunk_offset1 + quicktime_sample_range_size(trak, chunk_sample, sample); return chunk_offset2; } void quicktime_write_chunk_header(quicktime_t *file, quicktime_trak_t *trak) { if(file->write_trak) quicktime_write_chunk_footer(file, file->write_trak); if(file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML)) { /* Get tag from first riff strl */ quicktime_strl_t *strl = trak->strl; char *tag = strl->tag; /* Create new RIFF object at 1 Gig mark */ if(file->file_type == LQT_FILE_AVI_ODML) { quicktime_riff_t *riff = file->riff[file->total_riffs - 1]; if(quicktime_position(file) - riff->atom.start > file->max_riff_size) { quicktime_finalize_riff(file, riff); quicktime_init_riff(file); } } /* Write AVI header */ quicktime_atom_write_header(file, &trak->chunk_atom, tag); } else trak->chunk_atom.start = quicktime_position(file); file->write_trak = trak; } void quicktime_write_chunk_footer(quicktime_t *file, quicktime_trak_t *trak) { int64_t offset = trak->chunk_atom.start; int sample_size = quicktime_position(file) - offset; // Write AVI footer if(file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML)) { quicktime_atom_write_footer(file, &trak->chunk_atom); // Save original index entry for first RIFF only if(file->total_riffs < 2) { quicktime_update_idx1table(file, trak, offset, sample_size); } // Save partial index entry if(file->file_type == LQT_FILE_AVI_ODML) quicktime_update_ixtable(file, trak, offset, sample_size); if(sample_size > trak->strl->strh.dwSuggestedBufferSize) trak->strl->strh.dwSuggestedBufferSize = ((sample_size+15)/16)*16; } if(offset + sample_size > file->mdat.atom.size) file->mdat.atom.size = offset + sample_size; quicktime_update_stco(&trak->mdia.minf.stbl.stco, trak->chunk_num, offset); if(trak->mdia.minf.is_video || trak->mdia.minf.is_text) quicktime_update_stsz(&trak->mdia.minf.stbl.stsz, trak->chunk_num, sample_size); /* Need to increase sample count for CBR (the VBR routines to it themselves) */ if(trak->mdia.minf.is_audio && !trak->mdia.minf.is_audio_vbr) trak->mdia.minf.stbl.stts.table->sample_count += trak->chunk_samples; if(trak->mdia.minf.is_panorama) { quicktime_update_stsz(&trak->mdia.minf.stbl.stsz, trak->chunk_num, sample_size); } if(trak->mdia.minf.is_qtvr) { quicktime_update_stsz(&trak->mdia.minf.stbl.stsz, trak->chunk_num, sample_size); } quicktime_update_stsc(&trak->mdia.minf.stbl.stsc, trak->chunk_num, trak->chunk_samples); trak->chunk_num++; trak->chunk_samples = 0; file->write_trak = NULL; } int quicktime_trak_duration(quicktime_trak_t *trak, int64_t *duration, int *timescale) { quicktime_stts_t *stts = &trak->mdia.minf.stbl.stts; int i; *duration = 0; for(i = 0; i < stts->total_entries; i++) { *duration += stts->table[i].sample_duration * stts->table[i].sample_count; } if(timescale) *timescale = trak->mdia.mdhd.time_scale; return 0; } static int fix_counts_read(quicktime_trak_t *trak, int timescale, int moov_time_scale) { if(trak->has_edts) { trak->pts_offset = quicktime_elst_get_pts_offset(&trak->edts.elst, moov_time_scale, timescale); } return 0; } int quicktime_trak_fix_counts(quicktime_t *file, quicktime_trak_t *trak, int moov_time_scale) { int64_t duration; int timescale; quicktime_stts_t * stts; long samples; quicktime_trak_duration(trak, &duration, ×cale); if(file->rd) return fix_counts_read(trak, timescale, moov_time_scale); samples = quicktime_track_samples(file, trak); /* get duration in movie's units */ trak->tkhd.duration = (long)((double)duration / timescale * moov_time_scale + 0.5); trak->mdia.mdhd.duration = duration; trak->mdia.mdhd.time_scale = timescale; if(trak->has_edts) { quicktime_elst_fix_counts(&trak->edts.elst, moov_time_scale, trak, timescale); } if(trak->mdia.minf.is_panorama) trak->edts.elst.total_entries = 1; stts = &trak->mdia.minf.stbl.stts; quicktime_compress_stsc(&trak->mdia.minf.stbl.stsc); if(trak->mdia.minf.is_video || trak->mdia.minf.is_text || trak->mdia.minf.is_timecode) { quicktime_compress_stts(stts); if(trak->mdia.minf.stbl.stts.total_entries == 1) trak->mdia.minf.stbl.stts.table[0].sample_count = samples; } else if(trak->mdia.minf.is_audio_vbr) { quicktime_compress_stts(stts); } else trak->mdia.minf.stbl.stts.table[0].sample_count = samples; if(trak->mdia.minf.is_video && IS_MP4(file->file_type) && trak->mdia.minf.stbl.has_ctts) { quicktime_fix_ctts(&trak->mdia.minf.stbl.ctts); } if(!trak->mdia.minf.stbl.stsz.total_entries) { // trak->mdia.minf.stbl.stsz.sample_size = 1; trak->mdia.minf.stbl.stsz.total_entries = samples; } return 0; } int64_t quicktime_elst_get_pts_offset(quicktime_elst_t *elst, int moov_scale, int timescale); long quicktime_chunk_samples(quicktime_trak_t *trak, long chunk) { long result, current_chunk; quicktime_stsc_t *stsc = &trak->mdia.minf.stbl.stsc; quicktime_stts_t *stts = &trak->mdia.minf.stbl.stts; quicktime_stsd_t *stsd = &trak->mdia.minf.stbl.stsd; long i = stsc->total_entries - 1; if(!stsc->total_entries) return 0; do { current_chunk = stsc->table[i].chunk - 1; result = stsc->table[i].samples; i--; }while(i >= 0 && current_chunk > chunk); /* LQT: Multiply with duration */ if(stsd->table[0].compression_id == -2) result *= stts->table[0].sample_duration; return result; } int quicktime_trak_shift_offsets(quicktime_trak_t *trak, int64_t offset) { quicktime_stco_t *stco = &trak->mdia.minf.stbl.stco; int i; for(i = 0; i < stco->total_entries; i++) { stco->table[i].offset += offset; } return 0; } libquicktime-1.2.4/src/language.c0000644000175000017500000002616211511622756013654 00000000000000/******************************************************************************* language.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #define LOG_DOMAIN "language" /* Definitions for charsets. These are mappings from Macintosh charset symbols to iconv charsets. The ones, which are set to (char*)0 are not available in iconv (replacements??) */ #define smRoman { "MACINTOSH", "ISO-8859-1" }, #define smHebrew { (char*)0, "ISO-8859-8" }, #define smJapanese { (char*)0, "SHIFT-JIS" }, #define smArabic { (char*)0, "ISO-8859-6" }, #define smExtArabic { (char*)0, "ISO-8859-6" }, #define smGreek { (char*)0, (char*)0 }, #define smCentralEuroRoman { (char*)0, "ISO-8859-2" }, #define smIcelandic { "MAC-IS", (char*)0 }, #define smTradChinese { (char*)0, (char*)0 }, #define smDevanagari { (char*)0, (char*)0 }, #define smThai { (char*)0, (char*)0 }, #define smKorean { (char*)0, (char*)0 }, #define smSami { "MAC-SAMI", (char*)0 }, #define smCyrillic { "MAC-CYRILLIC", (char*)0 }, #define smSimpChinese { (char*)0, (char*)0 }, #define smCeltic { (char*)0, (char*)0 }, #define smRomanian { (char*)0, (char*)0 }, #define smUkrainian { "MAC-UK", (char*)0 }, #define smArmenian { (char*)0, (char*)0 }, #define smGeorgian { (char*)0, (char*)0 }, #define smMongolian { (char*)0, (char*)0 }, #define smTibetan { (char*)0, (char*)0 }, #define smBengali { (char*)0, (char*)0 }, #define smGuriati { (char*)0, (char*)0 }, #define smGurmukhi { (char*)0, (char*)0 }, #define smOriya { (char*)0, (char*)0 }, #define smMalayalam { (char*)0, (char*)0 }, #define smKannada { (char*)0, (char*)0 }, #define smTamil { (char*)0, (char*)0 }, #define smTelugu { (char*)0, (char*)0 }, #define smSinhalese { (char*)0, (char*)0 }, #define smBurmese { (char*)0, (char*)0 }, #define smKhmer { (char*)0, (char*)0 }, #define smLaotian { (char*)0, (char*)0 }, #define smVietnamese { (char*)0, (char*)0 }, #define smEthiopic { (char*)0, (char*)0 }, /* Language / character set codecs */ static struct { int mac_code; // Integer mac code char language[4]; // 3 character language code struct { char * charset; // Character set (understood by iconv_open) char * charset_fallback; // Character set (understood by iconv_open) } cs; } mac_languages[] = { { 0, "eng", smRoman }, // English { 1, "fra", smRoman }, // French { 2, "ger", smRoman }, // German { 3, "ita", smRoman }, // Italian { 4, "dut", smRoman }, // Dutch { 5, "swe", smRoman }, // Swedish { 6, "spa", smRoman }, // Spanish { 7, "dan", smRoman }, // Danish { 8, "por", smRoman }, // Portuguese { 9, "nor", smRoman }, // Norwegian { 10, "heb", smHebrew }, // Hebrew { 11, "jpn", smJapanese }, // Japanese { 12, "ara", smArabic }, // Arabic { 13, "fin", smRoman }, // Finnish { 14, "gre", smGreek }, // Greek { 15, "ice", smIcelandic }, // Icelandic { 16, "mlt", smRoman }, // Maltese { 17, "tur", smRoman }, // Turkish { 18, "scr", smRoman }, // Croatian { 19, "chi", smTradChinese }, // Traditional Chinese { 20, "urd", smArabic }, // Urdu { 21, "hin", smDevanagari }, // Hindi { 22, "tha", smThai }, // Thai { 23, "kor", smKorean}, // Korean { 24, "lit", smCentralEuroRoman }, // Lithuanian { 25, "pol", smCentralEuroRoman }, // Polish { 26, "hun", smCentralEuroRoman }, // Hungarian { 27, "est", smCentralEuroRoman }, // Estonian { 28, "lav", smCentralEuroRoman }, // Latvian { 29, "smi", smSami }, // Saamisk { 30, "fao", smIcelandic}, // Faeroese { 31, "far", smArabic }, // Farsi { 32, "rus", smCyrillic }, // Russian { 33, "chi", smSimpChinese }, // Simplified Chinese { 34, "dut", smRoman }, // Flemish { 35, "gle", smCeltic }, // Irish { 36, "alb", smRoman }, // Albanian { 37, "rum", smRomanian }, // Romanian { 38, "cze", smCentralEuroRoman }, // Czech { 39, "slo", smCentralEuroRoman }, // Slovak { 40, "slv", smCentralEuroRoman }, // Slovenian { 41, "yid", smHebrew }, // Yiddish { 42, "scc", smCyrillic }, // Serbian { 43, "mac", smCyrillic }, // Macedonian { 44, "bul", smCyrillic }, // Bulgarian { 45, "ukr", smUkrainian }, // Ukrainian { 46, "bel", smCyrillic }, // Byelorussian { 47, "uzb", smCyrillic }, // Uzbek { 48, "kaz", smCyrillic }, // Kazakh { 49, "aze", smCyrillic }, // Azerbaijani (cyrillic) { 50, "aze", smArabic }, // Azerbaijani (arabic) { 51, "arm", smArmenian }, // Armenian { 52, "geo", smGeorgian }, // Georgian { 53, "mol", smCyrillic }, // Moldavian { 54, "kir", smCyrillic }, // Kirghiz { 55, "tgk", smCyrillic }, // Tajiki { 56, "tuk", smCyrillic }, // Turkmen { 57, "mon", smMongolian }, // Mongolian { 58, "mon", smCyrillic }, // Mongolian (cyrillic) { 59, "pus", smArabic }, // Pashto { 60, "kur", smArabic }, // Kurdish { 61, "kas", smArabic }, // Kashmiri { 62, "snd", smExtArabic }, // Sindhi { 63, "tib", smTibetan }, // Tibetan { 64, "nep", smDevanagari }, // Nepali { 65, "san", smDevanagari }, // Sanskrit // { 66, "", smDevanagari }, // Marathi ?? { 67, "ben", smBengali }, // Bengali { 68, "asm", smBengali }, // Assamese { 69, "guj", smGuriati }, // Gujarati { 70, "pan", smGurmukhi }, // Punjabi { 71, "ori", smOriya }, // Oriya { 72, "mal", smMalayalam }, // Malayalam { 73, "kan", smKannada }, // Kannada { 74, "tam", smTamil }, // Tamil { 75, "tel", smTelugu }, // Telugu { 76, "sin", smSinhalese }, // Sinhalese { 77, "bur", smBurmese }, // Burmese { 78, "khm", smKhmer }, // Khmer { 79, "lao", smLaotian }, // Lao { 80, "vie", smVietnamese }, // Vietnamese { 81, "ind", smRoman }, // Indonesian { 82, "tgl", smRoman }, // Tagalog { 83, "may", smRoman }, // Malay (roman) { 84, "may", smArabic }, // Malay (arabic) { 85, "amh", smEthiopic }, // Amharic { 86, "tir", smEthiopic }, // Tigrinya { 87, "orm", smEthiopic }, // Oromo { 88, "som", smRoman }, // Somali { 89, "swa", smRoman }, // Swahili { 90, "kin", smRoman }, // Kinyarwanda { 91, "run", smRoman }, // Rundi { 92, "nya", smRoman }, // Chewa { 93, "mlg", smRoman }, // Malagasy { 94, "epo", smRoman }, // Esperanto { 128, "wel", smRoman }, // Welsh { 129, "baq", smRoman }, // Basque { 130, "cat", smRoman }, // Catalan { 131, "lat", smRoman }, // Latin { 132, "que", smRoman }, // Quechua { 133, "grn", smRoman }, // Guarani { 134, "aym", smRoman }, // Aymara { 135, "tat", smCyrillic }, // Tatar { 136, "uig", smArabic }, // Uighur { 137, "dzo", smTibetan }, // Dzongkha { 138, "jav", smRoman }, // Javanese (roman) }; #define NUM_CODES (sizeof(mac_languages)/sizeof(mac_languages[0])) static int get_language(quicktime_trak_t * trak, char * ret, lqt_file_type_t file_type) { int i; if(IS_MP4(file_type)) { ret[0] = ((trak->mdia.mdhd.language >> 10) & 0x1f) + 0x60; ret[1] = ((trak->mdia.mdhd.language >> 5) & 0x1f) + 0x60; ret[2] = (trak->mdia.mdhd.language & 0x1f) + 0x60; ret[3] = '\0'; return 1; } for(i = 0; i < NUM_CODES; i++) { if(trak->mdia.mdhd.language == mac_languages[i].mac_code) { strcpy(ret, mac_languages[i].language); return 1; } } return 0; } static char * unicode_string = LQT_UTF_8_16; const char * lqt_get_charset(int mac_code, lqt_file_type_t file_type) { int i; if(IS_MP4(file_type)) return unicode_string; for(i = 0; i < NUM_CODES; i++) { if(mac_code == mac_languages[i].mac_code) return mac_languages[i].cs.charset; } return (char*)0; } const char * lqt_get_charset_fallback(int mac_code, lqt_file_type_t file_type) { int i; if(IS_MP4(file_type)) return unicode_string; for(i = 0; i < NUM_CODES; i++) { if(mac_code == mac_languages[i].mac_code) return mac_languages[i].cs.charset_fallback; } return (char*)0; } static int set_language_code(quicktime_trak_t * trak, const char * language, lqt_file_type_t file_type) { int i; if(IS_MP4(file_type)) { trak->mdia.mdhd.language = ((int)(language[0]-0x60) << 10) | ((int)(language[1]-0x60) << 5) | ((int)(language[2]-0x60)); return 0; } for(i = 0; i < NUM_CODES; i++) { if(!strcmp(language, mac_languages[i].language)) { trak->mdia.mdhd.language = mac_languages[i].mac_code; return 1; } } return 0; } void lqt_set_audio_language(quicktime_t * file, int track, const char * language) { if((track < 0) || (track >= file->total_atracks)) return; set_language_code((file->atracks[track].track), language, file->file_type); } int lqt_get_audio_language(quicktime_t * file, int track, char * language) { if((track < 0) || (track >= file->total_atracks)) return 0; return get_language(file->atracks[track].track, language, file->file_type); } void lqt_set_text_language(quicktime_t * file, int track, const char * language) { if((track < 0) || (track >= file->total_ttracks)) return; set_language_code((file->ttracks[track].track), language, file->file_type); } int lqt_get_text_language(quicktime_t * file, int track, char * language) { if((track < 0) || (track >= file->total_ttracks)) return 0; return get_language(file->ttracks[track].track, language, file->file_type); } libquicktime-1.2.4/src/util.c0000644000175000017500000005610311511622757013045 00000000000000/******************************************************************************* util.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include "lqt_fseek.h" #include "workarounds.h" #include #include #include #include #include #include #include #ifndef HAVE_LRINT #define lrint(x) ((long int)(x)) #endif /* Disk I/O */ int64_t quicktime_get_file_length(const char *path) { struct stat status; if(stat(path, &status)) perror("quicktime_get_file_length stat:"); return status.st_size; } int quicktime_file_open(quicktime_t *file, const char *path, int rd, int wr) { int exists = 0; char flags[10]; if(rd && (file->stream = fopen(path, "rb"))) { exists = 1; fclose(file->stream); } if(rd && !wr) sprintf(flags, "rb"); else if(!rd && wr) sprintf(flags, "wb"); else if(rd && wr) { if(exists) sprintf(flags, "rb+"); else sprintf(flags, "wb+"); } if(!(file->stream = fopen(path, flags))) { return 1; } if(rd && exists) { file->total_length = quicktime_get_file_length(path); } if(wr) file->presave_buffer = calloc(1, QUICKTIME_PRESAVE); return 0; } int quicktime_file_close(quicktime_t *file) { /* Flush presave buffer */ if(file->presave_size) { quicktime_fseek(file, file->presave_position - file->presave_size); fwrite(file->presave_buffer, 1, file->presave_size, file->stream); file->presave_size = 0; } if(file->stream) { fclose(file->stream); } file->stream = 0; return 0; } int64_t quicktime_ftell(quicktime_t *file) { return file->ftell_position; } int quicktime_fseek(quicktime_t *file, int64_t offset) { file->ftell_position = offset; if(offset > file->total_length || offset < 0) return 1; if(fseeko(file->stream, file->ftell_position, SEEK_SET)) { // perror("quicktime_fseek fseeko"); return 1; } return 0; } /* Read entire buffer from the preload buffer */ static int read_preload(quicktime_t *file, uint8_t *data, int64_t size) { int64_t selection_start = 0; int64_t selection_end = 0; int64_t fragment_start = 0; int64_t fragment_len = 0; selection_start = file->file_position; selection_end = quicktime_add(file->file_position, size); fragment_start = file->preload_ptr + (selection_start - file->preload_start); while(fragment_start < 0) fragment_start += file->preload_size; while(fragment_start >= file->preload_size) fragment_start -= file->preload_size; while(selection_start < selection_end) { fragment_len = selection_end - selection_start; if(fragment_start + fragment_len > file->preload_size) fragment_len = file->preload_size - fragment_start; memcpy(data, file->preload_buffer + fragment_start, fragment_len); fragment_start += fragment_len; data += fragment_len; if(fragment_start >= file->preload_size) fragment_start = (int64_t)0; selection_start += fragment_len; } return 0; } int quicktime_read_data(quicktime_t *file, uint8_t *data, int64_t size) { int result = 1; /* Return if we had an error before */ if(file->io_error || file->io_eof) return 0; if(!file->preload_size) { quicktime_fseek(file, file->file_position); result = fread(data, 1, size, file->stream); if(result < size) { file->io_error = ferror(file->stream); file->io_eof = feof(file->stream); } file->ftell_position += size; } else { /* Region requested for loading */ int64_t selection_start = file->file_position; int64_t selection_end = file->file_position + size; int64_t fragment_start, fragment_len; if(selection_end - selection_start > file->preload_size) { /* Size is larger than preload size. Should never happen. */ quicktime_fseek(file, file->file_position); result = fread(data, 1, size, file->stream); if(result < size) { file->io_error = ferror(file->stream); file->io_eof = feof(file->stream); } file->ftell_position += size; } else if(selection_start >= file->preload_start && selection_start < file->preload_end && selection_end <= file->preload_end && selection_end > file->preload_start) { /* Entire range is in buffer */ read_preload(file, data, size); result = size; } else if(selection_end > file->preload_end && selection_end - file->preload_size < file->preload_end) { /* Range is after buffer */ /* Move the preload start to within one preload length of the selection_end */ while(selection_end - file->preload_start > file->preload_size) { fragment_len = selection_end - file->preload_start - file->preload_size; if(file->preload_ptr + fragment_len > file->preload_size) fragment_len = file->preload_size - file->preload_ptr; file->preload_start += fragment_len; file->preload_ptr += fragment_len; if(file->preload_ptr >= file->preload_size) file->preload_ptr = 0; } /* Append sequential data after the preload end to the new end */ fragment_start = file->preload_ptr + file->preload_end - file->preload_start; while(fragment_start >= file->preload_size) fragment_start -= file->preload_size; while(file->preload_end < selection_end) { fragment_len = selection_end - file->preload_end; if(fragment_start + fragment_len > file->preload_size) fragment_len = file->preload_size - fragment_start; quicktime_fseek(file, file->preload_end); result = fread(&file->preload_buffer[fragment_start], fragment_len, 1, file->stream); if(result < fragment_len) { file->io_error = ferror(file->stream); file->io_eof = feof(file->stream); } file->ftell_position += fragment_len; file->preload_end += fragment_len; fragment_start += fragment_len; if(fragment_start >= file->preload_size) fragment_start = 0; } read_preload(file, data, size); result = size; } else { /* Range is before buffer or over a preload_size away from the end of the buffer. */ /* Replace entire preload buffer with range. */ quicktime_fseek(file, file->file_position); result = fread(file->preload_buffer, 1, size, file->stream); if(result < size) { file->io_error = ferror(file->stream); file->io_eof = feof(file->stream); } file->ftell_position += size; file->preload_start = file->file_position; file->preload_end = file->file_position + size; file->preload_ptr = 0; read_preload(file, data, size); } } file->file_position += size; return result; } int quicktime_write_data(quicktime_t *file, const uint8_t *data, int size) { int data_offset = 0; int writes_attempted = 0; int writes_succeeded = 0; if(file->io_error) return 0; // Flush existing buffer and seek to new position if(file->file_position != file->presave_position) { if(file->presave_size) { quicktime_fseek(file, file->presave_position - file->presave_size); writes_succeeded += fwrite(file->presave_buffer, 1, file->presave_size, file->stream); writes_attempted += file->presave_size; file->presave_size = 0; } file->presave_position = file->file_position; } // Write presave buffers until done while(size > 0) { int fragment_size = QUICKTIME_PRESAVE; if(fragment_size > size) fragment_size = size; if(fragment_size + file->presave_size > QUICKTIME_PRESAVE) fragment_size = QUICKTIME_PRESAVE- file->presave_size; memcpy(file->presave_buffer + file->presave_size, data + data_offset, fragment_size); file->presave_position += fragment_size; file->presave_size += fragment_size; data_offset += fragment_size; size -= fragment_size; if(file->presave_size >= QUICKTIME_PRESAVE) { quicktime_fseek(file, file->presave_position - file->presave_size); writes_succeeded += fwrite(file->presave_buffer, 1, file->presave_size, file->stream); writes_attempted += file->presave_size; file->presave_size = 0; } } /* Adjust file position */ file->file_position = file->presave_position; /* Adjust ftell position */ file->ftell_position = file->presave_position; /* Adjust total length */ if(file->total_length < file->ftell_position) file->total_length = file->ftell_position; /* fwrite failed */ if(!writes_succeeded && writes_attempted) { file->io_error = ferror(file->stream); return 0; } else if(!size) return 1; else return size; } int64_t quicktime_byte_position(quicktime_t *file) { return quicktime_position(file); } void quicktime_read_pascal(quicktime_t *file, char *data) { char len = quicktime_read_char(file); quicktime_read_data(file, (uint8_t*)data, len); data[(int)len] = 0; } void quicktime_write_pascal(quicktime_t *file, char *data) { uint8_t len = strlen(data); quicktime_write_data(file, &len, 1); quicktime_write_data(file, (uint8_t*)data, len); } float quicktime_read_fixed32(quicktime_t *file) { unsigned long a, b, c, d; uint8_t data[4]; quicktime_read_data(file, data, 4); a = data[0]; b = data[1]; c = data[2]; d = data[3]; a = (a << 8) + b; b = (c << 8) + d; if(b) return (float)a + (float)b / 65536; else return a; } int quicktime_write_fixed32(quicktime_t *file, float number) { unsigned char data[4]; int a, b; a = number; b = (number - a) * 65536; data[0] = a >> 8; data[1] = a & 0xff; data[2] = b >> 8; data[3] = b & 0xff; return quicktime_write_data(file, data, 4); } static float float32_be_read (unsigned char *cptr) { int exponent, mantissa, negative ; float fvalue ; negative = cptr [0] & 0x80 ; exponent = ((cptr [0] & 0x7F) << 1) | ((cptr [1] & 0x80) ? 1 : 0) ; mantissa = ((cptr [1] & 0x7F) << 16) | (cptr [2] << 8) | (cptr [3]) ; if (! (exponent || mantissa)) return 0.0 ; mantissa |= 0x800000 ; exponent = exponent ? exponent - 127 : 0 ; fvalue = mantissa ? ((float) mantissa) / ((float) 0x800000) : 0.0 ; if (negative) fvalue *= -1 ; if (exponent > 0) fvalue *= (1 << exponent) ; else if (exponent < 0) fvalue /= (1 << abs (exponent)) ; return fvalue ; } /* float32_be_read */ static double double64_be_read (unsigned char *cptr) { int exponent, negative ; double dvalue ; negative = (cptr [0] & 0x80) ? 1 : 0 ; exponent = ((cptr [0] & 0x7F) << 4) | ((cptr [1] >> 4) & 0xF) ; /* Might not have a 64 bit long, so load the mantissa into a double. */ dvalue = (((cptr [1] & 0xF) << 24) | (cptr [2] << 16) | (cptr [3] << 8) | cptr [4]) ; dvalue += ((cptr [5] << 16) | (cptr [6] << 8) | cptr [7]) / ((double) 0x1000000) ; if (exponent == 0 && dvalue == 0.0) return 0.0 ; dvalue += 0x10000000 ; exponent = exponent - 0x3FF ; dvalue = dvalue / ((double) 0x10000000) ; if (negative) dvalue *= -1 ; if (exponent > 0) dvalue *= (1 << exponent) ; else if (exponent < 0) dvalue /= (1 << abs (exponent)) ; return dvalue ; } /* double64_be_read */ static void float32_be_write (float in, unsigned char *out) { int exponent, mantissa, negative = 0 ; memset (out, 0, sizeof (int)) ; if (in == 0.0) return ; if (in < 0.0) { in *= -1.0 ; negative = 1 ; } ; in = frexp (in, &exponent) ; exponent += 126 ; in *= (float) 0x1000000 ; mantissa = (((int) in) & 0x7FFFFF) ; if (negative) out [0] |= 0x80 ; if (exponent & 0x01) out [1] |= 0x80 ; out [3] = mantissa & 0xFF ; out [2] = (mantissa >> 8) & 0xFF ; out [1] |= (mantissa >> 16) & 0x7F ; out [0] |= (exponent >> 1) & 0x7F ; return ; } /* float32_be_write */ static void double64_be_write (double in, unsigned char *out) { int exponent, mantissa ; memset (out, 0, sizeof (double)) ; if (in == 0.0) return ; if (in < 0.0) { in *= -1.0 ; out [0] |= 0x80 ; } ; in = frexp (in, &exponent) ; exponent += 1022 ; out [0] |= (exponent >> 4) & 0x7F ; out [1] |= (exponent << 4) & 0xF0 ; in *= 0x20000000 ; mantissa = lrint (floor (in)) ; out [1] |= (mantissa >> 24) & 0xF ; out [2] = (mantissa >> 16) & 0xFF ; out [3] = (mantissa >> 8) & 0xFF ; out [4] = mantissa & 0xFF ; in = fmod (in, 1.0) ; in *= 0x1000000 ; mantissa = lrint (floor (in)) ; out [5] = (mantissa >> 16) & 0xFF ; out [6] = (mantissa >> 8) & 0xFF ; out [7] = mantissa & 0xFF ; return ; } /* double64_be_write */ float quicktime_read_float32(quicktime_t *file) { unsigned char b[4]; quicktime_read_data(file, b, 4); return float32_be_read(b); } double quicktime_read_double64(quicktime_t *file) { unsigned char b[8]; quicktime_read_data(file, b, 8); return double64_be_read(b); } int quicktime_write_float32(quicktime_t *file, float value) { unsigned char b[4]; float32_be_write(value, b); return quicktime_write_data(file, b, 4); } int quicktime_write_double64(quicktime_t *file, double value) { unsigned char b[8]; double64_be_write(value, b); return quicktime_write_data(file, b, 8); } int quicktime_write_int64(quicktime_t *file, int64_t value) { unsigned char data[8]; data[0] = (((uint64_t)value) & 0xff00000000000000LL) >> 56; data[1] = (((uint64_t)value) & 0xff000000000000LL) >> 48; data[2] = (((uint64_t)value) & 0xff0000000000LL) >> 40; data[3] = (((uint64_t)value) & 0xff00000000LL) >> 32; data[4] = (((uint64_t)value) & 0xff000000LL) >> 24; data[5] = (((uint64_t)value) & 0xff0000LL) >> 16; data[6] = (((uint64_t)value) & 0xff00LL) >> 8; data[7] = ((uint64_t)value) & 0xff; return quicktime_write_data(file, data, 8); } int quicktime_write_int64_le(quicktime_t *file, int64_t value) { unsigned char data[8]; data[7] = (((uint64_t)value) & 0xff00000000000000LL) >> 56; data[6] = (((uint64_t)value) & 0xff000000000000LL) >> 48; data[5] = (((uint64_t)value) & 0xff0000000000LL) >> 40; data[4] = (((uint64_t)value) & 0xff00000000LL) >> 32; data[3] = (((uint64_t)value) & 0xff000000LL) >> 24; data[2] = (((uint64_t)value) & 0xff0000LL) >> 16; data[1] = (((uint64_t)value) & 0xff00LL) >> 8; data[0] = ((uint64_t)value) & 0xff; return quicktime_write_data(file, data, 8); } int quicktime_write_int32(quicktime_t *file, long value) { unsigned char data[4]; data[0] = (value & 0xff000000) >> 24; data[1] = (value & 0xff0000) >> 16; data[2] = (value & 0xff00) >> 8; data[3] = value & 0xff; return quicktime_write_data(file, data, 4); } int quicktime_write_int32_le(quicktime_t *file, long value) { unsigned char data[4]; data[3] = (value & 0xff000000) >> 24; data[2] = (value & 0xff0000) >> 16; data[1] = (value & 0xff00) >> 8; data[0] = value & 0xff; return quicktime_write_data(file, data, 4); } int quicktime_write_char32(quicktime_t *file, char *string) { return quicktime_write_data(file, (uint8_t*)string, 4); } float quicktime_read_fixed16(quicktime_t *file) { unsigned char data[2]; quicktime_read_data(file, data, 2); if(data[1]) return (float)data[0] + (float)data[1] / 256; else return (float)data[0]; } int quicktime_write_fixed16(quicktime_t *file, float number) { unsigned char data[2]; int a, b; a = number; b = (number - a) * 256; data[0] = a; data[1] = b; return quicktime_write_data(file, data, 2); } unsigned long quicktime_read_uint32(quicktime_t *file) { unsigned long result; unsigned long a, b, c, d; uint8_t data[4]; quicktime_read_data(file, data, 4); a = data[0]; b = data[1]; c = data[2]; d = data[3]; result = (a << 24) | (b << 16) | (c << 8) | d; return result; } long quicktime_read_int32(quicktime_t *file) { unsigned long result; unsigned long a, b, c, d; uint8_t data[4]; quicktime_read_data(file, data, 4); a = data[0]; b = data[1]; c = data[2]; d = data[3]; result = (a << 24) | (b << 16) | (c << 8) | d; return (long)result; } long quicktime_read_int32_le(quicktime_t *file) { unsigned long result; unsigned long a, b, c, d; uint8_t data[4]; quicktime_read_data(file, data, 4); a = data[0]; b = data[1]; c = data[2]; d = data[3]; result = (d << 24) | (c << 16) | (b << 8) | a; return (long)result; } int64_t quicktime_read_int64(quicktime_t *file) { uint64_t result, a, b, c, d, e, f, g, h; uint8_t data[8]; quicktime_read_data(file, data, 8); a = data[0]; b = data[1]; c = data[2]; d = data[3]; e = data[4]; f = data[5]; g = data[6]; h = data[7]; result = (a << 56) | (b << 48) | (c << 40) | (d << 32) | (e << 24) | (f << 16) | (g << 8) | h; return (int64_t)result; } int64_t quicktime_read_int64_le(quicktime_t *file) { uint64_t result, a, b, c, d, e, f, g, h; uint8_t data[8]; quicktime_read_data(file, data, 8); a = data[7]; b = data[6]; c = data[5]; d = data[4]; e = data[3]; f = data[2]; g = data[1]; h = data[0]; result = (a << 56) | (b << 48) | (c << 40) | (d << 32) | (e << 24) | (f << 16) | (g << 8) | h; return (int64_t)result; } long quicktime_read_int24(quicktime_t *file) { unsigned long result; unsigned long a, b, c; uint8_t data[4]; quicktime_read_data(file, data, 3); a = data[0]; b = data[1]; c = data[2]; result = (a << 16) | (b << 8) | c; return (long)result; } int quicktime_write_int24(quicktime_t *file, long number) { unsigned char data[3]; data[0] = (number & 0xff0000) >> 16; data[1] = (number & 0xff00) >> 8; data[2] = (number & 0xff); return quicktime_write_data(file, data, 3); } int quicktime_read_int16(quicktime_t *file) { unsigned long result; unsigned long a, b; uint8_t data[2]; quicktime_read_data(file, data, 2); a = data[0]; b = data[1]; result = (a << 8) | b; return (int)result; } int quicktime_read_int16_le(quicktime_t *file) { unsigned long result; unsigned long a, b; uint8_t data[2]; quicktime_read_data(file, data, 2); a = data[0]; b = data[1]; result = (b << 8) | a; return (int)result; } int quicktime_write_int16(quicktime_t *file, int number) { unsigned char data[2]; data[0] = (number & 0xff00) >> 8; data[1] = (number & 0xff); return quicktime_write_data(file, data, 2); } int quicktime_write_int16_le(quicktime_t *file, int number) { unsigned char data[2]; data[1] = (number & 0xff00) >> 8; data[0] = (number & 0xff); return quicktime_write_data(file, data, 2); } int quicktime_read_char(quicktime_t *file) { char output; quicktime_read_data(file, (uint8_t*)(&output), 1); return output; } int quicktime_write_char(quicktime_t *file, char x) { return quicktime_write_data(file, (uint8_t*)(&x), 1); } void quicktime_read_char32(quicktime_t *file, char *string) { quicktime_read_data(file, (uint8_t*)string, 4); } int64_t quicktime_position(quicktime_t *file) { return file->file_position; } int quicktime_set_position(quicktime_t *file, int64_t position) { file->file_position = position; return 0; } void quicktime_copy_char32(char *output, char *input) { *output++ = *input++; *output++ = *input++; *output++ = *input++; *output = *input; } void quicktime_print_chars(char *desc, uint8_t *input, int len) { int i; lqt_dump("%s", desc); for(i = 0; i < len; i++) lqt_dump("%02x ", input[i]); lqt_dump("\n"); } unsigned long quicktime_current_time(void) { time_t t; time (&t); return (t+(66*31536000)+1468800); } int quicktime_match_32(void *_input, void *_output) { uint8_t * input = (uint8_t*)_input; uint8_t * output = (uint8_t*)_output; if(input[0] == output[0] && input[1] == output[1] && input[2] == output[2] && input[3] == output[3]) return 1; else return 0; } int quicktime_match_24(char *input, char *output) { if(input[0] == output[0] && input[1] == output[1] && input[2] == output[2]) return 1; else return 0; } static void do_hexdump(uint8_t * data, int len, int linebreak, FILE * f) { int i; int bytes_written = 0; int imax; while(bytes_written < len) { imax = (bytes_written + linebreak > len) ? len - bytes_written : linebreak; for(i = 0; i < imax; i++) fprintf(f, "%02x ", data[bytes_written + i]); for(i = imax; i < linebreak; i++) fprintf(f, " "); for(i = 0; i < imax; i++) { if(!(data[bytes_written + i] & 0x80) && (data[bytes_written + i] >= 32)) fprintf(f, "%c", data[bytes_written + i]); else fprintf(f, "."); } bytes_written += imax; fprintf(f, "\n"); } } void lqt_hexdump(uint8_t * data, int len, int linebreak) { do_hexdump(data, len, linebreak, stderr); } void lqt_hexdump_stdout(uint8_t * data, int len, int linebreak) { do_hexdump(data, len, linebreak, stdout); } void lqt_dump_time(uint64_t t) { time_t ti; struct tm tm; /* 2082844800 = seconds between 1/1/04 and 1/1/70 */ ti = t - 2082844800; localtime_r(&ti, &tm); tm.tm_mon++; printf("%04d-%02d-%02d %02d:%02d:%02d (%"PRId64")", tm.tm_year+1900, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, t); } libquicktime-1.2.4/src/gmin.c0000644000175000017500000000544111511622756013020 00000000000000/******************************************************************************* gmin.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" void quicktime_gmin_init(quicktime_gmin_t *gmin) { gmin->version = 0; gmin->flags = 0; gmin->graphics_mode = 64; gmin->opcolor[0] = 32768; gmin->opcolor[1] = 32768; gmin->opcolor[2] = 32768; gmin->balance = 0; } void quicktime_gmin_delete(quicktime_gmin_t *gmin) { } void quicktime_gmin_dump(quicktime_gmin_t *gmin) { lqt_dump(" Base media info (gmin)\n"); lqt_dump(" version %d\n", gmin->version); lqt_dump(" flags %ld\n", gmin->flags); lqt_dump(" graphics_mode %d\n", gmin->graphics_mode); lqt_dump(" opcolor %d %d %d\n", gmin->opcolor[0], gmin->opcolor[1], gmin->opcolor[2]); lqt_dump(" balance %d\n", gmin->balance); } void quicktime_read_gmin(quicktime_t *file, quicktime_gmin_t *gmin) { int i; gmin->version = quicktime_read_char(file); gmin->flags = quicktime_read_int24(file); gmin->graphics_mode = quicktime_read_int16(file); for(i = 0; i < 3; i++) gmin->opcolor[i] = quicktime_read_int16(file); gmin->balance = quicktime_read_int16(file); } void quicktime_write_gmin(quicktime_t *file, quicktime_gmin_t *gmin) { quicktime_atom_t atom; int i; quicktime_atom_write_header(file, &atom, "gmin"); quicktime_write_char(file, gmin->version); quicktime_write_int24(file, gmin->flags); quicktime_write_int16(file, gmin->graphics_mode); for(i = 0; i < 3; i++) quicktime_write_int16(file, gmin->opcolor[i]); quicktime_write_int16(file, gmin->balance); quicktime_write_int16(file, gmin->reserved); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/avi_info.c0000644000175000017500000001265311511622756013663 00000000000000/******************************************************************************* avi_info.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include "charset.h" #include #include static char * my_strdup(const char * str) { char * ret = malloc(strlen(str)+1); strcpy(ret, str); return ret; } /* RS == read_string */ #define RS(tag) \ if(!strncmp((char*)ptr, #tag, 4)) \ { \ info->tag = my_strdup((char*)(ptr + 8)); \ lqt_charset_convert(cnv, &info->tag, -1, (int*)0); \ ptr += string_len + 8; \ if(string_len % 2) \ ptr++; \ continue; \ } void quicktime_read_riffinfo(quicktime_t *file, quicktime_riffinfo_t *info, quicktime_atom_t *parent_atom) { uint32_t string_len; uint8_t *buf, * ptr, *end_ptr; lqt_charset_converter_t * cnv; int size = parent_atom->end - quicktime_position(file); buf = malloc(size); ptr = buf; quicktime_read_data(file, ptr, size); end_ptr = ptr + size; cnv = lqt_charset_converter_create(file, "ISO-8859-1", "UTF-8"); while(ptr < end_ptr) { string_len = ((uint32_t)ptr[4]) | (((uint32_t)ptr[5]) << 8) | (((uint32_t)ptr[6]) << 16) | (((uint32_t)ptr[7]) << 24); RS(IARL); RS(IART); RS(ICMS); RS(ICMT); RS(ICOP); RS(ICRD); RS(ICRP); RS(IDIM); RS(IDPI); RS(IENG); RS(IGNR); RS(IKEY); RS(ILGT); RS(IMED); RS(INAM); RS(IPLT); RS(IPRD); RS(ISBJ); RS(ISFT); RS(ISHP); RS(ISRC); RS(ISRF); RS(ITCH); ptr += string_len + 8; if(string_len % 2) ptr++; } free(buf); lqt_charset_converter_destroy(cnv); } #undef RS void quicktime_init_riffinfo(quicktime_riffinfo_t *info) { info->ISFT = my_strdup(PACKAGE"-"VERSION); } /* WS == write_string */ #define WS(tag) \ if(info->tag) \ { \ lqt_charset_convert(cnv, &info->tag, -1, (int*)0); \ quicktime_atom_write_header(file, &child_atom, #tag);\ /* The trailing '\0' must be written to the file! */\ quicktime_write_data(file, (uint8_t*)info->tag, strlen(info->tag)+1); \ quicktime_atom_write_footer(file, &child_atom);\ } void quicktime_write_riffinfo(quicktime_t *file, quicktime_riffinfo_t *info) { quicktime_atom_t atom; quicktime_atom_t child_atom; lqt_charset_converter_t * cnv; cnv = lqt_charset_converter_create(file, "UTF-8", "ISO-8859-1"); quicktime_atom_write_header(file, &atom, "LIST"); quicktime_write_char32(file, "INFO"); WS(IARL); WS(IART); WS(ICMS); WS(ICMT); WS(ICOP); WS(ICRD); WS(ICRP); WS(IDIM); WS(IDPI); WS(IENG); WS(IGNR); WS(IKEY); WS(ILGT); WS(IMED); WS(INAM); WS(IPLT); WS(IPRD); WS(ISBJ); WS(ISFT); WS(ISHP); WS(ISRC); WS(ISRF); WS(ITCH); quicktime_atom_write_footer(file, &atom); lqt_charset_converter_destroy(cnv); } #define CP_STR_INFO_2_UDTA(src, dst, dst_len) \ if(info->src) \ { \ udta->dst = my_strdup(info->src); \ udta->dst_len = strlen(info->src); \ } void quicktime_riffinfo_2_udta(quicktime_riffinfo_t * info, quicktime_udta_t * udta) { /* Artist */ CP_STR_INFO_2_UDTA(IART, artist, artist_len); /* Name */ CP_STR_INFO_2_UDTA(INAM, name, name_len); /* Comment */ CP_STR_INFO_2_UDTA(ICMT, comment, comment_len); /* Copyright */ CP_STR_INFO_2_UDTA(ICOP, copyright, copyright_len); /* genre */ CP_STR_INFO_2_UDTA(IGNR, genre, genre_len); } #undef CP_STR_INFO_2_UDTA #define CP_STR_UDTA_2_INFO(dst, src) \ if(udta->src) \ { \ info->dst = my_strdup(udta->src); \ } void quicktime_udta_2_riffinfo(quicktime_udta_t * udta, quicktime_riffinfo_t * info) { /* Artist */ CP_STR_UDTA_2_INFO(IART, artist); /* Name */ CP_STR_UDTA_2_INFO(INAM, name); /* Comment */ CP_STR_UDTA_2_INFO(ICMT, comment); /* Copyright */ CP_STR_UDTA_2_INFO(ICOP, copyright); /* genre */ CP_STR_UDTA_2_INFO(IGNR, genre); } /* FS = free_string */ #define FS(tag) if(info->tag) { free(info->tag); info->tag = (char*)0; } void quicktime_delete_riffinfo(quicktime_riffinfo_t * info) { FS(IARL); FS(IART); FS(ICMS); FS(ICMT); FS(ICOP); FS(ICRD); FS(ICRP); FS(IDIM); FS(IDPI); FS(IENG); FS(IGNR); FS(IKEY); FS(ILGT); FS(IMED); FS(INAM); FS(IPLT); FS(IPRD); FS(ISBJ); FS(ISFT); FS(ISHP); FS(ISRC); FS(ISRF); FS(ITCH); } libquicktime-1.2.4/src/udta.c0000644000175000017500000003513411511622757013026 00000000000000/******************************************************************************* udta.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include "charset.h" #include #include #include #define LOG_DOMAIN "udta" #define ILST_TYPES (LQT_FILE_M4A) // #define DEFAULT_INFO "Made with Libquicktime" /* Atom IDs */ static char copyright_id[] = { 0xa9, 'c', 'p', 'y' }; static char info_id[] = { 0xa9, 'i', 'n', 'f' }; static char name_id[] = { 0xa9, 'n', 'a', 'm' }; static char artist_id[] = { 0xa9, 'A', 'R', 'T' }; static char album_id[] = { 0xa9, 'a', 'l', 'b' }; static char track_id[] = { 0xa9, 't', 'r', 'k' }; static char comment_id[] = { 0xa9, 'c', 'm', 't' }; static char author_id[] = { 0xa9, 'a', 'u', 't' }; static char genre_id[] = { 0xa9, 'g', 'e', 'n' }; static char trkn_id[] = { 't', 'r', 'k', 'n' }; int quicktime_udta_init(quicktime_udta_t *udta) { memset(udta, 0, sizeof(*udta)); udta->is_qtvr = 0; quicktime_navg_init(&udta->navg); quicktime_hdlr_init_udta(&udta->hdlr); return 0; } int quicktime_udta_delete(quicktime_udta_t *udta) { if(udta->copyright_len) { free(udta->copyright); } if(udta->name_len) { free(udta->name); } if(udta->info_len) { free(udta->info); } if(udta->author_len) { free(udta->author); } if(udta->artist_len) { free(udta->artist); } if(udta->genre_len) { free(udta->genre); } if(udta->comment_len) { free(udta->comment); } if(udta->track_len) { free(udta->track); } if(udta->album_len) { free(udta->album); } quicktime_hdlr_delete(&udta->hdlr); return 0; } void quicktime_udta_dump(quicktime_udta_t *udta) { lqt_dump(" user data (udta)\n"); if(udta->has_hdlr) quicktime_hdlr_dump(&udta->hdlr); if(udta->copyright_len) lqt_dump(" copyright: %s\n", udta->copyright); if(udta->name_len) lqt_dump(" name: %s\n", udta->name); if(udta->info_len) lqt_dump(" info: %s\n", udta->info); if(udta->author_len) lqt_dump(" author: %s\n", udta->author); if(udta->artist_len) lqt_dump(" artist: %s\n", udta->artist); if(udta->album_len) lqt_dump(" album: %s\n", udta->album); if(udta->track_len) lqt_dump(" track: %s\n", udta->track); if(udta->genre_len) lqt_dump(" genre: %s\n", udta->genre); if(udta->comment_len) lqt_dump(" comment: %s\n", udta->comment); if(udta->is_qtvr) lqt_dump(" ctyp: %c%c%c%c\n", udta->ctyp[0], udta->ctyp[1], udta->ctyp[2], udta->ctyp[3]); if(quicktime_match_32(udta->ctyp, "stna")) quicktime_navg_dump(&udta->navg); } int quicktime_read_udta_string(quicktime_t *file, char **string, int *size, int ilst) { quicktime_atom_t leaf_atom; int result; uint32_t tmp; lqt_charset_converter_t * cnv = (lqt_charset_converter_t*)0; const char * charset; const char * charset_fallback; uint16_t language; if(*size) free(*string); if(!ilst) { *size = quicktime_read_int16(file); /* Size of string */ language = quicktime_read_int16(file); /* Language code */ *string = malloc(*size + 1); result = quicktime_read_data(file, (uint8_t*)(*string), *size); charset = lqt_get_charset(language, file->file_type); charset_fallback = lqt_get_charset_fallback(language, file->file_type); if(!charset && !charset_fallback) { lqt_log(file, LQT_LOG_WARNING, LOG_DOMAIN, "Unknown character set for language code %d, will copy the string verbatim", language); } else { if(charset) cnv = lqt_charset_converter_create(file, charset, "UTF-8"); if(!cnv && charset_fallback) cnv = lqt_charset_converter_create(file, charset_fallback, "UTF-8"); if(cnv) { lqt_charset_convert(cnv, string, *size, size); lqt_charset_converter_destroy(cnv); } } return !result; } else { quicktime_atom_read_header(file, &leaf_atom); if(!quicktime_atom_is(&leaf_atom, "data")) return 1; tmp = quicktime_read_int32(file); /* Version and flags */ if(!(tmp & 0x00000001)) /* Contains no text */ return 1; quicktime_read_int32(file); /* Reserved (0) */ *size = leaf_atom.end - quicktime_position(file); /* Size of string */ *string = malloc(*size + 1); result = quicktime_read_data(file, (uint8_t*)(*string), *size); (*string)[*size] = 0; return !result; } } int quicktime_read_udta(quicktime_t *file, quicktime_udta_t *udta, quicktime_atom_t *udta_atom) { quicktime_atom_t leaf_atom; int result = 0, tmp; int have_meta = 0, have_ilst = 0; while(udta_atom->end - quicktime_position(file) >= 8) { quicktime_atom_read_header(file, &leaf_atom); if(quicktime_atom_is(&leaf_atom, "meta")) { /* Skip version and flags (0) */ quicktime_read_int32(file); have_meta = 1; } else if(quicktime_atom_is(&leaf_atom, "ilst")) { have_ilst = 1; } else if(quicktime_atom_is(&leaf_atom, "hdlr")) { // quicktime_atom_skip(file, &leaf_atom); quicktime_read_hdlr(file, &udta->hdlr, &leaf_atom); udta->has_hdlr = 1; } else if(quicktime_atom_is(&leaf_atom, copyright_id)) { result += quicktime_read_udta_string(file, &udta->copyright, &udta->copyright_len, have_ilst); } else if(quicktime_atom_is(&leaf_atom, name_id)) { result += quicktime_read_udta_string(file, &udta->name, &udta->name_len, have_ilst); } else if(quicktime_atom_is(&leaf_atom, info_id)) { result += quicktime_read_udta_string(file, &udta->info, &udta->info_len, have_ilst); } else if(quicktime_atom_is(&leaf_atom, artist_id)) { result += quicktime_read_udta_string(file, &udta->artist, &udta->artist_len, have_ilst); } else if(quicktime_atom_is(&leaf_atom, album_id)) { result += quicktime_read_udta_string(file, &udta->album, &udta->album_len, have_ilst); } else if(quicktime_atom_is(&leaf_atom, genre_id)) { result += quicktime_read_udta_string(file, &udta->genre, &udta->genre_len, have_ilst); } else if(quicktime_atom_is(&leaf_atom, track_id)) { result += quicktime_read_udta_string(file, &udta->track, &udta->track_len, have_ilst); } else if(quicktime_atom_is(&leaf_atom, trkn_id)) { quicktime_atom_read_header(file, &leaf_atom); if(!quicktime_atom_is(&leaf_atom, "data")) return 1; quicktime_read_int32(file); /* Version and flags */ quicktime_read_int32(file); /* Reserved (0) */ quicktime_read_int16(file); /* Emtpy */ tmp = quicktime_read_int16(file); quicktime_read_int16(file); /* Total tracks */ quicktime_read_int16(file); /* Empty */ udta->track_len = 6; udta->track = malloc(6); /* strlen("65535") + 1 */ sprintf(udta->track, "%d", tmp); } else if(quicktime_atom_is(&leaf_atom, comment_id)) { result += quicktime_read_udta_string(file, &udta->comment, &udta->comment_len, have_ilst); } else if(quicktime_atom_is(&leaf_atom, author_id)) { result += quicktime_read_udta_string(file, &udta->author, &udta->author_len, have_ilst); } else if(quicktime_atom_is(&leaf_atom, "NAVG")) { result += quicktime_read_navg(file, &udta->navg, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "ctyp")) { udta->ctyp[0] = quicktime_read_char(file); udta->ctyp[1] = quicktime_read_char(file); udta->ctyp[2] = quicktime_read_char(file); udta->ctyp[3] = quicktime_read_char(file); if (quicktime_match_32(udta->ctyp, "stna") || quicktime_match_32(udta->ctyp, "qtvr") || quicktime_match_32(udta->ctyp, "STpn")) udta->is_qtvr = 1; } else quicktime_atom_skip(file, &leaf_atom); } quicktime_atom_skip(file, udta_atom); return result; } int quicktime_write_udta_string(quicktime_t *file, const char * str, int ilst, lqt_charset_converter_t ** cnv) { quicktime_atom_t data_atom; int new_size; int result = 0; if(!ilst) { char * string; if(!(*cnv)) { /* Hard wired charsets for Western European languages (probably not good) */ *cnv = lqt_charset_converter_create(file, "UTF-8", "MACINTOSH"); if(!(*cnv)) *cnv = lqt_charset_converter_create(file, "UTF-8", "ISO-8859-1"); } string = strdup(str); lqt_charset_convert(*cnv, &string, -1, &new_size); quicktime_write_int16(file, new_size); /* String size */ quicktime_write_int16(file, 0); /* Language code (defaults to english, probably not good) */ result = quicktime_write_data(file, (uint8_t*)(string), new_size); free(string); } else { quicktime_atom_write_header(file, &data_atom, "data"); quicktime_write_int32(file, 0x0000001); /* Version (0x00), flags 0x000001 (text) */ quicktime_write_int32(file, 0); /* Reserved */ result = quicktime_write_data(file, (const uint8_t*)(str), strlen(str)); quicktime_atom_write_footer(file, &data_atom); } return !result; } void quicktime_write_udta(quicktime_t *file, quicktime_udta_t *udta) { quicktime_atom_t atom, subatom, meta_atom, ilst_atom, data_atom; int tmp; int have_ilst = !!(file->file_type & ILST_TYPES); lqt_charset_converter_t * cnv = (lqt_charset_converter_t*)0; quicktime_atom_write_header(file, &atom, "udta"); if(have_ilst) { quicktime_atom_write_header(file, &meta_atom, "meta"); quicktime_write_int32(file, 0); /* Version and flags (probably 0) */ quicktime_write_hdlr(file, &udta->hdlr); quicktime_atom_write_header(file, &ilst_atom, "ilst"); } if(udta->copyright_len) { quicktime_atom_write_header(file, &subatom, copyright_id); quicktime_write_udta_string(file, udta->copyright, have_ilst, &cnv); quicktime_atom_write_footer(file, &subatom); } if(udta->name_len) { quicktime_atom_write_header(file, &subatom, name_id); quicktime_write_udta_string(file, udta->name, have_ilst, &cnv); quicktime_atom_write_footer(file, &subatom); } if(udta->info_len) { quicktime_atom_write_header(file, &subatom, info_id); quicktime_write_udta_string(file, udta->info, have_ilst, &cnv); quicktime_atom_write_footer(file, &subatom); } if(udta->artist_len) { quicktime_atom_write_header(file, &subatom, artist_id); quicktime_write_udta_string(file, udta->artist, have_ilst, &cnv); quicktime_atom_write_footer(file, &subatom); } if(udta->album_len) { quicktime_atom_write_header(file, &subatom, album_id); quicktime_write_udta_string(file, udta->album, have_ilst, &cnv); quicktime_atom_write_footer(file, &subatom); } if(udta->genre_len) { quicktime_atom_write_header(file, &subatom, genre_id); quicktime_write_udta_string(file, udta->genre, have_ilst, &cnv); quicktime_atom_write_footer(file, &subatom); } if(udta->track_len) { if(have_ilst) { tmp = atoi(udta->track); quicktime_atom_write_header(file, &subatom, trkn_id); quicktime_atom_write_header(file, &data_atom, "data"); quicktime_write_int32(file, 0); /* Version and flags */ quicktime_write_int32(file, 0); /* Reserved (0) */ quicktime_write_int16(file, 0); /* Emtpy */ quicktime_write_int16(file, tmp); quicktime_write_int16(file, 0); /* Total tracks */ quicktime_write_int16(file, 0); /* Empty */ quicktime_atom_write_footer(file, &data_atom); quicktime_atom_write_footer(file, &subatom); } else { quicktime_atom_write_header(file, &subatom, track_id); quicktime_write_udta_string(file, udta->track, have_ilst, &cnv); quicktime_atom_write_footer(file, &subatom); } } if(udta->comment_len) { quicktime_atom_write_header(file, &subatom, comment_id); quicktime_write_udta_string(file, udta->comment, have_ilst, &cnv); quicktime_atom_write_footer(file, &subatom); } if(udta->author_len) { quicktime_atom_write_header(file, &subatom, author_id); quicktime_write_udta_string(file, udta->author, have_ilst, &cnv); quicktime_atom_write_footer(file, &subatom); } if(udta->is_qtvr) { if (quicktime_match_32(udta->ctyp, "stna")) quicktime_write_navg(file, &udta->navg); quicktime_atom_write_header(file, &subatom, "ctyp"); quicktime_write_char(file, udta->ctyp[0]); quicktime_write_char(file, udta->ctyp[1]); quicktime_write_char(file, udta->ctyp[2]); quicktime_write_char(file, udta->ctyp[3]); quicktime_atom_write_footer(file, &subatom); } if(have_ilst) { quicktime_atom_write_footer(file, &ilst_atom); quicktime_atom_write_footer(file, &meta_atom); } quicktime_atom_write_footer(file, &atom); if(cnv) lqt_charset_converter_destroy(cnv); } int quicktime_set_udta_string(char **string, int *size, char *new_string) { if(*size) free(*string); *size = strlen(new_string); *string = malloc(*size + 1); strcpy(*string, new_string); return 0; } libquicktime-1.2.4/src/mdhd.c0000644000175000017500000001007111511622756012775 00000000000000/******************************************************************************* mdhd.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #define MP4_DEFAULT_LANGUAGE 5575 // English void quicktime_mdhd_init(quicktime_mdhd_t *mdhd) { mdhd->version = 0; mdhd->flags = 0; mdhd->creation_time = quicktime_current_time(); mdhd->modification_time = quicktime_current_time(); mdhd->time_scale = 0; mdhd->duration = 0; mdhd->language = 0; mdhd->quality = 100; } void quicktime_mdhd_init_video(quicktime_t *file, quicktime_mdhd_t *mdhd, int timescale) { if(IS_MP4(file->file_type)) { mdhd->language = MP4_DEFAULT_LANGUAGE; mdhd->quality = 0; } mdhd->time_scale = timescale; mdhd->duration = 0; /* set this when closing */ } void quicktime_mdhd_init_audio(quicktime_t *file, quicktime_mdhd_t *mdhd, int sample_rate) { if(IS_MP4(file->file_type)) { mdhd->language = MP4_DEFAULT_LANGUAGE; mdhd->quality = 0; } mdhd->time_scale = sample_rate; mdhd->duration = 0; /* set this when closing */ } void quicktime_mdhd_init_text(quicktime_t *file, quicktime_mdhd_t *mdhd, int timescale) { if(IS_MP4(file->file_type)) { mdhd->language = MP4_DEFAULT_LANGUAGE; mdhd->quality = 0; } mdhd->time_scale = timescale; mdhd->duration = 0; /* set this when closing */ } void quicktime_mdhd_delete(quicktime_mdhd_t *mdhd) { } void quicktime_read_mdhd(quicktime_t *file, quicktime_mdhd_t *mdhd) { mdhd->version = quicktime_read_char(file); mdhd->flags = quicktime_read_int24(file); mdhd->creation_time = quicktime_read_int32(file); mdhd->modification_time = quicktime_read_int32(file); mdhd->time_scale = quicktime_read_int32(file); mdhd->duration = quicktime_read_int32(file); mdhd->language = quicktime_read_int16(file); mdhd->quality = quicktime_read_int16(file); } void quicktime_mdhd_dump(quicktime_mdhd_t *mdhd) { lqt_dump(" media header (mdhd)\n"); lqt_dump(" version %d\n", mdhd->version); lqt_dump(" flags %ld\n", mdhd->flags); lqt_dump(" creation_time "); lqt_dump_time(mdhd->creation_time); lqt_dump("\n"); lqt_dump(" modification_time "); lqt_dump_time(mdhd->modification_time); lqt_dump("\n"); lqt_dump(" time_scale %ld\n", mdhd->time_scale); lqt_dump(" duration %ld\n", mdhd->duration); lqt_dump(" language %d\n", mdhd->language); lqt_dump(" quality %d\n", mdhd->quality); } void quicktime_write_mdhd(quicktime_t *file, quicktime_mdhd_t *mdhd) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "mdhd"); quicktime_write_char(file, mdhd->version); quicktime_write_int24(file, mdhd->flags); quicktime_write_int32(file, mdhd->creation_time); quicktime_write_int32(file, mdhd->modification_time); quicktime_write_int32(file, mdhd->time_scale); quicktime_write_int32(file, mdhd->duration); quicktime_write_int16(file, mdhd->language); quicktime_write_int16(file, mdhd->quality); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/tkhd.c0000644000175000017500000001326311511622757013022 00000000000000/******************************************************************************* tkhd.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" int quicktime_tkhd_init(quicktime_tkhd_t *tkhd, lqt_file_type_t type) { int i; tkhd->version = 0; if(IS_MP4(type)) tkhd->flags = 7; else tkhd->flags = 15; tkhd->creation_time = quicktime_current_time(); tkhd->modification_time = quicktime_current_time(); tkhd->track_id = 0; tkhd->reserved1 = 0; tkhd->duration = 0; /* need to set this when closing */ for(i = 0; i < 8; i++) tkhd->reserved2[i] = 0; tkhd->layer = 0; tkhd->alternate_group = 0; tkhd->volume = 1.0; tkhd->reserved3 = 0; quicktime_matrix_init(&tkhd->matrix); tkhd->track_width = 0; tkhd->track_height = 0; return 0; } int quicktime_tkhd_delete(quicktime_tkhd_t *tkhd) { return 0; } void quicktime_tkhd_dump(quicktime_tkhd_t *tkhd) { lqt_dump(" track header (tkhd)\n"); lqt_dump(" version %d\n", tkhd->version); lqt_dump(" flags %ld\n", tkhd->flags); lqt_dump(" creation_time "); lqt_dump_time(tkhd->creation_time); lqt_dump("\n"); lqt_dump(" modification_time "); lqt_dump_time(tkhd->modification_time); lqt_dump("\n"); lqt_dump(" track_id %d\n", tkhd->track_id); lqt_dump(" reserved1 %ld\n", tkhd->reserved1); lqt_dump(" duration %"PRId64"\n", tkhd->duration); quicktime_print_chars(" reserved2 ", tkhd->reserved2, 8); lqt_dump(" layer %d\n", tkhd->layer); lqt_dump(" alternate_group %d\n", tkhd->alternate_group); lqt_dump(" volume %f\n", tkhd->volume); lqt_dump(" reserved3 %ld\n", tkhd->reserved3); quicktime_matrix_dump(&tkhd->matrix); lqt_dump(" track_width %f\n", tkhd->track_width); lqt_dump(" track_height %f\n", tkhd->track_height); } void quicktime_read_tkhd(quicktime_t *file, quicktime_tkhd_t *tkhd) { tkhd->version = quicktime_read_char(file); tkhd->flags = quicktime_read_int24(file); if(tkhd->version == 0) { tkhd->creation_time = quicktime_read_int32(file); tkhd->modification_time = quicktime_read_int32(file); } else if(tkhd->version == 1) { tkhd->creation_time = quicktime_read_int64(file); tkhd->modification_time = quicktime_read_int64(file); } tkhd->track_id = quicktime_read_int32(file); tkhd->reserved1 = quicktime_read_int32(file); if(tkhd->version == 0) tkhd->duration = quicktime_read_int32(file); else if(tkhd->version == 1) tkhd->duration = quicktime_read_int64(file); quicktime_read_data(file, tkhd->reserved2, 8); tkhd->layer = quicktime_read_int16(file); tkhd->alternate_group = quicktime_read_int16(file); tkhd->volume = quicktime_read_fixed16(file); tkhd->reserved3 = quicktime_read_int16(file); quicktime_read_matrix(file, &tkhd->matrix); tkhd->track_width = quicktime_read_fixed32(file); tkhd->track_height = quicktime_read_fixed32(file); } void quicktime_write_tkhd(quicktime_t *file, quicktime_tkhd_t *tkhd) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "tkhd"); quicktime_write_char(file, tkhd->version); quicktime_write_int24(file, tkhd->flags); if(tkhd->version == 0) { quicktime_write_int32(file, tkhd->creation_time); quicktime_write_int32(file, tkhd->modification_time); } else if(tkhd->version == 1) { quicktime_write_int64(file, tkhd->creation_time); quicktime_write_int64(file, tkhd->modification_time); } quicktime_write_int32(file, tkhd->track_id); quicktime_write_int32(file, tkhd->reserved1); if(tkhd->version == 0) quicktime_write_int32(file, tkhd->duration); else if(tkhd->version == 1) quicktime_write_int64(file, tkhd->duration); quicktime_write_data(file, tkhd->reserved2, 8); quicktime_write_int16(file, tkhd->layer); quicktime_write_int16(file, tkhd->alternate_group); quicktime_write_fixed16(file, tkhd->volume); quicktime_write_int16(file, tkhd->reserved3); quicktime_write_matrix(file, &tkhd->matrix); quicktime_write_fixed32(file, tkhd->track_width); quicktime_write_fixed32(file, tkhd->track_height); quicktime_atom_write_footer(file, &atom); } void quicktime_tkhd_init_video(quicktime_t *file, quicktime_tkhd_t *tkhd, int frame_w, int frame_h) { tkhd->track_width = frame_w; tkhd->track_height = frame_h; tkhd->volume = 0; } void quicktime_tkhd_init_timecode(quicktime_t *file, quicktime_tkhd_t *tkhd, int frame_w, int frame_h) { tkhd->track_width = frame_w; tkhd->track_height = 20; tkhd->matrix.values[7] = frame_h; tkhd->volume = 0; } libquicktime-1.2.4/src/avi_indx.c0000644000175000017500000001536011511622756013670 00000000000000/******************************************************************************* avi_indx.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include void quicktime_delete_indx(quicktime_indx_t *indx) { int i; if(indx->table) { for(i = 0; i < indx->table_size; i++) { quicktime_indxtable_t *indx_table = &indx->table[i]; if(indx_table->ix) quicktime_delete_ix(indx_table->ix); } free(indx->table); } } void quicktime_init_indx(quicktime_t *file, quicktime_indx_t *indx, quicktime_strl_t *strl) { indx->longs_per_entry = 4; indx->index_subtype = 0; indx->index_type = AVI_INDEX_OF_INDEXES; memcpy(indx->chunk_id, strl->tag, 4); } void quicktime_indx_init_riff(quicktime_t *file, quicktime_trak_t * trak) { quicktime_strl_t * strl; quicktime_indx_t * indx; quicktime_indxtable_t *indx_table; strl = trak->strl; indx = &strl->indx; if(indx->table_size >= indx->table_allocation) { int new_allocation = indx->table_allocation * 2; if(new_allocation < 1) new_allocation = 1; indx->table = realloc(indx->table, new_allocation * sizeof(quicktime_indxtable_t)); memset(indx->table + indx->table_size, 0, new_allocation - indx->table_size); indx->table_allocation = new_allocation; } /* Append */ indx_table = &indx->table[indx->table_size++]; indx_table->ix = quicktime_new_ix(file, trak, strl); } void quicktime_indx_finalize_riff(quicktime_t *file, quicktime_trak_t * trak) { quicktime_strl_t * strl; quicktime_indx_t * indx; quicktime_indxtable_t *indx_table; strl = trak->strl; indx = &strl->indx; indx_table = &indx->table[indx->table_size-1]; quicktime_write_ix(file, trak); indx_table->index_offset = indx_table->ix->atom.start - 8; indx_table->index_size = indx_table->ix->atom.size; indx_table->duration = indx_table->ix->table_size; } void quicktime_finalize_indx(quicktime_t *file, quicktime_indx_t * indx) { int j; quicktime_atom_t junk_atom; quicktime_set_position(file, indx->offset); /* Write indx */ // quicktime_set_position(file, strl->indx_offset); quicktime_atom_write_header(file, &indx->atom, "indx"); /* longs per entry */ quicktime_write_int16_le(file, indx->longs_per_entry); /* index sub type */ quicktime_write_char(file, indx->index_subtype); /* index type */ quicktime_write_char(file, indx->index_type); /* entries in use */ quicktime_write_int32_le(file, indx->table_size); /* chunk ID */ quicktime_write_char32(file, indx->chunk_id); /* reserved */ quicktime_write_int32_le(file, 0); quicktime_write_int32_le(file, 0); quicktime_write_int32_le(file, 0); /* table */ for(j = 0; j < indx->table_size; j++) { quicktime_indxtable_t *indx_table = &indx->table[j]; quicktime_write_int64_le(file, indx_table->index_offset); quicktime_write_int32_le(file, indx_table->index_size); quicktime_write_int32_le(file, indx_table->duration); } quicktime_atom_write_footer(file, &indx->atom); quicktime_atom_write_header(file, &junk_atom, "JUNK"); while(quicktime_position(file) < indx->offset + indx->size) quicktime_write_char(file, 0); quicktime_atom_write_footer(file, &junk_atom); } void quicktime_read_indx(quicktime_t *file, quicktime_strl_t *strl, quicktime_atom_t *parent_atom) { quicktime_indx_t *indx = &strl->indx; quicktime_indxtable_t *indx_table; quicktime_ix_t *ix; int i; int64_t offset; file->file_type = LQT_FILE_AVI_ODML; indx->longs_per_entry = quicktime_read_int16_le(file); indx->index_subtype = quicktime_read_char(file); indx->index_type = quicktime_read_char(file); indx->table_size = quicktime_read_int32_le(file); quicktime_read_char32(file, indx->chunk_id); quicktime_read_int32_le(file); quicktime_read_int32_le(file); quicktime_read_int32_le(file); /* Read indx entries */ indx->table = calloc(indx->table_size, sizeof(quicktime_indxtable_t)); for(i = 0; i < indx->table_size; i++) { indx_table = &indx->table[i]; indx_table->index_offset = quicktime_read_int64_le(file); indx_table->index_size = quicktime_read_int32_le(file); indx_table->duration = quicktime_read_int32_le(file); offset = quicktime_position(file); /* Now read the partial index */ ix = indx_table->ix = calloc(1, sizeof(quicktime_ix_t)); quicktime_set_position(file, indx_table->index_offset); quicktime_read_ix(file, ix); quicktime_set_position(file, offset); } } void quicktime_set_indx_keyframe(quicktime_t *file, quicktime_trak_t *trak, long new_keyframe) { long frame_count; int i; quicktime_indx_t *indx = &trak->strl->indx; /* Get the right ix table */ frame_count = 0; i = 0; while(frame_count + indx->table[i].ix->table_size < new_keyframe) { frame_count+= indx->table[i].ix->table_size; i++; } indx->table[i].ix->table[new_keyframe - frame_count].size &= 0x7fffffff; } void quicktime_indx_dump(quicktime_indx_t *indx) { int i; lqt_dump(" indx"); lqt_dump(" longs_per_entry: %d\n", indx->longs_per_entry); lqt_dump(" index_subtype: %d\n", indx->index_subtype); lqt_dump(" index_type: %d\n", indx->index_type); lqt_dump(" chunk_id: %s\n", indx->chunk_id); lqt_dump(" table_size: %d\n", indx->table_size); for(i = 0; i < indx->table_size; i++) { lqt_dump(" index_offset: %"PRId64"\n", indx->table[i].index_offset); lqt_dump(" index_size: %d\n", indx->table[i].index_size); lqt_dump(" duration: %d\n", indx->table[i].duration); quicktime_ix_dump(indx->table[i].ix); } } libquicktime-1.2.4/src/avi_odml.c0000644000175000017500000000414011511622756013653 00000000000000/******************************************************************************* avi_odml.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #if 0 void quicktime_read_odml(quicktime_t *file, quicktime_atom_t *parent_atom) { } #endif void quicktime_init_odml(quicktime_t *file, quicktime_hdrl_t *hdrl) { quicktime_atom_t list_atom, dmlh_atom; // LIST 'odml' quicktime_atom_write_header(file, &list_atom, "LIST"); quicktime_write_char32(file, "odml"); // 'dmlh' quicktime_atom_write_header(file, &dmlh_atom, "dmlh"); // Placeholder for total frames in all RIFF objects hdrl->total_frames_offset = quicktime_position(file); quicktime_write_int32_le(file, 0); quicktime_atom_write_footer(file, &dmlh_atom); quicktime_atom_write_footer(file, &list_atom); } void quicktime_finalize_odml(quicktime_t *file, quicktime_hdrl_t *hdrl) { // Get length in frames if(file->total_vtracks) { quicktime_set_position(file, hdrl->total_frames_offset); quicktime_write_int32_le(file, quicktime_track_samples(file, file->vtracks[0].track)); } } #if 0 void quicktime_dump_odml(quicktime_t *file, quicktime_hdrl_t *hdrl) { } #endif libquicktime-1.2.4/src/lqt_quicktime.c0000644000175000017500000024406011722235260014735 00000000000000/******************************************************************************* lqt_quicktime.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include "lqt_fseek.h" #include #include #include #include #include #include #define LQT_LIBQUICKTIME #include #define LOG_DOMAIN "core" static int64_t get_file_length(quicktime_t *file) { int64_t current_pos, total_bytes; current_pos = ftello(file->stream); fseeko(file->stream, 0, SEEK_END); total_bytes = ftello(file->stream); fseeko(file->stream, current_pos, SEEK_CUR); return total_bytes; } int lqt_fileno(quicktime_t *file) { FILE *fp; fp = file->stream; return(fileno(fp)); } int quicktime_make_streamable(char *in_path, char *out_path) { quicktime_t file, *old_file, new_file; int moov_exists = 0, mdat_exists = 0, ftyp_exists = 0, result, atoms = 1; int64_t mdat_start = 0, mdat_size = 0; quicktime_atom_t leaf_atom; int64_t moov_length = 0, moov_start; memset(&new_file,0,sizeof(new_file)); quicktime_init(&file); /* find the moov atom in the old file */ if(!(file.stream = fopen(in_path, "rb"))) { perror("quicktime_make_streamable"); return 1; } file.total_length = get_file_length(&file); /* get the locations of moov and mdat atoms */ do { result = quicktime_atom_read_header(&file, &leaf_atom); if(!result) { if(quicktime_atom_is(&leaf_atom, "moov")) { moov_exists = atoms; moov_length = leaf_atom.size; } else if(quicktime_atom_is(&leaf_atom, "ftyp")) { ftyp_exists = atoms; } else if(quicktime_atom_is(&leaf_atom, "mdat")) { mdat_start = quicktime_position(&file) - HEADER_LENGTH; mdat_size = leaf_atom.size; mdat_exists = atoms; } quicktime_atom_skip(&file, &leaf_atom); atoms++; } }while(!result && quicktime_position(&file) < file.total_length); fclose(file.stream); if(!moov_exists) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "quicktime_make_streamable: no moov atom"); return 1; } if(!mdat_exists) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "quicktime_make_streamable: no mdat atom"); return 1; } /* copy the old file to the new file */ if(moov_exists && mdat_exists) { /* moov comes after mdat */ if(moov_exists > mdat_exists) { uint8_t *buffer; int64_t buf_size = 1000000; result = 0; /* read the header proper */ if(!(old_file = quicktime_open(in_path, 1, 0))) { return 1; } quicktime_shift_offsets(&old_file->moov, moov_length+8); /* open the output file */ if(!(new_file.stream = fopen(out_path, "wb"))) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "quicktime_make_streamable: cannot open output file: %s", strerror(errno)); result = 1; } else { /* set up some flags */ new_file.wr = 1; new_file.rd = 0; new_file.presave_buffer = calloc(1, QUICKTIME_PRESAVE); new_file.file_type = old_file->file_type; if(old_file->has_ftyp) quicktime_write_ftyp(&new_file, &old_file->ftyp); moov_start = quicktime_position(&new_file); quicktime_write_moov(&new_file, &old_file->moov); if(moov_length != quicktime_position(&new_file) - moov_start) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "quicktime_make_streamable: moov size changed from %"PRId64" to %"PRId64" (Pos: %"PRId64", start: %"PRId64")", moov_length, quicktime_position(&new_file) - moov_start, quicktime_position(&new_file), moov_start); quicktime_set_position(&new_file, moov_start + moov_length); } quicktime_atom_write_header64(&new_file, &new_file.mdat.atom, "mdat"); quicktime_set_position(old_file, mdat_start); if(!(buffer = calloc(1, buf_size))) { result = 1; printf("quicktime_make_streamable: out of memory\n"); } else { while(quicktime_position(old_file) < mdat_start + mdat_size && !result) { if(quicktime_position(old_file) + buf_size > mdat_start + mdat_size) buf_size = mdat_start + mdat_size - quicktime_position(old_file); if(!quicktime_read_data(old_file, buffer, buf_size)) result = 1; if(!result) { if(!quicktime_write_data(&new_file, buffer, buf_size)) result = 1; } } free(buffer); } quicktime_atom_write_footer(&new_file, &new_file.mdat.atom); if(new_file.presave_size) { quicktime_fseek(&new_file, new_file.presave_position - new_file.presave_size); fwrite(new_file.presave_buffer, 1, new_file.presave_size, new_file.stream); new_file.presave_size = 0; } free(new_file.presave_buffer); fclose(new_file.stream); } quicktime_close(old_file); } else { printf("quicktime_make_streamable: header already at 0 offset\n"); return 0; } } return 0; } void lqt_set_audio_parameter(quicktime_t *file,int stream, const char *key, const void *value) { quicktime_codec_t *codec = file->atracks[stream].codec; if(codec->set_parameter) codec->set_parameter(file, stream, key, value); } void lqt_set_video_parameter(quicktime_t *file,int stream, const char *key, const void *value) { quicktime_codec_t *codec = file->vtracks[stream].codec; if(codec->set_parameter) codec->set_parameter(file, stream, key, value); } void quicktime_set_parameter(quicktime_t *file, char *key, void *value) { int i; for(i = 0; i < file->total_vtracks; i++) { lqt_set_video_parameter(file,i, key,value); } for(i = 0; i < file->total_atracks; i++) { lqt_set_audio_parameter(file,i, key,value); } } void quicktime_set_jpeg(quicktime_t *file, int quality, int use_float) { quicktime_set_parameter( file, "jpeg_quality", &quality ); quicktime_set_parameter( file, "jpeg_usefloat", &use_float ); } void quicktime_set_copyright(quicktime_t *file, char *string) { quicktime_set_udta_string(&file->moov.udta.copyright, &file->moov.udta.copyright_len, string); } void quicktime_set_name(quicktime_t *file, char *string) { quicktime_set_udta_string(&file->moov.udta.name, &file->moov.udta.name_len, string); } void quicktime_set_info(quicktime_t *file, char *string) { quicktime_set_udta_string(&file->moov.udta.info, &file->moov.udta.info_len, string); } char* quicktime_get_copyright(quicktime_t *file) { return file->moov.udta.copyright; } char* quicktime_get_name(quicktime_t *file) { return file->moov.udta.name; } char* quicktime_get_info(quicktime_t *file) { return file->moov.udta.info; } /* Extended metadata support */ void lqt_set_album(quicktime_t *file, char *string) { quicktime_set_udta_string(&file->moov.udta.album, &file->moov.udta.album_len, string); } void lqt_set_artist(quicktime_t *file, char *string) { quicktime_set_udta_string(&file->moov.udta.artist, &file->moov.udta.artist_len, string); } void lqt_set_genre(quicktime_t *file, char *string) { quicktime_set_udta_string(&file->moov.udta.genre, &file->moov.udta.genre_len, string); } void lqt_set_track(quicktime_t *file, char *string) { quicktime_set_udta_string(&file->moov.udta.track, &file->moov.udta.track_len, string); } void lqt_set_comment(quicktime_t *file, char *string) { quicktime_set_udta_string(&file->moov.udta.comment, &file->moov.udta.comment_len, string); } void lqt_set_author(quicktime_t *file, char *string) { quicktime_set_udta_string(&file->moov.udta.author, &file->moov.udta.author_len, string); } void lqt_set_creation_time(quicktime_t *file, unsigned long time) { file->moov.mvhd.creation_time = time; } char * lqt_get_album(quicktime_t * file) { return file->moov.udta.album; } char * lqt_get_artist(quicktime_t * file) { return file->moov.udta.artist; } char * lqt_get_genre(quicktime_t * file) { return file->moov.udta.genre; } char * lqt_get_track(quicktime_t * file) { return file->moov.udta.track; } char * lqt_get_comment(quicktime_t *file) { return file->moov.udta.comment; } char * lqt_get_author(quicktime_t *file) { return file->moov.udta.author; } unsigned long lqt_get_creation_time(quicktime_t * file) { return file->moov.mvhd.creation_time; } int quicktime_video_tracks(quicktime_t *file) { int i, result = 0; for(i = 0; i < file->moov.total_tracks; i++) { if(file->moov.trak[i]->mdia.minf.is_video) result++; } return result; } int quicktime_audio_tracks(quicktime_t *file) { int i, result = 0; quicktime_minf_t *minf; for(i = 0; i < file->moov.total_tracks; i++) { minf = &file->moov.trak[i]->mdia.minf; if(minf->is_audio) result++; } return result; } int lqt_set_audio_codec(quicktime_t *file, int track, lqt_codec_info_t * info) { quicktime_stsd_t * stsd; stsd = &file->atracks[track].track->mdia.minf.stbl.stsd; quicktime_stsd_set_audio_codec(stsd, info->fourccs[0]); quicktime_init_audio_map(file, &file->atracks[track], file->wr, info); lqt_set_default_audio_parameters(file, track); return 0; } int lqt_add_audio_track_internal(quicktime_t *file, int channels, long sample_rate, int bits, lqt_codec_info_t * codec_info, const lqt_compression_info_t * ci) { quicktime_trak_t *trak; char * compressor = codec_info ? codec_info->fourccs[0] : NULL; file->atracks = realloc(file->atracks, (file->total_atracks+1)*sizeof(*file->atracks)); memset(&file->atracks[file->total_atracks], 0, sizeof(*file->atracks)); if(ci) lqt_compression_info_copy(&file->atracks[file->total_atracks].ci, ci); trak = quicktime_add_track(file); quicktime_trak_init_audio(file, trak, channels, sample_rate, bits, compressor); file->atracks[file->total_atracks].track = trak; file->total_atracks++; if(codec_info) return lqt_set_audio_codec(file, file->total_atracks-1, codec_info); return 0; } int lqt_add_audio_track(quicktime_t *file, int channels, long sample_rate, int bits, lqt_codec_info_t * codec_info) { return lqt_add_audio_track_internal(file, channels, sample_rate, bits, codec_info, NULL); } int lqt_set_audio(quicktime_t *file, int channels, long sample_rate, int bits, lqt_codec_info_t * codec_info) { lqt_add_audio_track(file, channels, sample_rate, bits, codec_info); return 0; } int quicktime_set_audio(quicktime_t *file, int channels, long sample_rate, int bits, char *compressor) { lqt_codec_info_t ** info; info = lqt_find_audio_codec(compressor, 1); lqt_set_audio(file, channels, sample_rate, bits, *info); lqt_destroy_codec_info(info); return 1; /* Return the number of tracks created */ } int lqt_set_video(quicktime_t *file, int tracks, int frame_w, int frame_h, int frame_duration, int timescale, lqt_codec_info_t * info) { int i; for(i = 0; i < tracks; i++) { if(lqt_add_video_track(file, frame_w, frame_h, frame_duration, timescale, info)) return 1; } return 0; } int quicktime_set_video(quicktime_t *file, int tracks, int frame_w, int frame_h, double frame_rate, char *compressor) { lqt_codec_info_t ** info; int timescale, frame_duration; timescale = quicktime_get_timescale(frame_rate); frame_duration = (int)((double)(timescale)/frame_rate+0.5); info = lqt_find_video_codec(compressor, 1); lqt_set_video(file, tracks, frame_w, frame_h, frame_duration, timescale, *info); lqt_destroy_codec_info(info); return 0; } static int check_image_size(lqt_codec_info_t * info, int frame_w, int frame_h) { int i; if(info->num_image_sizes) { for(i = 0; i < info->num_image_sizes; i++) { if((frame_w == info->image_sizes[i].width) && (frame_h == info->image_sizes[i].height)) return 1; } return 0; } else return 1; } int lqt_set_video_codec(quicktime_t *file, int track, lqt_codec_info_t * info) { quicktime_stsd_t *stsd; if(!check_image_size(info, quicktime_video_width(file, track), quicktime_video_height(file, track))) return 1; stsd = &file->vtracks[track].track->mdia.minf.stbl.stsd; quicktime_stsd_set_video_codec(stsd, info->fourccs[0]); quicktime_init_video_map(&file->vtracks[track], file->wr, info); lqt_set_default_video_parameters(file, track); /* Get encoding colormodel */ file->vtracks[file->total_vtracks-1].codec->encode_video(file, (uint8_t**)0, track); file->vtracks[track].io_cmodel = file->vtracks[track].stream_cmodel; return 0; } int lqt_add_video_track_internal(quicktime_t *file, int frame_w, int frame_h, int frame_duration, int timescale, lqt_codec_info_t * info, const lqt_compression_info_t * ci) { char * compressor = info ? info->fourccs[0] : NULL; quicktime_trak_t *trak; /* Check if the image size is supported */ if(info && !check_image_size(info, frame_w, frame_h)) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "Adding video track failed, unsupported image size"); return 1; } if(!file->total_vtracks) quicktime_mhvd_init_video(file, &file->moov.mvhd, timescale); file->vtracks = realloc(file->vtracks, (file->total_vtracks+1) * sizeof(*file->vtracks)); memset(&file->vtracks[file->total_vtracks], 0, sizeof(*file->vtracks)); if(ci) { lqt_compression_info_copy(&file->vtracks[file->total_vtracks].ci, ci); file->vtracks[file->total_vtracks].stream_cmodel = ci->colormodel; } trak = quicktime_add_track(file); file->vtracks[file->total_vtracks].track = trak; file->total_vtracks++; quicktime_trak_init_video(file, trak, frame_w, frame_h, frame_duration, timescale, compressor); if(info) return lqt_set_video_codec(file, file->total_vtracks-1, info); return 0; } int lqt_add_video_track(quicktime_t *file, int frame_w, int frame_h, int frame_duration, int timescale, lqt_codec_info_t * info) { return lqt_add_video_track_internal(file, frame_w, frame_h, frame_duration, timescale, info, NULL); } void quicktime_set_framerate(quicktime_t *file, double framerate) { int i; int new_time_scale, new_sample_duration; if(!file->wr) { lqt_log(file, LQT_LOG_WARNING, LOG_DOMAIN, "quicktime_set_framerate shouldn't be called in read mode."); return; } new_time_scale = quicktime_get_timescale(framerate); new_sample_duration = (int)((float)new_time_scale / framerate + 0.5); for(i = 0; i < file->total_vtracks; i++) { file->vtracks[i].track->mdia.mdhd.time_scale = new_time_scale; file->vtracks[i].track->mdia.minf.stbl.stts.table[0].sample_duration = new_sample_duration; } } /* Used for writing only */ quicktime_trak_t* quicktime_add_track(quicktime_t *file) { quicktime_moov_t *moov = &file->moov; quicktime_trak_t *trak; // for(i = moov->total_tracks; i > 0; i--) // moov->trak[i] = moov->trak[i - 1]; trak = moov->trak[moov->total_tracks] = calloc(1, sizeof(quicktime_trak_t)); quicktime_trak_init(trak, file->file_type); moov->trak[moov->total_tracks]->tkhd.track_id = moov->mvhd.next_track_id; moov->total_tracks++; moov->mvhd.next_track_id++; return trak; } /* ============================= Initialization functions */ int quicktime_init(quicktime_t *file) { bzero(file, sizeof(quicktime_t)); // quicktime_atom_write_header64(new_file, &file->mdat.atom, "mdat"); quicktime_moov_init(&file->moov); file->max_riff_size = 0x40000000; // file->color_model = BC_RGB888; return 0; } static int quicktime_delete(quicktime_t *file) { int i; if(file->total_atracks) { for(i = 0; i < file->total_atracks; i++) quicktime_delete_audio_map(&file->atracks[i]); free(file->atracks); } if(file->total_vtracks) { for(i = 0; i < file->total_vtracks; i++) quicktime_delete_video_map(&file->vtracks[i]); free(file->vtracks); } if(file->total_ttracks) { for(i = 0; i < file->total_ttracks; i++) lqt_delete_text_map(file, &file->ttracks[i]); free(file->ttracks); } file->total_atracks = 0; file->total_vtracks = 0; if(file->moov_data) free(file->moov_data); if(file->preload_size) { free(file->preload_buffer); file->preload_size = 0; } if(file->presave_buffer) { free(file->presave_buffer); } for(i = 0; i < file->total_riffs; i++) { quicktime_delete_riff(file, file->riff[i]); } quicktime_moov_delete(&file->moov); quicktime_mdat_delete(&file->mdat); quicktime_ftyp_delete(&file->ftyp); return 0; } /* =============================== Optimization functions */ int quicktime_set_cpus(quicktime_t *file, int cpus) { return 0; } void quicktime_set_preload(quicktime_t *file, int64_t preload) { file->preload_size = preload; if(file->preload_buffer) free(file->preload_buffer); file->preload_buffer = 0; if(preload) file->preload_buffer = calloc(1, preload); file->preload_start = 0; file->preload_end = 0; file->preload_ptr = 0; } int quicktime_get_timescale(double frame_rate) { int timescale = 600; /* Encode the 29.97, 23.976, 59.94 framerates */ if(frame_rate - (int)frame_rate != 0) timescale = (int)(frame_rate * 1001 + 0.5); else if((600 / frame_rate) - (int)(600 / frame_rate) != 0) timescale = (int)(frame_rate * 100 + 0.5); return timescale; } int quicktime_seek_start(quicktime_t *file) { int i; for(i = 0; i < file->total_atracks; i++) quicktime_set_audio_position(file, 0, i); for(i = 0; i < file->total_vtracks; i++) quicktime_set_video_position(file, 0, i); return 0; } long quicktime_audio_length(quicktime_t *file, int track) { if(file->total_atracks > 0) return file->atracks[track].total_samples; return 0; } long quicktime_video_length(quicktime_t *file, int track) { /*printf("quicktime_video_length %d %d\n", quicktime_track_samples(file, file->vtracks[track].track), track); */ if(file->total_vtracks > 0) return quicktime_track_samples(file, file->vtracks[track].track); return 0; } long quicktime_audio_position(quicktime_t *file, int track) { return file->atracks[track].current_position; } long quicktime_video_position(quicktime_t *file, int track) { return file->vtracks[track].current_position; } int quicktime_set_audio_position(quicktime_t *file, int64_t sample, int track) { if((track >= 0) && (track < file->total_atracks)) { /* We just set the current position, Codec will do the rest */ file->atracks[track].current_position = sample; file->atracks[track].eof = 0; } else lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "quicktime_set_audio_position: track >= file->total_atracks\n"); return 0; } int quicktime_set_video_position(quicktime_t *file, int64_t frame, int track) { int64_t chunk_sample, chunk; quicktime_trak_t *trak; quicktime_codec_t * codec; if((track < 0) || (track >= file->total_vtracks)) return 0; trak = file->vtracks[track].track; if((frame < 0) || (frame >= quicktime_track_samples(file, trak))) return 0; file->vtracks[track].current_position = frame; quicktime_chunk_of_sample(&chunk_sample, &chunk, trak, frame); file->vtracks[track].cur_chunk = chunk; file->vtracks[track].timestamp = quicktime_sample_to_time(&trak->mdia.minf.stbl.stts, frame, &file->vtracks[track].stts_index, &file->vtracks[track].stts_count); /* Resync codec */ codec = file->vtracks[track].codec; if(codec && codec->resync) codec->resync(file, track); return 0; } void lqt_seek_video(quicktime_t * file, int track, int64_t time) { int64_t frame; quicktime_trak_t *trak; if((track < 0) || (track >= file->total_vtracks)) return; trak = file->vtracks[track].track; file->vtracks[track].timestamp = time; frame = quicktime_time_to_sample(&trak->mdia.minf.stbl.stts, &file->vtracks[track].timestamp, &file->vtracks[track].stts_index, &file->vtracks[track].stts_count); quicktime_set_video_position(file, frame, track); } #define FRAME_PADDING 128 int lqt_read_video_frame(quicktime_t * file, uint8_t ** buffer, int * buffer_alloc, int64_t frame, int64_t * time, int track) { int64_t offset, chunk_sample, chunk; int result; quicktime_trak_t *trak; int len; if((track >= file->total_vtracks) || (track < 0)) return 0; trak = file->vtracks[track].track; if((frame < 0) || (frame >= quicktime_track_samples(file, trak))) return 0; // file->vtracks[track].current_position = frame; quicktime_chunk_of_sample(&chunk_sample, &chunk, trak, frame); file->vtracks[track].cur_chunk = chunk; offset = quicktime_sample_to_offset(file, trak, frame); quicktime_set_position(file, offset); if(time) *time = quicktime_sample_to_time(&trak->mdia.minf.stbl.stts, frame, &file->vtracks[track].stts_index, &file->vtracks[track].stts_count); len = quicktime_frame_size(file, frame, track); if(len + FRAME_PADDING > *buffer_alloc) { *buffer_alloc = len + FRAME_PADDING + 1024; *buffer = realloc(*buffer, *buffer_alloc); } result = quicktime_read_data(file, *buffer, len); if(result < len) { return 0; } memset(*buffer + len, 0, FRAME_PADDING); return len; } #undef FRAME_PADDING int quicktime_has_audio(quicktime_t *file) { if(quicktime_audio_tracks(file)) return 1; return 0; } long quicktime_sample_rate(quicktime_t *file, int track) { if(file->total_atracks) return file->atracks[track].samplerate; return 0; } int quicktime_audio_bits(quicktime_t *file, int track) { if(file->total_atracks) return file->atracks[track].track->mdia.minf.stbl.stsd.table[0].sample_size; return 0; } char* quicktime_audio_compressor(quicktime_t *file, int track) { return file->atracks[track].track->mdia.minf.stbl.stsd.table[0].format; } int quicktime_track_channels(quicktime_t *file, int track) { if(track < file->total_atracks) return file->atracks[track].channels; return 0; } int quicktime_channel_location(quicktime_t *file, int *quicktime_track, int *quicktime_channel, int channel) { int current_channel = 0, current_track = 0; *quicktime_channel = 0; *quicktime_track = 0; for(current_channel = 0, current_track = 0; current_track < file->total_atracks; ) { if(channel >= current_channel) { *quicktime_channel = channel - current_channel; *quicktime_track = current_track; } current_channel += file->atracks[current_track].channels; current_track++; } return 0; } int quicktime_has_video(quicktime_t *file) { if(quicktime_video_tracks(file)) return 1; return 0; } int quicktime_video_width(quicktime_t *file, int track) { // if(file->total_vtracks) // return file->vtracks[track].track->tkhd.track_width; // return 0; if((track < 0) || (track >= file->total_vtracks)) return 0; return file->vtracks[track].track->mdia.minf.stbl.stsd.table->width; } int quicktime_video_height(quicktime_t *file, int track) { // if(file->total_vtracks) // return file->vtracks[track].track->tkhd.track_height; // return 0; if((track < 0) || (track >= file->total_vtracks)) return 0; return file->vtracks[track].track->mdia.minf.stbl.stsd.table->height; } int quicktime_video_depth(quicktime_t *file, int track) { if(file->total_vtracks) return file->vtracks[track].track->mdia.minf.stbl.stsd.table[0].depth; return 0; } long lqt_video_edit_list_total_entries(quicktime_t * file, int track) { if(track < 0 || track >= quicktime_video_tracks(file)) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "illegal track index"); return 0; } return file->vtracks[track].track->edts.elst.total_entries; } long lqt_video_edit_duration(quicktime_t * file, int track, int entry_index) { if(track < 0 || track >= quicktime_video_tracks(file)) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "illegal track index"); return 0; } if(entry_index < 0 || entry_index >= file->vtracks[track].track->edts.elst.total_entries) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "illegal edit list entry"); return 0; } // convert to media timescale return (long)((double)file->vtracks[track].track->edts.elst.table[entry_index].duration / file->moov.mvhd.time_scale * file->vtracks[track].track->mdia.mdhd.time_scale + 0.5); } long lqt_video_edit_time(quicktime_t * file, int track, int entry_index) { if(track < 0 || track >= quicktime_video_tracks(file)) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "illegal track index"); return 0; } if(entry_index < 0 || entry_index >= file->vtracks[track].track->edts.elst.total_entries) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "illegal edit list entry"); return 0; } return file->vtracks[track].track->edts.elst.table[entry_index].time; } float lqt_video_edit_rate(quicktime_t * file, int track, int entry_index) { if(track < 0 || track >= quicktime_video_tracks(file)) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "illegal track index"); return 0.0f; } if(entry_index < 0 || entry_index >= file->vtracks[track].track->edts.elst.total_entries) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "illegal edit list entry"); return 0.0f; } return file->vtracks[track].track->edts.elst.table[entry_index].rate; } void quicktime_set_cmodel(quicktime_t *file, int colormodel) { int i; for(i = 0; i < file->total_vtracks; i++) file->vtracks[i].io_cmodel = colormodel; } int lqt_get_cmodel(quicktime_t * file, int track) { if((track < file->total_vtracks) && (track >= 0)) return file->vtracks[track].io_cmodel; else return LQT_COLORMODEL_NONE; } void lqt_set_cmodel(quicktime_t *file, int track, int colormodel) { if((track < file->total_vtracks) && (track >= 0)) { file->vtracks[track].io_cmodel = colormodel; /* Maybe switch the encoding colormodel to better match the IO one. */ if(file->wr && !file->encoding_started) { lqt_codec_info_t * info = file->vtracks[track].codec->info; int encoding_cmodel = lqt_get_best_target_colormodel( colormodel, info->encoding_colormodels); if (encoding_cmodel != LQT_COLORMODEL_NONE) { file->vtracks[track].stream_cmodel = encoding_cmodel; } } } else lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "lqt_set_cmodel: No track No. %d", track); } void quicktime_set_row_span(quicktime_t *file, int row_span) { int i; for(i = 0; i < file->total_vtracks; i++) file->vtracks[i].io_row_span = row_span; } void lqt_set_row_span(quicktime_t *file, int track, int row_span) { file->vtracks[track].io_row_span = row_span; } void lqt_set_row_span_uv(quicktime_t *file, int track, int row_span_uv) { file->vtracks[track].io_row_span_uv = row_span_uv; } #if 0 static void quicktime_set_window(quicktime_t *file, int in_x, /* Location of input frame to take picture */ int in_y, int in_w, int in_h, int out_w, /* Dimensions of output frame */ int out_h) { if(in_x >= 0 && in_y >= 0 && in_w > 0 && in_h > 0 && out_w > 0 && out_h > 0) { file->in_x = in_x; file->in_y = in_y; file->in_w = in_w; file->in_h = in_h; file->out_w = out_w; file->out_h = out_h; } } #endif void quicktime_set_depth(quicktime_t *file, int depth, int track) { int i; for(i = 0; i < file->total_vtracks; i++) { file->vtracks[i].track->mdia.minf.stbl.stsd.table[0].depth = depth; } } double quicktime_frame_rate(quicktime_t *file, int track) { if(file->total_vtracks > track) { if(file->vtracks[track].track->mdia.minf.stbl.stts.table) return (float)file->vtracks[track].track->mdia.mdhd.time_scale / file->vtracks[track].track->mdia.minf.stbl.stts.table[0].sample_duration; else return (float)file->vtracks[track].track->mdia.mdhd.time_scale / file->vtracks[track].track->mdia.minf.stbl.stts.default_duration; } return 0; } int64_t lqt_get_frame_time(quicktime_t * file, int track, int frame) { int64_t dummy1; int64_t dummy2; return quicktime_sample_to_time(&file->vtracks[track].track->mdia.minf.stbl.stts, frame, &dummy1, &dummy2); } /* * Return the timestamp of the NEXT frame to be decoded. * Call this BEFORE one of the decoding functions. */ int64_t lqt_frame_time(quicktime_t * file, int track) { return file->vtracks[track].timestamp; } /* * Return the Duration of the entire track */ int64_t lqt_video_duration(quicktime_t * file, int track) { int64_t dummy1; int64_t dummy2; return quicktime_sample_to_time(&file->vtracks[track].track->mdia.minf.stbl.stts, -1, &dummy1, &dummy2); } /* * Get the timescale of the track. Divide the return values * of lqt_frame_duration and lqt_frame_time by the scale to * get the time in seconds. */ int lqt_video_time_scale(quicktime_t * file, int track) { if(file->total_vtracks <= track) return 0; return file->vtracks[track].track->mdia.mdhd.time_scale; } /* * Get the duration of the NEXT frame to be decoded. * If constant is not NULL it will be set to 1 if the * frame duration is constant throughout the whole track */ int lqt_frame_duration(quicktime_t * file, int track, int *constant) { if(file->total_vtracks <= track) return 0; if(constant) { if(file->vtracks[track].track->mdia.minf.stbl.stts.total_entries == 1) *constant = 1; else if((file->vtracks[track].track->mdia.minf.stbl.stts.total_entries == 2) && (file->vtracks[track].track->mdia.minf.stbl.stts.table[1].sample_count == 1)) *constant = 1; else *constant = 0; } return file->vtracks[track].track->mdia.minf.stbl.stts.table[file->vtracks[track].stts_index].sample_duration; } char* quicktime_video_compressor(quicktime_t *file, int track) { if ((track < 0) || (track >= file->total_vtracks)) return NULL; return file->vtracks[track].track->mdia.minf.stbl.stsd.table[0].format; } int quicktime_write_audio(quicktime_t *file, uint8_t *audio_buffer, long samples, int track) { int result; int64_t bytes; quicktime_audio_map_t *track_map = &file->atracks[track]; quicktime_trak_t *trak = track_map->track; /* write chunk for 1 track */ bytes = samples * quicktime_audio_bits(file, track) / 8 * file->atracks[track].channels; quicktime_write_chunk_header(file, trak); result = !quicktime_write_data(file, audio_buffer, bytes); trak->chunk_samples = samples; quicktime_write_chunk_footer(file, trak); /* file->atracks[track].current_position += samples; */ file->atracks[track].cur_chunk++; return result; } long lqt_audio_edit_list_total_entries(quicktime_t * file, int track) { if(track < 0 || track >= quicktime_audio_tracks(file)) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "illegal track index"); return 0; } return file->atracks[track].track->edts.elst.total_entries; } long lqt_audio_edit_duration(quicktime_t * file, int track, int entry_index) { if(track < 0 || track >= quicktime_audio_tracks(file)) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "illegal track index"); return 0; } if(entry_index < 0 || entry_index >= file->atracks[track].track->edts.elst.total_entries) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "illegal edit list entry"); return 0; } // convert to media timescale return (long)((double)file->atracks[track].track->edts.elst.table[entry_index].duration / file->moov.mvhd.time_scale * file->atracks[track].track->mdia.mdhd.time_scale + 0.5); } long lqt_audio_edit_time(quicktime_t * file, int track, int entry_index) { if(track < 0 || track >= quicktime_audio_tracks(file)) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "illegal track index"); return 0; } if(entry_index < 0 || entry_index >= file->atracks[track].track->edts.elst.total_entries) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "illegal edit list entry"); return 0; } return file->atracks[track].track->edts.elst.table[entry_index].time; } float lqt_audio_edit_rate(quicktime_t * file, int track, int entry_index) { if(track < 0 || track >= quicktime_audio_tracks(file)) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "illegal track index"); return 0.0f; } if(entry_index < 0 || entry_index >= file->atracks[track].track->edts.elst.total_entries) { lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "illegal edit list entry"); return 0.0f; } return file->atracks[track].track->edts.elst.table[entry_index].rate; } int quicktime_write_frame(quicktime_t *file, unsigned char *video_buffer, int64_t bytes, int track) { int result = 0; quicktime_video_map_t *vtrack = &file->vtracks[track]; lqt_video_append_timestamp(file, track, vtrack->timestamp, file->vtracks[track].track->mdia.minf.stbl.stts.default_duration); vtrack->timestamp += file->vtracks[track].track->mdia.minf.stbl.stts.default_duration; lqt_write_frame_header(file, track, file->vtracks[track].current_position, -1, 0 /* int keyframe */ ); result = !quicktime_write_data(file, video_buffer, bytes); lqt_write_frame_footer(file, track); if(file->vtracks[track].timecode_track) lqt_flush_timecode(file, track, file->vtracks[track].current_position* (int64_t)file->vtracks[track].track->mdia.minf.stbl.stts.default_duration, 0); file->vtracks[track].current_position++; return result; } long quicktime_frame_size(quicktime_t *file, long frame, int track) { long bytes = 0; quicktime_trak_t *trak = file->vtracks[track].track; if(trak->mdia.minf.stbl.stsz.sample_size) { bytes = trak->mdia.minf.stbl.stsz.sample_size; } else { long total_frames = quicktime_track_samples(file, trak); if(frame < 0) frame = 0; else if(frame > total_frames - 1) frame = total_frames - 1; bytes = trak->mdia.minf.stbl.stsz.table[frame].size; } return bytes; } int quicktime_read_frame_init(quicktime_t *file, int track) { int64_t offset; quicktime_trak_t *trak = file->vtracks[track].track; offset = quicktime_sample_to_offset(file, trak, file->vtracks[track].current_position); quicktime_set_position(file, offset); if(quicktime_ftell(file) != file->file_position) { fseeko(file->stream, file->file_position, SEEK_SET); file->ftell_position = file->file_position; } return 0; } int quicktime_read_frame_end(quicktime_t *file, int track) { file->file_position = quicktime_ftell(file); file->vtracks[track].current_position++; return 0; } long quicktime_read_frame(quicktime_t *file, unsigned char *video_buffer, int track) { int64_t bytes, offset, chunk_sample, chunk; int result = 0; quicktime_trak_t *trak = file->vtracks[track].track; bytes = quicktime_frame_size(file, file->vtracks[track].current_position, track); quicktime_chunk_of_sample(&chunk_sample, &chunk, trak, file->vtracks[track].current_position); file->vtracks[track].cur_chunk = chunk; offset = quicktime_sample_to_offset(file, trak, file->vtracks[track].current_position); quicktime_set_position(file, offset); result = quicktime_read_data(file, video_buffer, bytes); lqt_update_frame_position(&file->vtracks[track]); if(!result) return 0; return bytes; } long quicktime_get_keyframe_before(quicktime_t *file, long frame, int track) { quicktime_trak_t *trak = file->vtracks[track].track; quicktime_stss_t *stss = &trak->mdia.minf.stbl.stss; int i; // Offset 1 frame++; for(i = stss->total_entries - 1; i >= 0; i--) { if(stss->table[i].sample <= frame) return stss->table[i].sample - 1; } return 0; } #if 0 static long quicktime_get_keyframe_after(quicktime_t *file, long frame, int track) { quicktime_trak_t *trak = file->vtracks[track].track; quicktime_stss_t *stss = &trak->mdia.minf.stbl.stss; int i; // Offset 1 frame++; for(i = 0; i < stss->total_entries; i++) { if(stss->table[i].sample >= frame) return stss->table[i].sample - 1; } return 0; } #endif void quicktime_insert_keyframe(quicktime_t *file, long frame, int track) { quicktime_trak_t *trak = file->vtracks[track].track; quicktime_stss_t *stss = &trak->mdia.minf.stbl.stss; if(file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML)) { // Set keyframe flag in idx1 table. if(file->total_riffs == 1) quicktime_set_idx1_keyframe(file, trak, frame); // Set keyframe flag in indx table. if(file->file_type == LQT_FILE_AVI_ODML) { quicktime_set_indx_keyframe(file, trak, frame); } } // Expand table if(stss->entries_allocated <= stss->total_entries) { stss->entries_allocated += 1024; stss->table = realloc(stss->table, sizeof(*stss->table) * stss->entries_allocated); } stss->table[stss->total_entries].sample = frame+1; stss->total_entries++; } int quicktime_has_keyframes(quicktime_t *file, int track) { quicktime_trak_t *trak = file->vtracks[track].track; quicktime_stss_t *stss = &trak->mdia.minf.stbl.stss; return stss->total_entries > 0; } int lqt_is_keyframe(quicktime_t *file, int track, int frame) { int i; quicktime_stss_t *stss = &file->vtracks[track].track->mdia.minf.stbl.stss; if(!stss->total_entries) return 1; frame++; for(i = 0; i < stss->total_entries; i++) { if(stss->table[i].sample == frame) return 1; } return 0; } int quicktime_init_video_map(quicktime_video_map_t *vtrack, int encode, lqt_codec_info_t * info) { vtrack->current_position = 0; vtrack->cur_chunk = 0; vtrack->io_cmodel = BC_RGB888; quicktime_init_vcodec(vtrack, encode, info); return 0; } int quicktime_delete_video_map(quicktime_video_map_t *vtrack) { quicktime_delete_codec(vtrack->codec); if(vtrack->temp_frame) lqt_rows_free(vtrack->temp_frame); if(vtrack->timecodes) free(vtrack->timecodes); if(vtrack->timestamps) free(vtrack->timestamps); if(vtrack->picture_numbers) free(vtrack->picture_numbers); lqt_compression_info_free(&vtrack->ci); return 0; } int quicktime_init_audio_map(quicktime_t * file, quicktime_audio_map_t *atrack, int encode, lqt_codec_info_t * info) { if(!encode) atrack->total_samples = quicktime_track_samples(file, atrack->track); atrack->channels = atrack->track->mdia.minf.stbl.stsd.table[0].channels; atrack->samplerate = (int)(atrack->track->mdia.minf.stbl.stsd.table[0].samplerate + 0.5); atrack->current_position = 0; atrack->cur_chunk = 0; if(!encode) { /* Set channel setup */ if(atrack->track->mdia.minf.stbl.stsd.table[0].has_chan) quicktime_get_chan(atrack); } quicktime_init_acodec(atrack, encode, info); return 0; } int quicktime_delete_audio_map(quicktime_audio_map_t *atrack) { quicktime_delete_codec(atrack->codec); if(atrack->sample_buffer) free(atrack->sample_buffer); if(atrack->channel_setup) free(atrack->channel_setup); lqt_compression_info_free(&atrack->ci); return 0; } // Initialize maps, for reading only void quicktime_init_maps(quicktime_t * file) { int i, j, k, dom, track; /* Initialize trak for reading */ for(i = 0; i < file->moov.total_tracks; i++) { quicktime_trak_fix_counts(file, file->moov.trak[i], file->moov.mvhd.time_scale); } /* get tables for all the different tracks */ file->total_atracks = quicktime_audio_tracks(file); if(file->total_atracks) { file->atracks = calloc(1, sizeof(*file->atracks) * file->total_atracks); for(i = 0, track = 0; i < file->total_atracks; i++, track++) { while(!file->moov.trak[track]->mdia.minf.is_audio) track++; file->atracks[i].track = file->moov.trak[track]; quicktime_init_audio_map(file, &file->atracks[i], file->wr, (lqt_codec_info_t*)0); /* Some codecs set the channel setup */ file->atracks[i].codec->decode_audio(file, (void*)0, 0, i); } } file->total_vtracks = quicktime_video_tracks(file); if(file->total_vtracks) { file->vtracks = calloc(1, sizeof(*file->vtracks) * file->total_vtracks); for(track = 0, i = 0; i < file->total_vtracks; i++, track++) { while(!file->moov.trak[track]->mdia.minf.is_video) track++; file->vtracks[i].track = file->moov.trak[track]; quicktime_init_video_map(&file->vtracks[i], file->wr, (lqt_codec_info_t*)0); /* Get decoder colormodel */ file->vtracks[i].codec->decode_video(file, (uint8_t**)0, i); file->vtracks[i].io_cmodel = file->vtracks[i].stream_cmodel; lqt_get_default_rowspan(file->vtracks[i].stream_cmodel, quicktime_video_width(file, i), &file->vtracks[i].stream_row_span, &file->vtracks[i].stream_row_span_uv); /* Get interlace mode */ if((file->vtracks[i].interlace_mode == LQT_INTERLACE_NONE) && (file->vtracks[i].track->mdia.minf.stbl.stsd.table[0].has_fiel)) { dom = file->vtracks[i].track->mdia.minf.stbl.stsd.table[0].fiel.dominance; if (file->vtracks[i].track->mdia.minf.stbl.stsd.table[0].fiel.fields == 2) { if (dom == 14 || dom == 6) file->vtracks[i].interlace_mode = LQT_INTERLACE_BOTTOM_FIRST; else if (dom == 9 || dom == 1) file->vtracks[i].interlace_mode = LQT_INTERLACE_TOP_FIRST; } } /* Timecode track */ if(file->moov.trak[track]->has_tref) { for(j = 0; j < file->moov.trak[track]->tref.num_references; j++) { /* Track reference has type tmcd */ if(quicktime_match_32(file->moov.trak[track]->tref.references[j].type, "tmcd")) { for(k = 0; k < file->moov.total_tracks; k++) { if(file->moov.trak[track]->tref.references[j].tracks[0] == file->moov.trak[k]->tkhd.track_id) { file->vtracks[i].timecode_track = file->moov.trak[k]; break; } } break; } } } } } /* Text tracks */ file->total_ttracks = lqt_text_tracks(file); if(file->total_ttracks) { file->ttracks = calloc(file->total_ttracks, sizeof(*file->ttracks)); for(track = 0, i = 0; i < file->total_ttracks; i++, track++) { while(!file->moov.trak[track]->mdia.minf.is_text) track++; lqt_init_text_map(file, &file->ttracks[i], file->moov.trak[track], 0); } } } int quicktime_read_info(quicktime_t *file) { int result = 0, got_header = 0; int64_t start_position = quicktime_position(file); quicktime_atom_t leaf_atom; uint8_t avi_avi[4]; int got_avi = 0; quicktime_set_position(file, 0LL); /* Test file format */ do { file->file_type = LQT_FILE_AVI; result = quicktime_atom_read_header(file, &leaf_atom); if(!result && quicktime_atom_is(&leaf_atom, "RIFF")) { quicktime_read_data(file, avi_avi, 4); if(quicktime_match_32(avi_avi, "AVI ")) { got_avi = 1; } else { result = 0; break; } } else { result = 0; break; } }while(1); if(!got_avi) file->file_type = LQT_FILE_NONE; quicktime_set_position(file, 0LL); /* McRoweSoft AVI section */ if(file->file_type == LQT_FILE_AVI) { /* Import first RIFF */ do { result = quicktime_atom_read_header(file, &leaf_atom); if(!result) { if(quicktime_atom_is(&leaf_atom, "RIFF")) { quicktime_read_riff(file, &leaf_atom); /* Return success */ got_header = 1; } } }while(!result && !got_header && quicktime_position(file) < file->total_length); /* Construct indexes. */ if(quicktime_import_avi(file)) return 1; } /* Quicktime section */ else if(!(file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML))) { do { result = quicktime_atom_read_header(file, &leaf_atom); if(!result) { if(quicktime_atom_is(&leaf_atom, "mdat")) { quicktime_read_mdat(file, &file->mdat, &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "ftyp")) { quicktime_read_ftyp(file, &file->ftyp, &leaf_atom); file->file_type = quicktime_ftyp_get_file_type(&file->ftyp); file->has_ftyp = 1; } else if(quicktime_atom_is(&leaf_atom, "moov")) { /* Set preload and preload the moov atom here */ int64_t start_position = quicktime_position(file); long temp_size = leaf_atom.end - start_position; unsigned char *temp = malloc(temp_size); quicktime_set_preload(file, (temp_size < 0x100000) ? 0x100000 : temp_size); quicktime_read_data(file, temp, temp_size); quicktime_set_position(file, start_position); free(temp); quicktime_read_moov(file, &file->moov, &leaf_atom); got_header = 1; } else quicktime_atom_skip(file, &leaf_atom); } }while(!result && quicktime_position(file) < file->total_length); /* read QTVR sample atoms -- object */ if (lqt_qtvr_get_object_track(file) >= 0) { quicktime_qtatom_t leaf_atom, root_atom; int64_t start_position = quicktime_position(file); quicktime_set_position(file, file->moov.trak[lqt_qtvr_get_object_track(file)]->mdia.minf.stbl.stco.table[0].offset); quicktime_qtatom_read_container_header(file); /* root qtatom "sean" */ quicktime_qtatom_read_header(file, &root_atom); do { quicktime_qtatom_read_header(file, &leaf_atom); if(quicktime_qtatom_is(&leaf_atom, "obji")) { quicktime_read_obji(file, &file->qtvr_node[0].obji); } else if(quicktime_qtatom_is(&leaf_atom, "ndhd")) { quicktime_read_ndhd(file, &file->qtvr_node[0].ndhd); } else quicktime_qtatom_skip(file, &leaf_atom); } while(quicktime_position(file) < root_atom.end); quicktime_set_position(file, start_position); } /* read QTVR sample atoms -- panorama */ if (lqt_qtvr_get_panorama_track(file) >= 0 && lqt_qtvr_get_qtvr_track(file) >= 0) { quicktime_qtatom_t leaf_atom, root_atom; int64_t start_position = quicktime_position(file); quicktime_set_position(file, file->moov.trak[lqt_qtvr_get_panorama_track(file)]->mdia.minf.stbl.stco.table[0].offset); quicktime_qtatom_read_container_header(file); /* root qtatom "sean" */ quicktime_qtatom_read_header(file, &root_atom); do { quicktime_qtatom_read_header(file, &leaf_atom); if(quicktime_qtatom_is(&leaf_atom, "pdat")) { quicktime_read_pdat(file, &file->qtvr_node[0].pdat); } else if(quicktime_qtatom_is(&leaf_atom, "ndhd")) { quicktime_read_ndhd(file, &file->qtvr_node[0].ndhd); } else quicktime_qtatom_skip(file, &leaf_atom); } while(quicktime_position(file) < root_atom.end); quicktime_set_position(file, start_position); } if (lqt_qtvr_get_qtvr_track(file) >= 0) { quicktime_qtatom_t leaf_atom, root_atom; int64_t start_position = quicktime_position(file); quicktime_set_position(file, file->moov.trak[lqt_qtvr_get_qtvr_track(file)]->mdia.minf.stbl.stco.table[0].offset); quicktime_qtatom_read_container_header(file); /* root qtatom "sean" */ quicktime_qtatom_read_header(file, &root_atom); do { quicktime_qtatom_read_header(file, &leaf_atom); if(quicktime_qtatom_is(&leaf_atom, "ndhd")) { quicktime_read_ndhd(file, &file->qtvr_node[0].ndhd); } else quicktime_qtatom_skip(file, &leaf_atom); } while(quicktime_position(file) < root_atom.end); quicktime_set_position(file, start_position); } /* go back to the original position */ quicktime_set_position(file, start_position); } /* Set file type if no ftyp is there (must be done before initializing the codecs) */ if(file->file_type == LQT_FILE_NONE) file->file_type = LQT_FILE_QT_OLD; /* Initialize track map objects */ if(got_header) { quicktime_init_maps(file); } /* Shut down preload in case of an obsurdly high temp_size */ quicktime_set_preload(file, 0); return !got_header; } int quicktime_dump(quicktime_t *file) { lqt_dump("quicktime_dump\n"); if(file->has_ftyp) quicktime_ftyp_dump(&file->ftyp); lqt_dump("movie data (mdat)\n"); lqt_dump(" size %"PRId64"\n", file->mdat.atom.size); lqt_dump(" start %"PRId64"\n", file->mdat.atom.start); quicktime_moov_dump(&file->moov); if (lqt_qtvr_get_object_track(file) >= 0) { quicktime_obji_dump(&file->qtvr_node[0].obji); } if (lqt_qtvr_get_panorama_track(file) >= 0) { quicktime_pdat_dump(&file->qtvr_node[0].pdat); } if (lqt_qtvr_get_qtvr_track(file) >= 0) { quicktime_ndhd_dump(&file->qtvr_node[0].ndhd); } if(file->file_type & (LQT_FILE_AVI | LQT_FILE_AVI_ODML)) { quicktime_riff_dump(file->riff[0]); } return 0; } // ================================== Entry points ============================= int quicktime_check_sig(char *path) { quicktime_t file; quicktime_atom_t leaf_atom; int result = 0, result1 = 0, result2 = 0; uint8_t avi_test[12]; quicktime_init(&file); result = quicktime_file_open(&file, path, 1, 0); if(!result) { // Check for Microsoft AVI quicktime_read_data(&file, avi_test, 12); quicktime_set_position(&file, 0); if(quicktime_match_32(avi_test, "RIFF") && quicktime_match_32(avi_test + 8, "AVI ")) { result2 = 1; } else { do { result1 = quicktime_atom_read_header(&file, &leaf_atom); if(!result1) { /* just want the "moov" atom */ if(quicktime_atom_is(&leaf_atom, "moov")) { result2 = 1; } else quicktime_atom_skip(&file, &leaf_atom); } }while(!result1 && !result2 && quicktime_position(&file) < file.total_length); } } quicktime_file_close(&file); quicktime_delete(&file); return result2; } void quicktime_set_avi(quicktime_t *file, int value) { if(value) file->file_type = LQT_FILE_AVI_ODML; } #if 0 static int quicktime_is_avi(quicktime_t *file) { return !!(file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML)); } #endif static quicktime_t* do_open(const char *filename, int rd, int wr, lqt_file_type_t type, lqt_log_callback_t log_cb, void * log_data) { int i; quicktime_t *new_file; int result = 0; new_file = calloc(1, sizeof(*new_file)); new_file->log_callback = log_cb; new_file->log_data = log_data; if(rd && wr) { lqt_log(new_file, LQT_LOG_ERROR, LOG_DOMAIN, "read/write mode is not supported"); free(new_file); return (quicktime_t*)0; } quicktime_init(new_file); new_file->wr = wr; new_file->rd = rd; new_file->mdat.atom.start = 0; if(wr) { new_file->file_type = type; quicktime_ftyp_init(&new_file->ftyp, type); if(new_file->ftyp.major_brand) new_file->has_ftyp = 1; /* Switch the iods atom on for MP4 */ if(new_file->file_type & LQT_FILE_MP4) new_file->moov.has_iods = 1; } result = quicktime_file_open(new_file, filename, rd, wr); if(!result) { if(rd) { if(quicktime_read_info(new_file)) { lqt_log(new_file, LQT_LOG_ERROR, LOG_DOMAIN, "Opening failed (unsupported filetype)"); quicktime_close(new_file); new_file = 0; } } /* start the data atom */ /* also don't want to do this if making a streamable file */ if(wr) { if(new_file->has_ftyp) quicktime_write_ftyp(new_file, &new_file->ftyp); quicktime_atom_write_header64(new_file, &new_file->mdat.atom, "mdat"); } } else { /* If the open failed due to permission or path errors then there * may not be a file pointer allocated and attempting to close will * coredump due to a NULL pointer dereference. */ if (new_file->stream) quicktime_close(new_file); else free(new_file); new_file = 0; } if(rd && new_file) { /* Set default decoding parameters */ for(i = 0; i < new_file->total_atracks; i++) lqt_set_default_audio_parameters(new_file, i); for(i = 0; i < new_file->total_vtracks; i++) lqt_set_default_video_parameters(new_file, i); } return new_file; } quicktime_t* quicktime_open(const char *filename, int rd, int wr) { return do_open(filename, rd, wr, LQT_FILE_QT_OLD, NULL, NULL); } quicktime_t * lqt_open_read(const char * filename) { return do_open(filename, 1, 0, LQT_FILE_NONE, NULL, NULL); } quicktime_t * lqt_open_write(const char * filename, lqt_file_type_t type) { return do_open(filename, 0, 1, type, NULL, NULL); } quicktime_t * lqt_open_read_with_log(const char * filename, lqt_log_callback_t cb, void * log_data) { return do_open(filename, 1, 0, LQT_FILE_NONE, cb, log_data); } quicktime_t * lqt_open_write_with_log(const char * filename, lqt_file_type_t type, lqt_log_callback_t cb, void * log_data) { return do_open(filename, 0, 1, type, cb, log_data); } int quicktime_close(quicktime_t *file) { int i; int result = 0; if(file->wr) { /* Finish final chunk if necessary */ if(file->write_trak) quicktime_write_chunk_footer(file, file->write_trak); quicktime_codecs_flush(file); for(i = 0; i < file->total_vtracks; i++) { lqt_video_build_timestamp_tables(file, i); /* Fix stts for timecode track */ if(file->vtracks[i].timecode_track && file->vtracks[i].timecodes_written) { int64_t duration; quicktime_trak_duration(file->vtracks[i].track, &duration, (int*)0); lqt_flush_timecode(file, i, duration, 1); } } if(file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML)) { #if 0 quicktime_atom_t junk_atom; int64_t position = quicktime_position(file); #endif // total_riffs is 0 if no A/V frames have been written if(file->total_riffs) { // Finalize last header quicktime_finalize_riff(file, file->riff[file->total_riffs - 1]); // Finalize the odml header quicktime_finalize_odml(file, &file->riff[0]->hdrl); if(file->file_type == LQT_FILE_AVI_ODML) { for(i = 0; i < file->moov.total_tracks; i++) { quicktime_finalize_indx(file, &file->moov.trak[i]->strl->indx); } } } } else { if (lqt_qtvr_get_object_track(file) >= 0) { lqt_qtvr_add_object_node(file); } else if (lqt_qtvr_get_panorama_track(file) >= 0) { lqt_qtvr_add_panorama_node(file); } // Atoms are only written here quicktime_atom_write_footer(file, &file->mdat.atom); quicktime_finalize_moov(file, &file->moov); quicktime_write_moov(file, &file->moov); } } quicktime_file_close(file); quicktime_delete(file); free(file); return result; } /* * Apply default parameters for a codec */ static void apply_default_parameters(quicktime_t * file, int track, quicktime_codec_t * codec, int encode) { int num_parameters; lqt_parameter_info_t * parameter_info; int j; lqt_codec_info_t * codec_info = codec->info; if(!codec_info) return; if(encode) { num_parameters = codec_info->num_encoding_parameters; parameter_info = codec_info->encoding_parameters; } else { num_parameters = codec_info->num_decoding_parameters; parameter_info = codec_info->decoding_parameters; } for(j = 0; j < num_parameters; j++) { switch(parameter_info[j].type) { case LQT_PARAMETER_INT: lqt_log(file, LQT_LOG_DEBUG, LOG_DOMAIN, "Setting parameter %s to %d", parameter_info[j].name, parameter_info[j].val_default.val_int); codec->set_parameter(file, track, parameter_info[j].name, ¶meter_info[j].val_default.val_int); break; case LQT_PARAMETER_FLOAT: lqt_log(file, LQT_LOG_DEBUG, LOG_DOMAIN, "Setting parameter %s to %f", parameter_info[j].name, parameter_info[j].val_default.val_float); codec->set_parameter(file, track, parameter_info[j].name, ¶meter_info[j].val_default.val_float); break; case LQT_PARAMETER_STRING: case LQT_PARAMETER_STRINGLIST: lqt_log(file, LQT_LOG_DEBUG, LOG_DOMAIN, "Setting parameter %s to %s", parameter_info[j].name, parameter_info[j].val_default.val_string); codec->set_parameter(file, track, parameter_info[j].name, parameter_info[j].val_default.val_string); break; case LQT_PARAMETER_SECTION: break; /* NOP */ } } } void lqt_set_default_video_parameters(quicktime_t * file, int track) { int i; for(i = 0; i < file->total_vtracks; i++) { apply_default_parameters(file, track, file->vtracks[track].codec, file->wr); } } void lqt_set_default_audio_parameters(quicktime_t * file, int track) { int i; for(i = 0; i < file->total_atracks; i++) { apply_default_parameters(file, i, file->atracks[track].codec, file->wr); } } int quicktime_major() { return QUICKTIME_MAJOR; } int quicktime_minor() { return QUICKTIME_MINOR; } int quicktime_release() { return QUICKTIME_RELEASE; } int quicktime_div3_is_key(unsigned char *data, long size) { int result = 0; // First 2 bits are pict type. result = (data[0] & 0xc0) == 0; return result; } /* * AVI Specific stuff */ int lqt_is_avi(quicktime_t *file) { return (file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML)); } int lqt_get_wav_id(quicktime_t *file, int track) { quicktime_trak_t * trak; trak = file->atracks[track].track; return trak->mdia.minf.stbl.stsd.table[0].compression_id; } int64_t * lqt_get_chunk_sizes(quicktime_t * file, quicktime_trak_t *trak) { int i, j; int64_t * ret; int64_t next_offset; long num_chunks; int num_tracks; int * chunk_indices; num_chunks = trak->mdia.minf.stbl.stco.total_entries; ret = calloc(num_chunks, sizeof(int64_t)); num_tracks = file->moov.total_tracks; chunk_indices = malloc(num_tracks * sizeof(int)); for(i = 0; i < num_tracks; i++) { chunk_indices[i] = 0; } for(i = 0; i < num_chunks; i++) { next_offset = -1; for(j = 0; j < num_tracks; j++) { if(chunk_indices[j] < 0) continue; while(file->moov.trak[j]->mdia.minf.stbl.stco.table[chunk_indices[j]].offset <= trak->mdia.minf.stbl.stco.table[i].offset) { if(chunk_indices[j] >= file->moov.trak[j]->mdia.minf.stbl.stco.total_entries - 1) { chunk_indices[j] = -1; break; } else chunk_indices[j]++; } if(chunk_indices[j] < 0) continue; if((next_offset == -1) || (file->moov.trak[j]->mdia.minf.stbl.stco.table[chunk_indices[j]].offset < next_offset)) next_offset = file->moov.trak[j]->mdia.minf.stbl.stco.table[chunk_indices[j]].offset; } if(next_offset > 0) { ret[i] = next_offset - trak->mdia.minf.stbl.stco.table[i].offset; } else /* Last chunk: Take the end of the mdat atom */ { ret[i] = file->mdat.atom.start + file->mdat.atom.size - trak->mdia.minf.stbl.stco.table[i].offset; if(ret[i] < 0) ret[i] = 0; } } free(chunk_indices); return ret; } int lqt_read_audio_chunk(quicktime_t * file, int track, long chunk, uint8_t ** buffer, int * buffer_alloc, int * samples) { int64_t offset; quicktime_trak_t * trak; int result; trak = file->atracks[track].track; if(chunk >= trak->mdia.minf.stbl.stco.total_entries) { /* Read beyond EOF */ file->atracks[track].eof = 1; return 0; } if(!trak->chunk_sizes) { trak->chunk_sizes = lqt_get_chunk_sizes(file, trak); } if(samples) *samples = quicktime_chunk_samples(trak, chunk); /* Reallocate buffer */ if(*buffer_alloc < trak->chunk_sizes[chunk] + 16) { *buffer_alloc = trak->chunk_sizes[chunk] + 32; *buffer = realloc(*buffer, *buffer_alloc); } /* Get offset */ offset = quicktime_chunk_to_offset(file, trak, chunk); quicktime_set_position(file, offset); result = quicktime_read_data(file, *buffer, trak->chunk_sizes[chunk]); memset((*buffer) + trak->chunk_sizes[chunk], 0, 16); return result ? trak->chunk_sizes[chunk] : 0; } int lqt_append_audio_chunk(quicktime_t * file, int track, long chunk, uint8_t ** buffer, int * buffer_alloc, int initial_bytes) { int64_t offset; quicktime_trak_t * trak; int result; trak = file->atracks[track].track; if(chunk >= trak->mdia.minf.stbl.stco.total_entries) { /* Read beyond EOF */ file->atracks[track].eof = 1; return 0; } if(!trak->chunk_sizes) { trak->chunk_sizes = lqt_get_chunk_sizes(file, trak); } /* Reallocate buffer */ if(*buffer_alloc < trak->chunk_sizes[chunk] + 16 + initial_bytes) { *buffer_alloc = trak->chunk_sizes[chunk] + 32 + initial_bytes; *buffer = realloc(*buffer, *buffer_alloc); } /* Get offset */ offset = quicktime_chunk_to_offset(file, trak, chunk); quicktime_set_position(file, offset); result = quicktime_read_data(file, (*buffer) + initial_bytes, trak->chunk_sizes[chunk]); memset((*buffer) + initial_bytes + trak->chunk_sizes[chunk], 0, 16); return result ? trak->chunk_sizes[chunk] : 0; } int64_t lqt_last_audio_position(quicktime_t * file, int track) { return file->atracks[track].last_position; } /* Interlace mode */ static struct { lqt_interlace_mode_t mode; const char * name; } interlace_modes[] = { { LQT_INTERLACE_NONE, "None (Progressive)" }, { LQT_INTERLACE_TOP_FIRST, "Top field first" }, { LQT_INTERLACE_BOTTOM_FIRST, "Bottom field first" } }; lqt_interlace_mode_t lqt_get_interlace_mode(quicktime_t * file, int track) { if(track < 0 || track > file->total_vtracks) return LQT_INTERLACE_NONE; return file->vtracks[track].interlace_mode; } int lqt_set_interlace_mode(quicktime_t * file, int track, lqt_interlace_mode_t mode) { if(track < 0 || track > file->total_vtracks) return 0; file->vtracks[track].interlace_mode = mode; return 1; } const char * lqt_interlace_mode_to_string(lqt_interlace_mode_t mode) { int i; for(i = 0; i < sizeof(interlace_modes)/sizeof(interlace_modes[0]); i++) { if(interlace_modes[i].mode == mode) return interlace_modes[i].name; } return interlace_modes[0].name; } /* Chroma placement */ static struct { lqt_chroma_placement_t placement; const char * name; } chroma_placements[] = { { LQT_CHROMA_PLACEMENT_DEFAULT, "MPEG-1/JPEG" }, { LQT_CHROMA_PLACEMENT_MPEG2, "MPEG-2" }, { LQT_CHROMA_PLACEMENT_DVPAL, "PAL DV" } }; const char * lqt_chroma_placement_to_string(lqt_chroma_placement_t placement) { int i; for(i = 0; i < sizeof(chroma_placements)/sizeof(chroma_placements[0]); i++) { if(chroma_placements[i].placement == placement) return chroma_placements[i].name; } return chroma_placements[0].name; } lqt_chroma_placement_t lqt_get_chroma_placement(quicktime_t * file, int track) { if(track < 0 || track > file->total_vtracks) return LQT_INTERLACE_NONE; return file->vtracks[track].chroma_placement; } /* Sample format */ static struct { lqt_sample_format_t format; const char * name; } sample_formats[] = { { LQT_SAMPLE_UNDEFINED, "Undefined" }, /* If this is returned, we have an error */ { LQT_SAMPLE_INT8, "8 bit signed" }, { LQT_SAMPLE_UINT8, "8 bit unsigned" }, { LQT_SAMPLE_INT16, "16 bit signed" }, { LQT_SAMPLE_INT32, "32 bit signed" }, { LQT_SAMPLE_FLOAT, "Floating point" }, /* Float is ALWAYS machine native */ { LQT_SAMPLE_DOUBLE, "Double precision" } /* Double is ALWAYS machine native */ }; const char * lqt_sample_format_to_string(lqt_sample_format_t format) { int i; for(i = 0; i < sizeof(sample_formats)/sizeof(sample_formats[0]); i++) { if(sample_formats[i].format == format) return sample_formats[i].name; } return sample_formats[0].name; } lqt_sample_format_t lqt_get_sample_format(quicktime_t * file, int track) { quicktime_audio_map_t * atrack; if(track < 0 || track > file->total_atracks) return LQT_SAMPLE_UNDEFINED; atrack = &file->atracks[track]; if(atrack->sample_format == LQT_SAMPLE_UNDEFINED) { if(file->wr) { atrack->codec->encode_audio(file, (void*)0, 0, track); } else { atrack->codec->decode_audio(file, (void*)0, 0, track); } } return atrack->sample_format; } void lqt_init_vbr_audio(quicktime_t * file, int track) { quicktime_trak_t * trak = file->atracks[track].track; trak->mdia.minf.stbl.stsd.table[0].compression_id = -2; trak->mdia.minf.stbl.stsz.sample_size = 0; trak->mdia.minf.is_audio_vbr = 1; if(trak->strl) { trak->strl->strh.dwRate = quicktime_sample_rate(file, track); trak->strl->strh.dwScale = 0; trak->strl->strh.dwSampleSize = 0; trak->strl->strf.wf.f.WAVEFORMAT.nBlockAlign = 0; trak->strl->strf.wf.f.WAVEFORMAT.nAvgBytesPerSec = 18120; // Probably doesn't matter trak->strl->strf.wf.f.PCMWAVEFORMAT.wBitsPerSample = 0; } } LQT_EXTERN void lqt_set_audio_bitrate(quicktime_t * file, int track, int bitrate) { quicktime_trak_t * trak = file->atracks[track].track; if(!trak->strl) return; /* strh stuff */ trak->strl->strh.dwRate = bitrate / 8; trak->strl->strh.dwScale = 1; trak->strl->strh.dwSampleSize = 1; /* WAVEFORMATEX stuff */ trak->strl->strf.wf.f.WAVEFORMAT.nBlockAlign = 1; trak->strl->strf.wf.f.WAVEFORMAT.nAvgBytesPerSec = bitrate / 8; trak->strl->strf.wf.f.PCMWAVEFORMAT.wBitsPerSample = 0; } void lqt_start_audio_vbr_frame(quicktime_t * file, int track) { quicktime_audio_map_t * atrack = &file->atracks[track]; /* Make chunk at maximum 10 VBR packets large */ if((file->write_trak == atrack->track) && (atrack->track->chunk_samples >= 10)) { quicktime_write_chunk_footer(file, file->write_trak); quicktime_write_chunk_header(file, atrack->track); } atrack->vbr_frame_start = quicktime_position(file); } void lqt_finish_audio_vbr_frame(quicktime_t * file, int track, int num_samples) { int size; quicktime_stsz_t * stsz; quicktime_stts_t * stts; long vbr_frames_written; quicktime_audio_map_t * atrack = &file->atracks[track]; stsz = &atrack->track->mdia.minf.stbl.stsz; stts = &atrack->track->mdia.minf.stbl.stts; vbr_frames_written = stsz->total_entries; /* Update stsz */ size = quicktime_position(file) - atrack->vbr_frame_start; quicktime_update_stsz(stsz, vbr_frames_written, size); if(atrack->track->strl) { quicktime_strl_t * strl = atrack->track->strl; if(size > strl->strf.wf.f.WAVEFORMAT.nBlockAlign) strl->strf.wf.f.WAVEFORMAT.nBlockAlign = size; if(!strl->strh.dwScale) strl->strh.dwScale = num_samples; strl->strh.dwLength++; } /* Update stts */ quicktime_update_stts(stts, vbr_frames_written, num_samples); atrack->track->chunk_samples++; } /* VBR Reading support */ /* Check if VBR reading should be enabled */ int lqt_audio_is_vbr(quicktime_t * file, int track) { return file->atracks[track].track->mdia.minf.is_audio_vbr; } /* Get the index of the VBR packet (== sample) containing a specified uncompressed sample */ static uint64_t packet_of_sample(quicktime_stts_t * stts, int64_t sample) { uint32_t i; int64_t packet_count = 0; int64_t sample_count = 0; for(i = 0; i < stts->total_entries; i++) { if(sample_count + stts->table[i].sample_count * stts->table[i].sample_duration > sample) { return packet_count + (sample - sample_count) / stts->table[i].sample_duration; } sample_count += stts->table[i].sample_count * stts->table[i].sample_duration; packet_count += stts->table[i].sample_count; } return -1; } /* * Helper function: Get the "durarion of a sample range" (which means the * uncompressed samples in a range of VBR packets) */ static int64_t get_uncompressed_samples(quicktime_stts_t * stts, long start_sample, long end_sample) { long count, i, stts_index = 0, stts_count = 0; int64_t ret; count = 0; ret = 0; for(i = 0; i < stts->total_entries; i++) { if(count + stts->table[i].sample_count > start_sample) { stts_index = i; stts_count = start_sample - count; break; } count += stts->table[i].sample_count; } ret = 0; for(i = start_sample; i < end_sample; i++) { ret += stts->table[stts_index].sample_duration; stts_count++; if(stts_count >= stts->table[stts_index].sample_count) { stts_index++; stts_count = 0; } } return ret; } /* Analog for quicktime_chunk_samples for VBR files */ int lqt_chunk_of_sample_vbr(int64_t *chunk_sample, int64_t *chunk, quicktime_trak_t *trak, int64_t sample) { int64_t packet; int64_t chunk_packet; /* Get the index of the packet containing the uncompressed sample */ packet = packet_of_sample(&trak->mdia.minf.stbl.stts, sample); /* Get the chunk of the packet */ quicktime_chunk_of_sample(&chunk_packet, chunk, trak, packet); /* Get the first uncompressed sample of the first packet of this chunk */ *chunk_sample = get_uncompressed_samples(&trak->mdia.minf.stbl.stts, 0, chunk_packet); return 0; } /* Determine the number of VBR packets (=samples) in one chunk */ int lqt_audio_num_vbr_packets(quicktime_t * file, int track, long chunk, int * samples) { int64_t start_sample; quicktime_trak_t * trak; long result = 0; quicktime_stsc_t *stsc; long i; trak = file->atracks[track].track; stsc = &trak->mdia.minf.stbl.stsc; if(chunk >= trak->mdia.minf.stbl.stco.total_entries) return 0; i = stsc->total_entries - 1; if(!stsc->total_entries) return 0; start_sample = 0; for(i = 0; i < stsc->total_entries; i++) { if(((i < stsc->total_entries - 1) && (stsc->table[i+1].chunk > chunk+1)) || (i == stsc->total_entries - 1)) { start_sample += (chunk - stsc->table[i].chunk) * stsc->table[i].samples; result = stsc->table[i].samples; break; } else start_sample += (stsc->table[i+1].chunk - stsc->table[i].chunk) * stsc->table[i].samples; } if(samples) *samples = get_uncompressed_samples(&trak->mdia.minf.stbl.stts, start_sample, start_sample + result); return result; } /* Read one VBR packet */ int lqt_audio_read_vbr_packet(quicktime_t * file, int track, long chunk, int packet, uint8_t ** buffer, int * buffer_alloc, int * samples) { int64_t offset; long i, stsc_index; quicktime_trak_t * trak; quicktime_stsc_t *stsc; int packet_size; long first_chunk_packet; /* Index of first packet in the chunk */ trak = file->atracks[track].track; stsc = &trak->mdia.minf.stbl.stsc; if(chunk >= trak->mdia.minf.stbl.stco.total_entries) return 0; i = 0; stsc_index = 0; first_chunk_packet = 0; for(i = 0; i < chunk; i++) { if((stsc_index < stsc->total_entries-1) && (stsc->table[stsc_index+1].chunk-1 == i)) stsc_index++; first_chunk_packet += stsc->table[stsc_index].samples; } /* Get offset */ offset = trak->mdia.minf.stbl.stco.table[chunk].offset; for(i = 0; i < packet; i++) { if(trak->mdia.minf.stbl.stsz.table) offset += trak->mdia.minf.stbl.stsz.table[first_chunk_packet+i].size; else offset += trak->mdia.minf.stbl.stsz.sample_size; } /* Get packet size */ if(trak->mdia.minf.stbl.stsz.table) packet_size = trak->mdia.minf.stbl.stsz.table[first_chunk_packet+packet].size; else packet_size = trak->mdia.minf.stbl.stsz.sample_size; /* Get number of audio samples */ if(samples) *samples = get_uncompressed_samples(&trak->mdia.minf.stbl.stts, first_chunk_packet+packet, first_chunk_packet+packet+1); /* Read the data */ if(*buffer_alloc < packet_size+16) { *buffer_alloc = packet_size + 128; *buffer = realloc(*buffer, *buffer_alloc); } quicktime_set_position(file, offset); quicktime_read_data(file, *buffer, packet_size); return packet_size; } static struct { lqt_file_type_t type; char * name; } filetypes[] = { { LQT_FILE_NONE, "Unknown/Undefined" }, { LQT_FILE_QT_OLD, "Quicktime" }, { LQT_FILE_QT, "Quicktime" }, { LQT_FILE_AVI, "AVI" }, { LQT_FILE_AVI_ODML, "AVI ODML" }, { LQT_FILE_MP4, "MP4" }, { LQT_FILE_M4A, "M4A" }, { LQT_FILE_3GP, "3GP" } }; const char * lqt_file_type_to_string(lqt_file_type_t type) { int i; for(i = 0; i < sizeof(filetypes)/sizeof(filetypes[0]); i++) { if(filetypes[i].type == type) return filetypes[i].name; } return filetypes[0].name; } lqt_file_type_t lqt_get_file_type(quicktime_t * file) { return file->file_type; } void lqt_set_max_riff_size(quicktime_t * file, int size) { file->max_riff_size = size * 1024 * 1024; } /* PTS offsets */ /** \ingroup audio_encode * \brief Set an audio pts offset * \param file A quicktime handle * \param track Track index (starting with 0) * \param offset PTS of the first audio sample (in samples) */ void lqt_set_audio_pts_offset(quicktime_t * file, int track, int64_t offset) { quicktime_trak_t * trak; if((track < 0) && (track >= file->total_atracks)) return; trak = file->atracks[track].track; trak->pts_offset = offset; } /** \ingroup audio_decode * \brief Get an audio pts offset * \param file A quicktime handle * \param track Track index (starting with 0) * \returns PTS of the first audio sample (in samples) */ int64_t lqt_get_audio_pts_offset(quicktime_t * file, int track) { quicktime_trak_t * trak; if((track < 0) && (track >= file->total_atracks)) return 0; trak = file->atracks[track].track; return trak->pts_offset; } /** \ingroup video_encode * \brief Set an video pts offset * \param file A quicktime handle * \param track Track index (starting with 0) * \param offset PTS of the first video frame (in timescale units) */ void lqt_set_video_pts_offset(quicktime_t * file, int track, int64_t offset) { quicktime_trak_t * trak; if((track < 0) && (track >= file->total_vtracks)) return; trak = file->vtracks[track].track; trak->pts_offset = offset; } /** \ingroup video_decode * \brief Get an video pts offset * \param file A quicktime handle * \param track Track index (starting with 0) * \returns PTS of the first video frame (in timescale units) */ int64_t lqt_get_video_pts_offset(quicktime_t * file, int track) { quicktime_trak_t * trak; if((track < 0) && (track >= file->total_vtracks)) return 0; trak = file->vtracks[track].track; return trak->pts_offset; } /** \ingroup text_encode * \brief Set an video pts offset * \param file A quicktime handle * \param track Track index (starting with 0) * \param offset PTS offset of the subtitles (in timescale units) */ void lqt_set_text_pts_offset(quicktime_t * file, int track, int64_t offset) { quicktime_trak_t * trak; if((track < 0) && (track >= file->total_ttracks)) return; trak = file->ttracks[track].track; trak->pts_offset = offset; } /** \ingroup text_decode * \brief Get an video pts offset * \param file A quicktime handle * \param track Track index (starting with 0) * \returns PTS offset of the subtitles (in timescale units) */ int64_t lqt_get_text_pts_offset(quicktime_t * file, int track) { quicktime_trak_t * trak; if((track < 0) && (track >= file->total_ttracks)) return 0; trak = file->ttracks[track].track; return trak->pts_offset; } libquicktime-1.2.4/src/atom.c0000644000175000017500000001330111722235260013012 00000000000000/******************************************************************************* atom.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include static int read_type(uint8_t *data, uint8_t *type) { type[0] = data[4]; type[1] = data[5]; type[2] = data[6]; type[3] = data[7]; /* need this for quicktime_check_sig */ if(isalpha(type[0]) && isalpha(type[1]) && isalpha(type[2]) && isalpha(type[3])) return 0; else if(type[0] | type[1] | type[2] | type[3] == 0) return 0; /* These kind of atoms do happen. */ else return 1; } static unsigned long read_size(uint8_t *data) { unsigned long result; unsigned long a, b, c, d; a = data[0]; b = data[1]; c = data[2]; d = data[3]; result = (a << 24) | (b << 16) | (c << 8) | d; // extended header is size 1 // if(result < HEADER_LENGTH) result = HEADER_LENGTH; return result; } static int64_t read_size64(uint8_t *data) { uint64_t result, a, b, c, d, e, f, g, h; a = data[0]; b = data[1]; c = data[2]; d = data[3]; e = data[4]; f = data[5]; g = data[6]; h = data[7]; result = (a << 56) | (b << 48) | (c << 40) | (d << 32) | (e << 24) | (f << 16) | (g << 8) | h; if(result < HEADER_LENGTH) result = HEADER_LENGTH; return (int64_t)result; } static int reset(quicktime_atom_t *atom) { atom->end = 0; atom->type[0] = atom->type[1] = atom->type[2] = atom->type[3] = 0; return 0; } int quicktime_atom_read_header(quicktime_t *file, quicktime_atom_t *atom) { int result = 0; uint8_t header[10]; if(file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML)) { reset(atom); atom->start = quicktime_position(file); if(!quicktime_read_data(file, header, HEADER_LENGTH)) return 1; atom->type[0] = header[0]; atom->type[1] = header[1]; atom->type[2] = header[2]; atom->type[3] = header[3]; atom->size = (((unsigned char)header[4]) ) | (((unsigned char)header[5]) << 8 ) | (((unsigned char)header[6]) << 16) | (((unsigned char)header[7]) << 24); atom->end = quicktime_add3(atom->start, atom->size, 8); } else { reset(atom); atom->start = quicktime_position(file); if(!quicktime_read_data(file, header, HEADER_LENGTH)) return 1; result = read_type(header, atom->type); atom->size = read_size(header); atom->end = atom->start + atom->size; /* Get extended size */ if(atom->size == 1) { if(!quicktime_read_data(file, header, HEADER_LENGTH)) return 1; atom->size = read_size64(header); atom->end = atom->start + atom->size; } } return result; } int quicktime_atom_write_header64(quicktime_t *file, quicktime_atom_t *atom, char *text) { int result = 0; atom->start = quicktime_position(file); result = !quicktime_write_int32(file, 1); if(!result) result = !quicktime_write_char32(file, text); if(!result) result = !quicktime_write_int64(file, 0); atom->use_64 = 1; return result; } int quicktime_atom_write_header(quicktime_t *file, quicktime_atom_t *atom, char *text) { int result = 0; if(file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML)) { reset(atom); atom->start = quicktime_position(file) + 8; result = !quicktime_write_char32(file, text); if(!result) result = !quicktime_write_int32_le(file, 0); atom->use_64 = 0; } else { atom->start = quicktime_position(file); result = !quicktime_write_int32(file, 0); if(!result) result = !quicktime_write_char32(file, text); atom->use_64 = 0; } return result; } void quicktime_atom_write_footer(quicktime_t *file, quicktime_atom_t *atom) { atom->end = quicktime_position(file); if(file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML)) { quicktime_set_position(file, atom->start - 4); quicktime_write_int32_le(file, atom->end - atom->start); quicktime_set_position(file, atom->end); if((atom->end - atom->start) % 2) { quicktime_write_char(file, 0x00); } atom->size = atom->end - atom->start + 8; } else { if(atom->use_64) { quicktime_set_position(file, atom->start + 8); quicktime_write_int64(file, atom->end - atom->start); } else { quicktime_set_position(file, atom->start); quicktime_write_int32(file, atom->end - atom->start); } quicktime_set_position(file, atom->end); } } int quicktime_atom_is(quicktime_atom_t *atom, char *type) { if(atom->type[0] == (uint8_t)type[0] && atom->type[1] == (uint8_t)type[1] && atom->type[2] == (uint8_t)type[2] && atom->type[3] == (uint8_t)type[3]) return 1; else return 0; } int quicktime_atom_skip(quicktime_t *file, quicktime_atom_t *atom) { if((file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML)) && (atom->end % 2)) atom->end++; else if(atom->start == atom->end) atom->end++; return quicktime_set_position(file, atom->end); } libquicktime-1.2.4/src/lqt_codecs.c0000644000175000017500000010510311511622756014202 00000000000000/******************************************************************************* lqt_codecs.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include "quicktime/colormodels.h" #define LQT_LIBQUICKTIME #include #include #include #include #define LOG_DOMAIN "codecs" static int quicktime_delete_codec_stub(quicktime_codec_t *codec) { lqt_log(NULL, LQT_LOG_WARNING, LOG_DOMAIN, "quicktime_delete_stub called"); return 0; } static int quicktime_decode_video_stub(quicktime_t *file, unsigned char **row_pointers, int track) { lqt_log(file, LQT_LOG_WARNING, LOG_DOMAIN, "quicktime_decode_video_stub called"); return 1; } static int quicktime_encode_video_stub(quicktime_t *file, unsigned char **row_pointers, int track) { lqt_log(file, LQT_LOG_WARNING, LOG_DOMAIN, "quicktime_encode_video_stub called"); return 1; } static int quicktime_decode_audio_stub(quicktime_t *file, void * output, long samples, int track) { lqt_log(file, LQT_LOG_WARNING, LOG_DOMAIN, "quicktime_decode_audio_stub called"); return 0; } static int quicktime_encode_audio_stub(quicktime_t *file, void * input, long samples, int track) { lqt_log(file, LQT_LOG_WARNING, LOG_DOMAIN, "quicktime_encode_audio_stub called"); return 1; } static int quicktime_flush_codec_stub(quicktime_t *file, int track) { return 0; } /* * Original quicktime4linux function changed for dynamic loading */ quicktime_codec_t * quicktime_load_codec(lqt_codec_info_t * info, quicktime_audio_map_t * amap, quicktime_video_map_t * vmap) { quicktime_codec_t * codec; lqt_init_codec_func_t init_codec; lqt_init_codec_func_t (*get_codec)(int); codec = calloc(1, sizeof(*codec)); /* Set stubs */ codec->delete_codec = quicktime_delete_codec_stub; codec->decode_video = quicktime_decode_video_stub; codec->encode_video = quicktime_encode_video_stub; codec->decode_audio = quicktime_decode_audio_stub; codec->encode_audio = quicktime_encode_audio_stub; codec->flush = quicktime_flush_codec_stub; if(!info) return codec; codec->info = lqt_codec_info_copy_single(info); lqt_log(NULL, LQT_LOG_DEBUG, LOG_DOMAIN, "Loading module %s", info->module_filename); /* dlopen the module */ codec->module = dlopen(info->module_filename, RTLD_NOW); if(!codec->module) { lqt_log(NULL, LQT_LOG_WARNING, LOG_DOMAIN, "Loading module %s failed: %s", info->module_filename, dlerror()); goto fail; } get_codec = (lqt_init_codec_func_t(*)(int))dlsym(codec->module, "get_codec"); if(!get_codec) { lqt_log(NULL, LQT_LOG_WARNING, LOG_DOMAIN, "Module %s contains no function get_codec", info->module_filename); goto fail; } init_codec = get_codec(info->module_index); init_codec(codec, amap, vmap); return codec; fail: if(codec->module) dlclose(codec->module); free(codec); return NULL; } int quicktime_init_vcodec(quicktime_video_map_t *vtrack, int encode, lqt_codec_info_t * codec_info) { lqt_codec_info_t ** codec_array = (lqt_codec_info_t**)0; char *compressor = vtrack->track->mdia.minf.stbl.stsd.table[0].format; /* Try to find the codec */ if(!codec_info) { codec_array = lqt_find_video_codec(compressor, encode); if(!codec_array) { lqt_log(NULL, LQT_LOG_WARNING, LOG_DOMAIN, "Could not find video %s for fourcc %4s", (encode ? "Encoder" : "Decoder"), compressor); } else codec_info = *codec_array; } vtrack->codec = quicktime_load_codec(codec_info, NULL, vtrack); if(!vtrack->codec) { lqt_log(NULL, LQT_LOG_WARNING, LOG_DOMAIN, "Loading codec %s failed", codec_info->name); if(codec_array) lqt_destroy_codec_info(codec_array); return -1; } if(codec_array) lqt_destroy_codec_info(codec_array); // vtrack->stream_cmodel = lqt_get_decoder_colormodel(quicktime_t * file, int track); return 0; } int quicktime_init_acodec(quicktime_audio_map_t *atrack, int encode, lqt_codec_info_t * codec_info) { lqt_codec_info_t ** codec_array = (lqt_codec_info_t**)0; char *compressor = atrack->track->mdia.minf.stbl.stsd.table[0].format; int wav_id = atrack->track->mdia.minf.stbl.stsd.table[0].compression_id; /* Try to find the codec */ if(!codec_info) { if(compressor && (*compressor != '\0')) { codec_array = lqt_find_audio_codec(compressor, encode); } else if(wav_id) { codec_array = lqt_find_audio_codec_by_wav_id(wav_id, encode); } if(!codec_array) { lqt_log(NULL, LQT_LOG_WARNING, LOG_DOMAIN, "Could not find audio %s for fourcc %4s", (encode ? "Encoder" : "Decoder"), compressor); } else codec_info = *codec_array; } atrack->codec = quicktime_load_codec(codec_info, atrack, NULL); /* We set the wav ids from our info structure, so we don't have to do this in the plugin sources */ if(codec_info && codec_info->num_wav_ids) atrack->wav_id = codec_info->wav_ids[0]; if(codec_array) lqt_destroy_codec_info(codec_array); return 0; } int quicktime_delete_codec(quicktime_codec_t *codec) { codec->delete_codec(codec); /* Close the module */ if(codec->module) dlclose(codec->module); if(codec->info) lqt_codec_info_destroy_single(codec->info); free(codec); return 0; } int quicktime_supported_video(quicktime_t *file, int track) { char *compressor = quicktime_video_compressor(file, track); lqt_codec_info_t ** test_codec = lqt_find_video_codec(compressor, file->wr); if(!test_codec) return 0; lqt_destroy_codec_info(test_codec); return 1; } int quicktime_supported_audio(quicktime_t *file, int track) { lqt_codec_info_t ** test_codec; char *compressor = quicktime_audio_compressor(file, track); test_codec = (lqt_codec_info_t**)0; if(compressor && (*compressor != '\0')) test_codec = lqt_find_audio_codec(compressor, file->wr); else if(lqt_is_avi(file)) test_codec = lqt_find_audio_codec_by_wav_id(lqt_get_wav_id(file, track), file->wr); if(!test_codec) return 0; lqt_destroy_codec_info(test_codec); return 1; } void lqt_update_frame_position(quicktime_video_map_t * track) { track->timestamp += track->track->mdia.minf.stbl.stts.table[track->stts_index].sample_duration; track->stts_count++; if(track->stts_count >= track->track->mdia.minf.stbl.stts.table[track->stts_index].sample_count) { track->stts_index++; track->stts_count = 0; } if(track->track->mdia.minf.stbl.has_ctts) { track->ctts_count++; if(track->ctts_count >= track->track->mdia.minf.stbl.ctts.table[track->ctts_index].sample_count) { track->ctts_index++; track->ctts_count = 0; } } track->current_position++; } /* Set the io_rowspan for the case the user didn't. */ static void set_default_rowspan(quicktime_t *file, int track) { if(file->vtracks[track].io_row_span) return; lqt_get_default_rowspan(file->vtracks[track].io_cmodel, quicktime_video_width(file, track), &file->vtracks[track].io_row_span, &file->vtracks[track].io_row_span_uv); } /* * Same as quicktime_decode_video but doesn't force BC_RGB888 */ int lqt_decode_video(quicktime_t *file, unsigned char **row_pointers, int track) { int result; int height; int width; set_default_rowspan(file, track); height = quicktime_video_height(file, track); width = quicktime_video_width(file, track); if(file->vtracks[track].io_cmodel != file->vtracks[track].stream_cmodel) { if(!file->vtracks[track].temp_frame) { file->vtracks[track].temp_frame = lqt_rows_alloc(width, height, file->vtracks[track].stream_cmodel, &file->vtracks[track].stream_row_span, &file->vtracks[track].stream_row_span_uv); } result = file->vtracks[track].codec->decode_video(file, file->vtracks[track].temp_frame, track); cmodel_transfer(row_pointers, // unsigned char **output_rows, /* Leave NULL if non existent */ file->vtracks[track].temp_frame, // unsigned char **input_rows, 0, // int in_x, /* Dimensions to capture from input frame */ 0, // int in_y, width, // int in_w, height + file->vtracks[track].height_extension, // int in_h, width, // int out_w, height + file->vtracks[track].height_extension, // int out_h, file->vtracks[track].stream_cmodel, // int in_colormodel, file->vtracks[track].io_cmodel, // int out_colormodel, file->vtracks[track].stream_row_span, /* For planar use the luma rowspan */ file->vtracks[track].io_row_span, /* For planar use the luma rowspan */ file->vtracks[track].stream_row_span_uv, /* Chroma rowspan */ file->vtracks[track].io_row_span_uv /* Chroma rowspan */); } else { file->vtracks[track].stream_row_span = file->vtracks[track].io_row_span; file->vtracks[track].stream_row_span_uv = file->vtracks[track].io_row_span_uv; result = file->vtracks[track].codec->decode_video(file, row_pointers, track); } lqt_update_frame_position(&file->vtracks[track]); return result; } /* The original function, which forces BG_RGB888 */ int quicktime_decode_video(quicktime_t *file, unsigned char **row_pointers, int track) { file->vtracks[track].io_cmodel = BC_RGB888; return lqt_decode_video(file, row_pointers, track); } long quicktime_decode_scaled(quicktime_t *file, int in_x, /* Location of input frame to take picture */ int in_y, int in_w, int in_h, int out_w, /* Dimensions of output frame */ int out_h, int color_model, /* One of the color models defined above */ unsigned char **row_pointers, int track) { int result; int height; int width; set_default_rowspan(file, track); height = quicktime_video_height(file, track); width = quicktime_video_width(file, track); file->vtracks[track].io_cmodel = color_model; if(!file->vtracks[track].temp_frame) { file->vtracks[track].temp_frame = lqt_rows_alloc(width, height, file->vtracks[track].stream_cmodel, &file->vtracks[track].stream_row_span, &file->vtracks[track].stream_row_span_uv); } result = file->vtracks[track].codec->decode_video(file, file->vtracks[track].temp_frame, track); cmodel_transfer(row_pointers, // unsigned char **output_rows, /* Leave NULL if non existent */ file->vtracks[track].temp_frame, // unsigned char **input_rows, in_x, // int in_x, /* Dimensions to capture from input frame */ in_y, // int in_y, in_w, // int in_w, in_h, // int in_h, out_w, // int out_w, out_h, // int out_h, file->vtracks[track].stream_cmodel, // int in_colormodel, file->vtracks[track].io_cmodel, // int out_colormodel, file->vtracks[track].stream_row_span, /* For planar use the luma rowspan */ file->vtracks[track].io_row_span, /* For planar use the luma rowspan */ file->vtracks[track].stream_row_span_uv, /* Chroma rowspan */ file->vtracks[track].io_row_span_uv /* Chroma rowspan */); lqt_update_frame_position(&file->vtracks[track]); return result; } int lqt_set_video_pass(quicktime_t *file, int pass, int total_passes, const char * stats_file, int track) { if(file->vtracks[track].codec->set_pass) return file->vtracks[track].codec->set_pass(file, track, pass, total_passes, stats_file); else return 0; } void lqt_start_encoding(quicktime_t *file) { int i; if(file->encoding_started) return; file->encoding_started = 1; if(file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML)) { quicktime_set_position(file, 0); // Write RIFF chunk quicktime_init_riff(file); } /* Trigger warnings if codecs are in the wrong container */ for(i = 0; i < file->total_atracks; i++) { if(!(file->atracks[i].codec->info->compatibility_flags & file->file_type)) lqt_log(file, LQT_LOG_WARNING, LOG_DOMAIN, "Audio codec and container are not known to be compatible. File might be playable by libquicktime only."); } for(i = 0; i < file->total_vtracks; i++) { if(!(file->vtracks[i].codec->info->compatibility_flags & file->file_type)) lqt_log(file, LQT_LOG_WARNING, LOG_DOMAIN, "Video codec and container are not known to be compatible. File might be playable by libquicktime only."); } } static int do_encode_video(quicktime_t *file, unsigned char **row_pointers, int track) { int result; int height; int width; lqt_start_encoding(file); set_default_rowspan(file, track); height = quicktime_video_height(file, track); width = quicktime_video_width(file, track); if(file->vtracks[track].io_cmodel != file->vtracks[track].stream_cmodel) { if(!file->vtracks[track].temp_frame) { file->vtracks[track].temp_frame = lqt_rows_alloc(width, height + file->vtracks[track].height_extension, file->vtracks[track].stream_cmodel, &file->vtracks[track].stream_row_span, &file->vtracks[track].stream_row_span_uv); } cmodel_transfer(file->vtracks[track].temp_frame, // unsigned char **output_rows, /* Leave NULL if non existent */ row_pointers, // unsigned char **input_rows, 0, // int in_x, /* Dimensions to capture from input frame */ 0, // int in_y, width, // int in_w, height + file->vtracks[track].height_extension, // int in_h, width, // int out_w, height + file->vtracks[track].height_extension, // int out_h, file->vtracks[track].io_cmodel, // int in_colormodel, file->vtracks[track].stream_cmodel, // int out_colormodel, file->vtracks[track].io_row_span, /* For planar use the luma rowspan */ file->vtracks[track].stream_row_span, /* For planar use the luma rowspan */ file->vtracks[track].io_row_span_uv, /* Chroma rowspan */ file->vtracks[track].stream_row_span_uv /* Chroma rowspan */); result = file->vtracks[track].codec->encode_video(file, file->vtracks[track].temp_frame, track); } else { file->vtracks[track].stream_row_span = file->vtracks[track].io_row_span; file->vtracks[track].stream_row_span_uv = file->vtracks[track].io_row_span_uv; result = file->vtracks[track].codec->encode_video(file, row_pointers, track); } return result; } void lqt_write_frame_header(quicktime_t * file, int track, int pic_num1, int64_t pic_pts, int keyframe) { quicktime_video_map_t * vtrack = &file->vtracks[track]; quicktime_trak_t * trak = vtrack->track; int pic_num = -1; int i; // fprintf(stderr, "Write frame header %d %ld\n", pic_num1, pic_pts); if(pic_num1 >= 0) pic_num = pic_num1; else { /* We start at current_position because this isn't incremented by now */ for(i = vtrack->current_position; i >= 0; i--) { if(vtrack->timestamps[i] == pic_pts) { pic_num = i; break; } } } // if(pic_num < 0) // fprintf(stderr, "Picture number not found\n"); if(vtrack->cur_chunk >= vtrack->picture_numbers_alloc) { vtrack->picture_numbers_alloc += 1024; vtrack->picture_numbers = realloc(vtrack->picture_numbers, sizeof(*vtrack->picture_numbers) * vtrack->picture_numbers_alloc); } vtrack->picture_numbers[vtrack->cur_chunk] = pic_num; vtrack->keyframe = keyframe; quicktime_write_chunk_header(file, trak); } void lqt_write_frame_footer(quicktime_t * file, int track) { quicktime_video_map_t * vtrack = &file->vtracks[track]; quicktime_trak_t * trak = vtrack->track; trak->chunk_samples = 1; quicktime_write_chunk_footer(file, trak); if(vtrack->keyframe) quicktime_insert_keyframe(file, vtrack->cur_chunk, track); vtrack->cur_chunk++; } void lqt_video_build_timestamp_tables(quicktime_t * file, int track) { int i; quicktime_video_map_t * vtrack = &file->vtracks[track]; quicktime_trak_t * trak = vtrack->track; quicktime_stts_t * stts; quicktime_ctts_t * ctts; quicktime_stts_table_t * stts_tab; int64_t dts; int has_b_frames = 0; /* If all frames are keyframes, disable stss */ if(trak->mdia.minf.stbl.stss.total_entries == vtrack->cur_chunk) trak->mdia.minf.stbl.stss.total_entries = 0; /* If we have no timestamp arrays (e.g. if stream was written compressed) return here */ if(!vtrack->picture_numbers) return; stts = &trak->mdia.minf.stbl.stts; ctts = &trak->mdia.minf.stbl.ctts; #if 0 fprintf (stderr, "Build timestamp tables %ld frames %d\n", vtrack->cur_chunk, stts->default_duration); for(i = 0; i < vtrack->cur_chunk; i++) { fprintf(stderr, "PTS[%d]: %ld\n", i, vtrack->timestamps[i]); } for(i = 0; i < vtrack->cur_chunk; i++) { fprintf(stderr, "pic_num[%d]: %d\n", i, vtrack->picture_numbers[i]); } #endif /* Check if we have B-frames */ for(i = 0; i < vtrack->cur_chunk-1; i++) { if(vtrack->picture_numbers[i] + 1 != vtrack->picture_numbers[i+1]) { has_b_frames = 1; break; } } /* Build preliminary stts */ if(stts->table) { free(stts->table); stts->table = NULL; } stts->total_entries = vtrack->cur_chunk; if(!stts->total_entries) return; stts->table = malloc(vtrack->cur_chunk * sizeof(*stts->table)); for(i = 0; i < vtrack->cur_chunk-1; i++) { stts->table[i].sample_count = 1; stts->table[i].sample_duration = vtrack->timestamps[i+1] - vtrack->timestamps[i]; } /* Last entry */ stts->table[vtrack->cur_chunk-1].sample_count = 1; stts->table[vtrack->cur_chunk-1].sample_duration = vtrack->duration - vtrack->timestamps[vtrack->cur_chunk-1]; if(stts->table[vtrack->cur_chunk-1].sample_duration <= 0) stts->table[vtrack->cur_chunk-1].sample_duration = stts->default_duration; /* If we have no B-frames, exit here */ if(!has_b_frames) return; /* If we have B-frames, reorder stts and build ctts */ stts_tab = malloc(vtrack->cur_chunk * sizeof(*stts_tab)); ctts->table = malloc(vtrack->cur_chunk * sizeof(*ctts->table)); ctts->total_entries = vtrack->cur_chunk; trak->mdia.minf.stbl.has_ctts = 1; dts = 0; /* Loop over *coded* pictures */ for(i = 0; i < vtrack->cur_chunk; i++) { stts_tab[i].sample_duration = stts->table[vtrack->picture_numbers[i]].sample_duration; stts_tab[i].sample_count = 1; /* CTS = PTS - DTS */ ctts->table[i].sample_count = 1; ctts->table[i].sample_duration = vtrack->timestamps[vtrack->picture_numbers[i]] - dts; dts += stts_tab[i].sample_duration; } free(stts->table); stts->table = stts_tab; } void lqt_video_append_timestamp(quicktime_t * file, int track, int64_t time, int duration) { quicktime_video_map_t * vtrack = &file->vtracks[track]; /* Update timestamp table */ // fprintf(stderr, "lqt_video_append_timestamp: %ld %d\n", // time, duration); if(vtrack->current_position >= vtrack->timestamps_alloc) { vtrack->timestamps_alloc += 1024; vtrack->timestamps = realloc(vtrack->timestamps, vtrack->timestamps_alloc * sizeof(*vtrack->timestamps)); } vtrack->timestamps[vtrack->current_position] = time; vtrack->duration = time + duration; } int lqt_encode_video(quicktime_t *file, unsigned char **row_pointers, int track, int64_t time) { return lqt_encode_video_d(file, row_pointers, track, time, -1); } int lqt_encode_video_d(quicktime_t *file, unsigned char **row_pointers, int track, int64_t time, int duration) { int result; quicktime_video_map_t * vtrack = &file->vtracks[track]; /* Must set valid timestamp for encoders */ vtrack->timestamp = time; lqt_video_append_timestamp(file, track, time, duration); result = do_encode_video(file, row_pointers, track); if (result) return(result); if(file->io_error) return 1; if(file->vtracks[track].timecode_track) lqt_flush_timecode(file, track, time, 0); file->vtracks[track].current_position++; return 0; } int quicktime_encode_video(quicktime_t *file, unsigned char **row_pointers, int track) { int result; result = lqt_encode_video_d(file, row_pointers, track, file->vtracks[track].timestamp, file->vtracks[track].track->mdia.minf.stbl.stts.default_duration); file->vtracks[track].timestamp += file->vtracks[track].track->mdia.minf.stbl.stts.default_duration; return result; } static int bytes_per_sample(lqt_sample_format_t format) { switch(format) { case LQT_SAMPLE_INT8: case LQT_SAMPLE_UINT8: return 1; break; case LQT_SAMPLE_INT16: return 2; break; case LQT_SAMPLE_INT32: return 4; break; case LQT_SAMPLE_FLOAT: /* Float is ALWAYS machine native */ return sizeof(float); break; case LQT_SAMPLE_DOUBLE: /* Double is ALWAYS machine native */ return sizeof(double); break; case LQT_SAMPLE_UNDEFINED: return 0; } return 0; } /* Decode raw samples */ int lqt_decode_audio_raw(quicktime_t *file, void * output, long samples, int track) { int result; quicktime_audio_map_t * atrack; atrack = &file->atracks[track]; result = atrack->codec->decode_audio(file, output, samples, track); file->atracks[track].current_position += samples; return result; } int lqt_encode_audio_raw(quicktime_t *file, void * input, long samples, int track) { int result; quicktime_audio_map_t * atrack; if(!samples) return 0; atrack = &file->atracks[track]; lqt_start_encoding(file); file->atracks[track].current_position += samples; result = atrack->codec->encode_audio(file, input, samples, track); if(file->io_error) return 0; else return samples; } /* Compatibility function for old decoding API */ static int decode_audio_old(quicktime_t *file, int16_t ** output_i, float ** output_f, long samples, int track) { int result; quicktime_audio_map_t * atrack; atrack = &file->atracks[track]; if(atrack->sample_format == LQT_SAMPLE_UNDEFINED) atrack->codec->decode_audio(file, (void*)0, 0, track); /* (Re)allocate sample buffer */ if(atrack->sample_buffer_alloc < samples) { atrack->sample_buffer_alloc = samples + 1024; atrack->sample_buffer = realloc(atrack->sample_buffer, atrack->sample_buffer_alloc * atrack->channels * bytes_per_sample(atrack->sample_format)); } /* Decode */ result = atrack->codec->decode_audio(file, atrack->sample_buffer, samples, track); /* Convert */ lqt_convert_audio_decode(file, atrack->sample_buffer, output_i, output_f, atrack->channels, samples, atrack->sample_format); return result; } int quicktime_decode_audio(quicktime_t *file, int16_t *output_i, float *output_f, long samples, int channel) { float ** channels_f; int16_t ** channels_i; int quicktime_track, quicktime_channel; int result = 1; quicktime_channel_location(file, &quicktime_track, &quicktime_channel, channel); if(file->atracks[quicktime_track].eof) return 1; if(output_i) { channels_i = calloc(quicktime_track_channels(file, quicktime_track), sizeof(*channels_i)); channels_i[quicktime_channel] = output_i; } else channels_i = (int16_t**)0; if(output_f) { channels_f = calloc(quicktime_track_channels(file, quicktime_track), sizeof(*channels_f)); channels_f[quicktime_channel] = output_f; } else channels_f = (float**)0; result = decode_audio_old(file, channels_i, channels_f, samples, quicktime_track); file->atracks[quicktime_track].current_position += result; if(channels_i) free(channels_i); else if(channels_f) free(channels_f); return ((result < 0) ? 1 : 0); } int lqt_total_channels(quicktime_t *file) { int i = 0, total_channels = 0; for( i=0; i < file->total_atracks; i++ ) { total_channels += file->atracks[i].channels; } return total_channels; } /* * Same as quicktime_decode_audio, but it grabs all channels at * once. Or if you want only some channels you can leave the channels * you don't want = NULL in the poutput array. The poutput arrays * must contain at least lqt_total_channels(file) elements. */ int lqt_decode_audio(quicktime_t *file, int16_t **poutput_i, float **poutput_f, long samples) { int result = 1; int i = 0; int16_t **output_i; float **output_f; int total_tracks = quicktime_audio_tracks(file); int track_channels; if(poutput_i) output_i = poutput_i; else output_i = (int16_t**)0; if(poutput_f) output_f = poutput_f; else output_f = (float**)0; for( i=0; i < total_tracks; i++ ) { track_channels = quicktime_track_channels(file, i); if(file->atracks[i].eof) return 1; result = decode_audio_old(file, output_i, output_f, samples, i); if(output_f) output_f += track_channels; if(output_i) output_i += track_channels; file->atracks[i].current_position += samples; } return result; } int lqt_decode_audio_track(quicktime_t *file, int16_t **poutput_i, float **poutput_f, long samples, int track) { int result = 1; if(file->atracks[track].eof) return 1; result = !decode_audio_old(file, poutput_i, poutput_f, samples, track); file->atracks[track].current_position += samples; return result; } static int encode_audio_old(quicktime_t *file, int16_t **input_i, float **input_f, long samples, int track) { quicktime_audio_map_t * atrack; atrack = &file->atracks[track]; lqt_start_encoding(file); if(!samples) return 0; if(atrack->sample_format == LQT_SAMPLE_UNDEFINED) atrack->codec->encode_audio(file, (void*)0, 0, track); /* (Re)allocate sample buffer */ if(atrack->sample_buffer_alloc < samples) { atrack->sample_buffer_alloc = samples + 1024; atrack->sample_buffer = realloc(atrack->sample_buffer, atrack->sample_buffer_alloc * atrack->channels * bytes_per_sample(atrack->sample_format)); } /* Convert */ lqt_convert_audio_encode(file, input_i, input_f, atrack->sample_buffer, atrack->channels, samples, atrack->sample_format); /* Encode */ file->atracks[track].current_position += samples; return atrack->codec->encode_audio(file, atrack->sample_buffer, samples, track); } int lqt_encode_audio_track(quicktime_t *file, int16_t **input_i, float **input_f, long samples, int track) { int result = 1; result = encode_audio_old(file, input_i, input_f, samples, track); return result; } int quicktime_encode_audio(quicktime_t *file, int16_t **input_i, float **input_f, long samples) { return lqt_encode_audio_track(file, input_i, input_f, samples, 0); } int quicktime_reads_cmodel(quicktime_t *file, int colormodel, int track) { return lqt_colormodel_has_conversion(file->vtracks[track].stream_cmodel, colormodel); } int quicktime_writes_cmodel(quicktime_t *file, int colormodel, int track) { return lqt_colormodel_has_conversion(colormodel, file->vtracks[track].stream_cmodel); } /* Compressors that can only encode a window at a time */ /* need to flush extra data here. */ static int quicktime_flush_acodec(quicktime_t *file, int track) { file->atracks[track].codec->flush(file, track); return 0; } static void quicktime_flush_vcodec(quicktime_t *file, int track) { while(file->vtracks[track].codec->flush(file, track)) ; } int quicktime_codecs_flush(quicktime_t *file) { int result = 0; int i; if(!file->wr) return result; if(file->total_atracks) { for(i = 0; i < file->total_atracks && !result; i++) { quicktime_flush_acodec(file, i); } } if(file->total_vtracks) { for(i = 0; i < file->total_vtracks && !result; i++) { quicktime_flush_vcodec(file, i); } } return result; } /* Copy audio */ int lqt_copy_audio(int16_t ** dst_i, float ** dst_f, int16_t ** src_i, float ** src_f, int dst_pos, int src_pos, int dst_size, int src_size, int num_channels) { int i, j, i_tmp; int samples_to_copy; samples_to_copy = src_size < dst_size ? src_size : dst_size; if(src_i) { for(i = 0; i < num_channels; i++) { if(dst_i && dst_i[i]) /* int -> int */ { memcpy(dst_i[i] + dst_pos, src_i[i] + src_pos, samples_to_copy * sizeof(int16_t)); } if(dst_f && dst_f[i]) /* int -> float */ { for(j = 0; j < samples_to_copy; j++) { dst_f[i][dst_pos + j] = (float)src_i[i][src_pos + j] / 32767.0; } } } } else if(src_f) { for(i = 0; i < num_channels; i++) { if(dst_i && dst_i[i]) /* float -> int */ { for(j = 0; j < samples_to_copy; j++) { i_tmp = (int)(src_f[i][src_pos + j] * 32767.0); if(i_tmp > 32767) i_tmp = 32767; if(i_tmp < -32768) i_tmp = -32768; dst_i[i][dst_pos + j] = i_tmp; } } if(dst_f && dst_f[i]) /* float -> float */ { memcpy(dst_f[i] + dst_pos, src_f[i] + src_pos, samples_to_copy * sizeof(float)); } } } return samples_to_copy; } libquicktime-1.2.4/src/ftab.c0000644000175000017500000000521111511622756012775 00000000000000/******************************************************************************* ftab.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include int quicktime_ftab_init(quicktime_ftab_t *ftab, int font_id, const char * font_name) { ftab->num_fonts = 1; ftab->fonts = calloc(ftab->num_fonts, sizeof(*ftab->fonts)); ftab->fonts[0].font_id = font_id; strcpy(ftab->fonts[0].font_name, font_name); return 0; } int quicktime_ftab_delete(quicktime_ftab_t *ftab) { if(ftab->fonts) free(ftab->fonts); return 0; } void quicktime_ftab_dump(quicktime_ftab_t *ftab) { int i; lqt_dump(" font table (ftab)\n"); lqt_dump(" num_fonts: %d\n", ftab->num_fonts); for(i = 0; i < ftab->num_fonts; i++) { lqt_dump(" Font %d, ID: %d, name: %s\n", i+1, ftab->fonts[i].font_id, ftab->fonts[i].font_name); } } int quicktime_read_ftab(quicktime_t *file, quicktime_ftab_t *ftab) { int i; ftab->num_fonts = quicktime_read_int16(file); ftab->fonts = calloc(ftab->num_fonts, sizeof(*ftab->fonts)); for(i = 0; i < ftab->num_fonts; i++) { ftab->fonts[i].font_id = quicktime_read_int16(file); quicktime_read_pascal(file, ftab->fonts[i].font_name); } return 0; } void quicktime_write_ftab(quicktime_t *file, quicktime_ftab_t *ftab) { int i; quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "ftab"); quicktime_write_int16(file, ftab->num_fonts); for(i = 0; i < ftab->num_fonts; i++) { quicktime_write_int16(file, ftab->fonts[i].font_id); quicktime_write_pascal(file, ftab->fonts[i].font_name); } quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/vrni.c0000644000175000017500000000374611511622757013053 00000000000000/******************************************************************************* vrni.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" int quicktime_vrni_init(quicktime_vrni_t *vrnp) { vrnp->ID = 1; quicktime_nloc_init(&vrnp->nloc); return 0; } int quicktime_vrni_delete(quicktime_vrni_t *vrni) { return 0; } void quicktime_vrni_dump(quicktime_vrni_t *vrni) { lqt_dump(" node id (vrni)\n"); lqt_dump(" id %i\n", vrni->ID); quicktime_nloc_dump(&vrni->nloc); } int quicktime_read_vrni(quicktime_t *file, quicktime_vrni_t *vrni, quicktime_qtatom_t *vrni_atom) { quicktime_qtatom_t leaf_atom; int result = 0; quicktime_qtatom_read_header(file, &leaf_atom); quicktime_read_nloc(file, &vrni->nloc, &leaf_atom); return result; } void quicktime_write_vrni(quicktime_t *file, quicktime_vrni_t *vrni ) { quicktime_qtatom_t atom; quicktime_qtatom_write_header(file, &atom, "vrni", 1); quicktime_write_nloc(file, &vrni->nloc); atom.child_count = 1; quicktime_qtatom_write_footer(file, &atom); } libquicktime-1.2.4/src/dinf.c0000644000175000017500000000420411511622756013002 00000000000000/******************************************************************************* dinf.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" void quicktime_dinf_init(quicktime_dinf_t *dinf) { quicktime_dref_init(&dinf->dref); } void quicktime_dinf_delete(quicktime_dinf_t *dinf) { quicktime_dref_delete(&dinf->dref); } void quicktime_dinf_init_all(quicktime_dinf_t *dinf, lqt_file_type_t type) { quicktime_dref_init_all(&dinf->dref, type); } void quicktime_dinf_dump(quicktime_dinf_t *dinf) { lqt_dump(" data information (dinf)\n"); quicktime_dref_dump(&dinf->dref); } void quicktime_read_dinf(quicktime_t *file, quicktime_dinf_t *dinf, quicktime_atom_t *dinf_atom) { quicktime_atom_t leaf_atom; do { quicktime_atom_read_header(file, &leaf_atom); if(quicktime_atom_is(&leaf_atom, "dref")) { quicktime_read_dref(file, &dinf->dref); } else quicktime_atom_skip(file, &leaf_atom); }while(quicktime_position(file) < dinf_atom->end); } void quicktime_write_dinf(quicktime_t *file, quicktime_dinf_t *dinf) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "dinf"); quicktime_write_dref(file, &dinf->dref); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/colr.c0000644000175000017500000000600211511622756013017 00000000000000/******************************************************************************* colr.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ /* Init, read, write handler for the "colr" (Clean Aperture) atom. */ #include "lqt_private.h" #include void quicktime_colr_init(quicktime_colr_t *colr) { memset(colr, 0, sizeof (*colr)); } void quicktime_colr_delete(quicktime_colr_t *colr) { } void quicktime_colr_dump(quicktime_colr_t *colr) { lqt_dump(" color description (colr)\n"); lqt_dump(" colorParamType %d\n", colr->colorParamType); lqt_dump(" primaries %d\n", colr->primaries); lqt_dump(" transferFunction %d\n", colr->transferFunction); lqt_dump(" matrix %d\n", colr->matrix); } void quicktime_read_colr(quicktime_t *file, quicktime_colr_t *colr) { colr->colorParamType = quicktime_read_int32(file); colr->primaries = quicktime_read_int16(file); colr->transferFunction = quicktime_read_int16(file); colr->matrix = quicktime_read_int16(file); } void quicktime_write_colr(quicktime_t *file, quicktime_colr_t *colr) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "colr"); quicktime_write_int32(file, colr->colorParamType); quicktime_write_int16(file, colr->primaries); quicktime_write_int16(file, colr->transferFunction); quicktime_write_int16(file, colr->matrix); quicktime_atom_write_footer(file, &atom); } int lqt_set_colr(quicktime_t *file, int track, quicktime_colr_t *colr) { quicktime_colr_t *trk_colr; if ((track < 0) || (track >= file->total_vtracks)) return 0; trk_colr = &file->vtracks[track].track->mdia.minf.stbl.stsd.table->colr; *trk_colr = *colr; file->vtracks[track].track->mdia.minf.stbl.stsd.table->has_colr = 1; return 1; } int lqt_get_colr(quicktime_t *file, int track, quicktime_colr_t *colr) { quicktime_colr_t *trk_colr; if ((track < 0) || (track >= file->total_vtracks)) return 0; if (!file->vtracks[track].track->mdia.minf.stbl.stsd.table->has_colr) return 0; trk_colr = &file->vtracks[track].track->mdia.minf.stbl.stsd.table->colr; *colr = *trk_colr; return 1; } libquicktime-1.2.4/src/stsd.c0000644000175000017500000002403211511622757013041 00000000000000/******************************************************************************* stsd.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include #define LOG_DOMAIN "stsd" /* Tape name in timecode track */ #define TCMI_NAME "Untitled" void quicktime_stsd_init(quicktime_stsd_t *stsd) { stsd->version = 0; stsd->flags = 0; stsd->total_entries = 0; } void quicktime_stsd_init_table(quicktime_stsd_t *stsd) { if(!stsd->total_entries) { stsd->total_entries = 1; stsd->table = (quicktime_stsd_table_t*)calloc(1, sizeof(quicktime_stsd_table_t) * stsd->total_entries); quicktime_stsd_table_init(&stsd->table[0]); } } int quicktime_stsd_init_qtvr(quicktime_t *file, quicktime_stsd_t *stsd, int track_type) { quicktime_stsd_table_t *table; quicktime_stsd_init_table(stsd); table = &stsd->table[0]; switch(track_type) { case QTVR_OBJ: case QTVR_PAN: table->format[0] = '\0'; table->format[1] = '\0'; table->format[2] = '\0'; table->format[3] = '\0'; break; case QTVR_QTVR_OBJ: case QTVR_QTVR_PAN: table->format[0] = 'q'; table->format[1] = 't'; table->format[2] = 'v'; table->format[3] = 'r'; break; default: lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "quicktime_stsd_init_qtvr invalid track type supplied."); return -1; } return 0; } void quicktime_stsd_init_panorama(quicktime_t *file, quicktime_stsd_t *stsd, int width, int height) { quicktime_stsd_table_t *table; quicktime_stsd_init_table(stsd); table = &stsd->table[0]; table->format[0] = 'p'; table->format[1] = 'a'; table->format[2] = 'n'; table->format[3] = 'o'; table->pano.SWidth = width; table->pano.SHeight = height; } void quicktime_stsd_set_video_codec(quicktime_stsd_t *stsd, char * compression) { quicktime_stsd_table_t *table; table = &stsd->table[0]; quicktime_copy_char32(table->format, compression); } void quicktime_stsd_init_video(quicktime_t *file, quicktime_stsd_t *stsd, int frame_w, int frame_h, char * compression) { quicktime_stsd_table_t *table; quicktime_stsd_init_table(stsd); table = &stsd->table[0]; if(compression) quicktime_stsd_set_video_codec(stsd, compression); table->width = frame_w; table->height = frame_h; table->frames_per_sample = 1; table->depth = 24; table->ctab_id = 65535; } void quicktime_stsd_set_audio_codec(quicktime_stsd_t *stsd, char * compressor) { quicktime_stsd_table_t *table; table = &stsd->table[0]; quicktime_copy_char32(table->format, compressor); quicktime_copy_char32(table->wave.frma.codec, compressor); } void quicktime_stsd_init_audio(quicktime_t *file, quicktime_stsd_t *stsd, int channels, int sample_rate, int bits, char *compressor) { quicktime_stsd_table_t *table; quicktime_stsd_init_table(stsd); table = &stsd->table[0]; if(compressor) quicktime_stsd_set_audio_codec(stsd, compressor); table->channels = channels; table->sample_size = bits; table->samplerate = sample_rate; } void quicktime_stsd_init_text(quicktime_t *file, quicktime_stsd_t *stsd) { quicktime_stsd_table_t *table; quicktime_stsd_text_t * text; quicktime_stsd_init_table(stsd); table = &stsd->table[0]; table->format[0] = 't'; table->format[1] = 'e'; table->format[2] = 'x'; table->format[3] = 't'; text = &table->text; text->displayFlags = 0; text->textJustification = 1; text->bgColor[0] = 0; text->bgColor[1] = 0; text->bgColor[2] = 0; text->defaultTextBox[0] = 0; text->defaultTextBox[1] = 0; text->defaultTextBox[2] = 0; text->defaultTextBox[3] = 0; text->scrpStartChar = 0; text->scrpHeight = 16; text->scrpFont = 0; text->scrpFace = 0; text->scrpSize = 12; text->scrpColor[0] = 65535; text->scrpColor[1] = 65535; text->scrpColor[2] = 65535; strcpy(text->font_name, "Sans-Serif"); } void quicktime_stsd_init_tx3g(quicktime_t *file, quicktime_stsd_t *stsd) { quicktime_stsd_table_t *table; quicktime_stsd_tx3g_t *tx3g; quicktime_stsd_init_table(stsd); table = &stsd->table[0]; table->format[0] = 't'; table->format[1] = 'x'; table->format[2] = '3'; table->format[3] = 'g'; tx3g = &table->tx3g; tx3g->horizontal_justification = 1; tx3g->vertical_justification = 255; tx3g->back_color[0] = 0; tx3g->back_color[1] = 0; tx3g->back_color[2] = 0; tx3g->back_color[3] = 0; tx3g->defaultTextBox[0] = 0; tx3g->defaultTextBox[1] = 0; tx3g->defaultTextBox[2] = 0; tx3g->defaultTextBox[3] = 0; tx3g->start_char_offset = 0; tx3g->end_char_offset = 0; tx3g->font_id = 1; tx3g->style_flags = 0; tx3g->font_size = 12; tx3g->text_color[0] = 255; tx3g->text_color[1] = 255; tx3g->text_color[2] = 255; tx3g->text_color[3] = 255; quicktime_ftab_init(&tx3g->ftab, 1, "Sans-Serif"); tx3g->has_ftab = 1; } void quicktime_stsd_init_timecode(quicktime_t *file, quicktime_stsd_t *stsd, int timescale, int frameduration, int numframes, uint32_t flags) { quicktime_stsd_table_t *table; quicktime_stsd_init_table(stsd); table = &stsd->table[0]; table->format[0] = 't'; table->format[1] = 'm'; table->format[2] = 'c'; table->format[3] = 'd'; table->tmcd.timescale = timescale; table->tmcd.frameduration = frameduration; table->tmcd.numframes = numframes; table->tmcd.flags = flags; table->tmcd.name = strdup(TCMI_NAME); } void quicktime_stsd_delete(quicktime_stsd_t *stsd) { int i; if(stsd->total_entries) { for(i = 0; i < stsd->total_entries; i++) quicktime_stsd_table_delete(&stsd->table[i]); free(stsd->table); } stsd->total_entries = 0; } void quicktime_stsd_dump(void *minf_ptr, quicktime_stsd_t *stsd) { int i; lqt_dump(" sample description (stsd)\n"); lqt_dump(" version %d\n", stsd->version); lqt_dump(" flags %ld\n", stsd->flags); lqt_dump(" total_entries %ld\n", stsd->total_entries); for(i = 0; i < stsd->total_entries; i++) { quicktime_stsd_table_dump(minf_ptr, &stsd->table[i]); } } void quicktime_read_stsd(quicktime_t *file, quicktime_stsd_t *stsd) { int i; stsd->version = quicktime_read_char(file); stsd->flags = quicktime_read_int24(file); stsd->total_entries = quicktime_read_int32(file); stsd->table = calloc(stsd->total_entries, sizeof(quicktime_stsd_table_t)); for(i = 0; i < stsd->total_entries; i++) { quicktime_read_stsd_table_raw(file, &stsd->table[i]); } } void quicktime_finalize_stsd(quicktime_t * file, quicktime_trak_t * trak, quicktime_stsd_t * stsd) { int64_t old_preload_size; uint8_t *old_preload_buffer; int64_t old_preload_start; int64_t old_preload_end; int64_t old_preload_ptr; int64_t old_position; int i; /* Save old buffers from the file */ old_preload_size = file->preload_size; old_preload_buffer = file->preload_buffer; old_preload_start = file->preload_start; old_preload_end = file->preload_end; old_preload_ptr = file->preload_ptr; old_position = quicktime_position(file); for(i = 0; i < stsd->total_entries; i++) { quicktime_stsd_table_init(&stsd->table[i]); quicktime_set_position(file, 0); file->preload_size = stsd->table[i].table_raw_size; file->preload_buffer = stsd->table[i].table_raw; file->preload_start = 0; file->preload_end = file->preload_start + stsd->table[i].table_raw_size; file->preload_ptr = 0; quicktime_read_stsd_table(file, &trak->mdia.minf, &stsd->table[i]); if(trak->mdia.minf.is_video && !stsd->table[i].width && !stsd->table[i].height) { stsd->table[i].width = (int)(trak->tkhd.track_width); stsd->table[i].height = (int)(trak->tkhd.track_height); } } file->preload_size = old_preload_size; file->preload_buffer = old_preload_buffer; file->preload_start = old_preload_start; file->preload_end = old_preload_end; file->preload_ptr = old_preload_ptr; quicktime_set_position(file, old_position); } void quicktime_write_stsd(quicktime_t *file, quicktime_minf_t *minf, quicktime_stsd_t *stsd) { quicktime_atom_t atom; int i; quicktime_atom_write_header(file, &atom, "stsd"); quicktime_write_char(file, stsd->version); quicktime_write_int24(file, stsd->flags); quicktime_write_int32(file, stsd->total_entries); for(i = 0; i < stsd->total_entries; i++) { quicktime_write_stsd_table(file, minf, stsd->table); } quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/tcmi.c0000644000175000017500000000664511511622757013032 00000000000000/******************************************************************************* tcmi.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" void quicktime_tcmi_init(quicktime_tcmi_t *tcmi) { tcmi->version = 0; tcmi->flags = 1; tcmi->font = 0; tcmi->face = 0; tcmi->size = 12; tcmi->fontname[0] = 'S'; tcmi->fontname[1] = 'y'; tcmi->fontname[2] = 's'; tcmi->fontname[3] = 't'; tcmi->fontname[4] = 'e'; tcmi->fontname[5] = 'm'; tcmi->txtcolor[0] = 65535; tcmi->txtcolor[1] = 65535; tcmi->txtcolor[2] = 65535; tcmi->bgcolor[0] = 0; tcmi->bgcolor[1] = 0; tcmi->bgcolor[2] = 0; } void quicktime_tcmi_delete(quicktime_tcmi_t *tcmi) { } void quicktime_tcmi_dump(quicktime_tcmi_t *tcmi) { lqt_dump(" Timecode media info (tcmi)\n"); lqt_dump(" version %d\n", tcmi->version); lqt_dump(" flags %ld\n", tcmi->flags); lqt_dump(" font %d\n", tcmi->font); lqt_dump(" face %d\n", tcmi->face); lqt_dump(" size %d\n", tcmi->size); lqt_dump(" txtcolor %d %d %d\n", tcmi->txtcolor[0], tcmi->txtcolor[1], tcmi->txtcolor[2]); lqt_dump(" bgcolor %d %d %d\n", tcmi->bgcolor[0], tcmi->bgcolor[1], tcmi->bgcolor[2]); lqt_dump(" fontname %s\n", tcmi->fontname); } void quicktime_read_tcmi(quicktime_t *file, quicktime_tcmi_t *tcmi) { int i; tcmi->version = quicktime_read_char(file); tcmi->flags = quicktime_read_int24(file); tcmi->font = quicktime_read_int16(file); tcmi->face = quicktime_read_int16(file); tcmi->size = quicktime_read_int16(file); quicktime_read_int16(file); for (i = 0; i < 3; ++i) tcmi->txtcolor[i] = quicktime_read_int16(file); for (i = 0; i < 3; ++i) tcmi->bgcolor[i] = quicktime_read_int16(file); quicktime_read_pascal(file, tcmi->fontname); } void quicktime_write_tcmi(quicktime_t *file, quicktime_tcmi_t *tcmi) { quicktime_atom_t atom; int i; quicktime_atom_write_header(file, &atom, "tcmi"); quicktime_write_char(file, tcmi->version); quicktime_write_int24(file, tcmi->flags); quicktime_write_int16(file, tcmi->font); quicktime_write_int16(file, tcmi->face); quicktime_write_int16(file, tcmi->size); quicktime_write_int16(file, 0); for (i = 0; i < 3; ++i) quicktime_write_int16(file, tcmi->txtcolor[i]); for (i = 0; i < 3; ++i) quicktime_write_int16(file, tcmi->bgcolor[i]); quicktime_write_pascal(file, tcmi->fontname); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/lqt_divx.c0000644000175000017500000001457311511622756013726 00000000000000/******************************************************************************* lqt_divx.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" // Determine of the compressed frame is a keyframe for direct copy int quicktime_divx_is_key(unsigned char *data, long size) { int result = 0; int i; for(i = 0; i < size - 5; i++) { if( data[i] == 0x00 && data[i + 1] == 0x00 && data[i + 2] == 0x01 && data[i + 3] == 0xb6) { if((data[i + 4] & 0xc0) == 0x0) return 1; else return 0; } } return result; } // Test for VOL header in frame int quicktime_divx_has_vol(unsigned char *data) { if( data[0] == 0x00 && data[1] == 0x00 && data[2] == 0x01 && data[3] == 0x00 && data[4] == 0x00 && data[5] == 0x00 && data[6] == 0x01 && data[7] == 0x20) return 1; else return 0; } static void putbits(unsigned char **data, int *bit_pos, uint64_t *bit_store, int *total, int count, uint64_t value) { value &= 0xffffffffffffffffLL >> (64 - count); while(64 - *bit_pos < count) { *(*data)++ = (*bit_store) >> 56; (*bit_store) <<= 8; (*bit_pos) -= 8; } (*bit_store) |= value << (64 - count - *bit_pos); (*bit_pos) += count; (*total) += count; } static void flushbits(unsigned char **data, int *bit_pos, uint64_t *bit_store) { while((*bit_pos) > 0) { *(*data)++ = (*bit_store) >> 56; (*bit_store) <<= 8; (*bit_pos) -= 8; } } #define VO_START_CODE 0x8 #define VO_START_CODE_LENGTH 27 #define VOL_START_CODE 0x12 /* 25-MAR-97 JDL : according to WD2 */ #define VOL_START_CODE_LENGTH 28 int quicktime_divx_write_vol(unsigned char *data_start, int vol_width, int vol_height, int time_increment_resolution, double frame_rate) { int written = 0; int bits, fixed_vop_time_increment; unsigned char *data = data_start; int bit_pos; uint64_t bit_store; bit_store = 0; bit_pos = 0; vol_width = (int)((float)vol_width / 16 + 0.5) * 16; vol_height = (int)((float)vol_height / 16 + 0.5) * 16; putbits(&data, &bit_pos, &bit_store, &written, VO_START_CODE_LENGTH, VO_START_CODE); putbits(&data, &bit_pos, &bit_store, &written, 5, 0); /* vo_id = 0 */ putbits(&data, &bit_pos, &bit_store, &written, VOL_START_CODE_LENGTH, VOL_START_CODE); putbits(&data, &bit_pos, &bit_store, &written, 4, 0); /* vol_id = 0 */ putbits(&data, &bit_pos, &bit_store, &written, 1, 0); /* random_accessible_vol = 0 */ putbits(&data, &bit_pos, &bit_store, &written, 8, 1); /* video_object_type_indication = 1 video */ putbits(&data, &bit_pos, &bit_store, &written, 1, 1); /* is_object_layer_identifier = 1 */ putbits(&data, &bit_pos, &bit_store, &written, 4, 2); /* visual_object_layer_ver_id = 2 */ putbits(&data, &bit_pos, &bit_store, &written, 3, 1); /* visual_object_layer_priority = 1 */ putbits(&data, &bit_pos, &bit_store, &written, 4, 1); /* aspect_ratio_info = 1 */ putbits(&data, &bit_pos, &bit_store, &written, 1, 0); /* vol_control_parameter = 0 */ putbits(&data, &bit_pos, &bit_store, &written, 2, 0); /* vol_shape = 0 rectangular */ putbits(&data, &bit_pos, &bit_store, &written, 1, 1); /* marker */ putbits(&data, &bit_pos, &bit_store, &written, 16, time_increment_resolution); putbits(&data, &bit_pos, &bit_store, &written, 1, 1); /* marker */ putbits(&data, &bit_pos, &bit_store, &written, 1, 1); /* fixed_vop_rate = 1 */ bits = 1; while((1 << bits) < time_increment_resolution) bits++; // Log calculation fails for some reason // bits = (int)ceil(log((double)time_increment_resolution) / log(2.0)); // if (bits < 1) bits=1; fixed_vop_time_increment = (int)(time_increment_resolution / frame_rate + 0.1); putbits(&data, &bit_pos, &bit_store, &written, bits, fixed_vop_time_increment); putbits(&data, &bit_pos, &bit_store, &written, 1, 1); /* marker */ putbits(&data, &bit_pos, &bit_store, &written, 13, vol_width); putbits(&data, &bit_pos, &bit_store, &written, 1, 1); /* marker */ putbits(&data, &bit_pos, &bit_store, &written, 13, vol_height); putbits(&data, &bit_pos, &bit_store, &written, 1, 1); /* marker */ putbits(&data, &bit_pos, &bit_store, &written, 1, 0); /* interlaced = 0 */ putbits(&data, &bit_pos, &bit_store, &written, 1, 1); /* OBMC_disabled = 1 */ putbits(&data, &bit_pos, &bit_store, &written, 2, 0); /* vol_sprite_usage = 0 */ putbits(&data, &bit_pos, &bit_store, &written, 1, 0); /* not_8_bit = 0 */ putbits(&data, &bit_pos, &bit_store, &written, 1, 0); /* vol_quant_type = 0 */ putbits(&data, &bit_pos, &bit_store, &written, 1, 0); /* vol_quarter_pixel = 0 */ putbits(&data, &bit_pos, &bit_store, &written, 1, 1); /* complexity_estimation_disabled = 1 */ putbits(&data, &bit_pos, &bit_store, &written, 1, 1); /* resync_marker_disabled = 1 */ putbits(&data, &bit_pos, &bit_store, &written, 1, 0); /* data_partitioning_enabled = 0 */ putbits(&data, &bit_pos, &bit_store, &written, 1, 0); /* scalability = 0 */ flushbits(&data, &bit_pos, &bit_store); return data - data_start; } libquicktime-1.2.4/src/lqt_codecfile.c0000644000175000017500000006721111604621437014664 00000000000000/******************************************************************************* lqt_codecfile.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. Modified by Napoleon E. Cornejo May 4, 2007, San Salvador, El Salvador - Validated user home directory in create_filename() 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 *******************************************************************************/ /* * Codec file handling */ #include "lqt_private.h" #include "lqt_codecinfo_private.h" #include #include #include #include #include #define LOG_DOMAIN "codecfile" /* * The keywords are defined globaly, so they are automatically * the same in reading and writing functions */ static const char * begin_codec_key = "BeginCodec: "; static const char * end_codec_key = "EndCodec"; /* * Start string for parameter definition: * These 2 strings (for en- and decoding MUST have the same length) */ static const char * begin_parameter_e_key = "BeginParameterE: "; static const char * begin_parameter_d_key = "BeginParameterD: "; static const char * end_parameter_key = "EndParameter"; static const char * long_name_key = "LongName: "; static const char * description_key = "Description: "; static const char * type_key = "Type: "; /* Types for codecs */ static const char * type_audio = "Audio"; static const char * type_video = "Video"; /* Codec direction */ static const char * direction_key = "Direction: "; static const char * direction_encode = "Encode"; static const char * direction_decode = "Decode"; static const char * direction_both = "Both"; static const char * num_fourccs_key = "NumFourccs: "; static const char * fourccs_key = "Fourccs: "; static const char * num_wav_ids_key = "NumWavIds: "; static const char * wav_ids_key = "WavIds: "; static const char * compatibility_key = "Compatibility: "; static const char * compression_id_key = "CompressionID: "; /* Module filename and module index */ static const char * module_filename_key = "ModuleFilename: "; static const char * module_index_key = "ModuleIndex: "; static const char * module_file_time_key = "FileTime: "; static const char * gettext_domain_key = "GettextDomain"; static const char * gettext_directory_key = "GettextDirectory"; /* Types for parameters */ static const char * type_int = "Integer"; static const char * type_float = "Float"; static const char * type_string = "String"; static const char * type_stringlist = "Stringlist"; static const char * type_section = "Section"; static const char * help_string_key = "HelpString: "; static const char * num_digits_key = "NumDigits"; static const char * num_encoding_parameters_key = "NumEncodingParameters: "; static const char * num_decoding_parameters_key = "NumDecodingParameters: "; static const char * value_key = "Value: "; static const char * min_value_key = "ValueMin: "; static const char * max_value_key = "ValueMax: "; static const char * real_name_key = "RealName: "; static const char * num_options_key = "NumOptions: "; static const char * option_key = "Options: "; static const char * label_key = "OptionLabels: "; /* Encoding colormodels */ static const char * num_encoding_colormodels_key = "NumEncodingColormodels: "; static const char * encoding_colormodel_key = "EncodingColormodel: "; static const char * num_image_sizes_key = "NumImageSizes: "; static const char * image_size_key = "ImageSize: "; /* Codec order */ static const char * audio_order_key = "AudioOrder: "; static const char * video_order_key = "VideoOrder: "; #define READ_BUFFER_SIZE 2048 #define CHECK_KEYWORD(key) (!strncmp(line, key, strlen(key))) static char * create_filename() { char * filename_buffer; /* Obtain the home directory */ char * fdir; /* First look for a system-wide codec file if available. If not look into users home */ fdir = getenv("LQT_CODEC_FILE"); if (fdir == NULL ) { lqt_log(NULL, LQT_LOG_DEBUG, LOG_DOMAIN, "no system-wide codec file. Looking in user's home."); fdir = getenv("HOME"); if(!fdir) return NULL; filename_buffer = malloc(strlen(fdir) + 22); strcpy(filename_buffer, fdir); strcat(filename_buffer, "/.libquicktime_codecs"); } else { filename_buffer = malloc(strlen(fdir) + 1); strcpy(filename_buffer, fdir); } return filename_buffer; } static char * __lqt_strdup(const char * string) { char * ret = malloc(strlen(string)+1); strcpy(ret, string); return ret; } static void read_parameter_value(char * pos, lqt_parameter_value_t * ret, lqt_parameter_type_t type) { switch(type) { case LQT_PARAMETER_INT: ret->val_int = atoi(pos); break; case LQT_PARAMETER_FLOAT: ret->val_float = strtod(pos, (char**)0); break; case LQT_PARAMETER_STRING: case LQT_PARAMETER_STRINGLIST: ret->val_string = __lqt_strdup(pos); break; case LQT_PARAMETER_SECTION: break; } } static char * convert_help_string(char * str) { char * ret; char * src_pos, *dst_pos; ret = malloc(strlen(str)+1); src_pos = str; dst_pos = ret; while(*src_pos != '\0') { if((src_pos[0] == '\\') && (src_pos[1] == 'n')) { *dst_pos = '\n'; src_pos += 2; dst_pos++; } else { *dst_pos = *src_pos; src_pos++; dst_pos++; } } *dst_pos = '\0'; free(str); return ret; } static void read_parameter_info(FILE * input, lqt_parameter_info_t * info, char * line) { char * pos; int options_read = 0; int labels_read = 0; /* First, get the name */ pos = line + strlen(begin_parameter_e_key); info->name = __lqt_strdup(pos); while(1) { fgets(line, READ_BUFFER_SIZE-1, input); if(feof(input)) break; pos = strchr(line, '\n'); if(pos) *pos = '\0'; /* Now, go through the syntax */ if(CHECK_KEYWORD(type_key)) { pos = line + strlen(type_key); if(!strcmp(pos, type_int)) { info->type = LQT_PARAMETER_INT; /* * We set them here for the case, they are not set after * (which can happen for min and max) */ info->val_default.val_int = 0; info->val_min.val_int = 0; info->val_max.val_int = 0; } if(!strcmp(pos, type_float)) { info->type = LQT_PARAMETER_FLOAT; /* * We set them here for the case, they are not set after * (which can happen for min and max) */ info->val_default.val_float = 0; info->val_min.val_float = 0; info->val_max.val_float = 0; info->num_digits = 1; } /* * Important: type_stringlist must be checked * BEFORE type_string */ else if(!strcmp(pos, type_stringlist)) { info->type = LQT_PARAMETER_STRINGLIST; info->val_default.val_string = (char*)0; } else if(!strcmp(pos, type_string)) { info->type = LQT_PARAMETER_STRING; info->val_default.val_string = (char*)0; } else if(!strcmp(pos, type_section)) { info->type = LQT_PARAMETER_SECTION; info->val_default.val_string = (char*)0; } } else if(CHECK_KEYWORD(real_name_key)) { pos = line + strlen(real_name_key); info->real_name = __lqt_strdup(pos); } else if(CHECK_KEYWORD(value_key)) { pos = line + strlen(value_key); read_parameter_value(pos, &info->val_default, info->type); } else if(CHECK_KEYWORD(min_value_key)) { pos = line + strlen(min_value_key); if(info->type == LQT_PARAMETER_INT) info->val_min.val_int = atoi(pos); else if(info->type == LQT_PARAMETER_FLOAT) info->val_min.val_float = strtod(pos, (char**)0); } else if(CHECK_KEYWORD(max_value_key)) { pos = line + strlen(max_value_key); if(info->type == LQT_PARAMETER_INT) info->val_max.val_int = atoi(pos); else if(info->type == LQT_PARAMETER_FLOAT) info->val_max.val_float = strtod(pos, (char**)0); } else if(CHECK_KEYWORD(num_options_key)) { pos = line + strlen(num_options_key); info->num_stringlist_options = atoi(pos); info->stringlist_options = calloc(info->num_stringlist_options, sizeof(char*)); info->stringlist_labels = calloc(info->num_stringlist_options, sizeof(char*)); } else if(CHECK_KEYWORD(option_key)) { pos = line + strlen(option_key); info->stringlist_options[options_read] = __lqt_strdup(pos); options_read++; } else if(CHECK_KEYWORD(label_key)) { pos = line + strlen(label_key); info->stringlist_labels[labels_read] = __lqt_strdup(pos); labels_read++; } else if(CHECK_KEYWORD(help_string_key)) { pos = line + strlen(help_string_key); info->help_string = __lqt_strdup(pos); info->help_string = convert_help_string(info->help_string); } else if(CHECK_KEYWORD(num_digits_key)) { pos = line + strlen(num_digits_key); info->num_digits = atoi(pos); } else if(CHECK_KEYWORD(end_parameter_key)) break; } } static void read_codec_info(FILE * input, lqt_codec_info_t * codec, char * line) { char * pos, *rest; int i; int encoding_parameters_read = 0; int decoding_parameters_read = 0; int encoding_colormodels_read = 0; int image_sizes_read = 0; uint32_t tmp_fourcc; /* First, get the name */ pos = line + strlen(begin_codec_key); codec->name = __lqt_strdup(pos); while(1) { fgets(line, READ_BUFFER_SIZE-1, input); if(feof(input)) break; pos = strchr(line, '\n'); if(pos) *pos = '\0'; /* Long name */ if(CHECK_KEYWORD(long_name_key)) { pos = line + strlen(long_name_key); codec->long_name = __lqt_strdup(pos); } /* Description */ else if(CHECK_KEYWORD(description_key)) { pos = line + strlen(description_key); codec->description = __lqt_strdup(pos); } /* Type */ else if(CHECK_KEYWORD(type_key)) { pos = line + strlen(type_key); if(!strcmp(pos, type_audio)) codec->type = LQT_CODEC_AUDIO; else if(!strcmp(pos, type_video)) codec->type = LQT_CODEC_VIDEO; } /* Compression ID */ else if(CHECK_KEYWORD(compression_id_key)) { pos = line + strlen(compression_id_key); codec->compression_id = lqt_compression_id_from_string(pos); } /* Direction */ else if(CHECK_KEYWORD(direction_key)) { pos = line + strlen(direction_key); if(!strcmp(pos, direction_encode)) codec->direction = LQT_DIRECTION_ENCODE; else if(!strcmp(pos, direction_decode)) codec->direction = LQT_DIRECTION_DECODE; else if(!strcmp(pos, direction_both)) codec->direction = LQT_DIRECTION_BOTH; } /* Compatibility flags */ else if(CHECK_KEYWORD(compatibility_key)) { pos = line + strlen(compatibility_key); codec->compatibility_flags = strtoul(pos, (char**)0, 16); } /* Module filename */ else if(CHECK_KEYWORD(module_filename_key)) { pos = line + strlen(module_filename_key); codec->module_filename = __lqt_strdup(pos); } /* Gettext domain */ else if(CHECK_KEYWORD(gettext_domain_key)) { pos = line + strlen(gettext_domain_key); codec->gettext_domain = __lqt_strdup(pos); } /* Gettext directory */ else if(CHECK_KEYWORD(gettext_directory_key)) { pos = line + strlen(gettext_directory_key); codec->gettext_directory = __lqt_strdup(pos); } /* Module Index */ else if(CHECK_KEYWORD(module_index_key)) { pos = line + strlen(module_index_key); codec->module_index = atoi(pos); } /* File modification time */ else if(CHECK_KEYWORD(module_file_time_key)) { pos = line + strlen(module_file_time_key); codec->file_time = strtoul(pos, (char**)0, 10); } /* Number of Fourccs */ else if(CHECK_KEYWORD(num_fourccs_key)) { pos = line + strlen(num_fourccs_key); codec->num_fourccs = atoi(pos); /* We allocate memory here */ if(codec->num_fourccs) { codec->fourccs = malloc(codec->num_fourccs * sizeof(char*)); for(i = 0; i < codec->num_fourccs; i++) codec->fourccs[i] = malloc(5 * sizeof(char)); } } /* Fourccs */ else if(CHECK_KEYWORD(fourccs_key)) { pos = line + strlen(fourccs_key); for(i = 0; i < codec->num_fourccs; i++) { tmp_fourcc = strtoul(pos, &rest, 16); LQT_FOURCC_2_STRING(codec->fourccs[i], tmp_fourcc); if(rest == pos) break; pos = rest; } } /* Number of wav ids */ else if(CHECK_KEYWORD(num_wav_ids_key)) { pos = line + strlen(num_wav_ids_key); codec->num_wav_ids = atoi(pos); /* We allocate memory here */ codec->wav_ids = malloc(codec->num_wav_ids * sizeof(int)); } /* Wav ids */ else if(CHECK_KEYWORD(wav_ids_key)) { pos = line + strlen(wav_ids_key); for(i = 0; i < codec->num_wav_ids; i++) { codec->wav_ids[i] = strtoul(pos, &rest, 16); pos = rest; } } /* Number of encoding colormodels */ else if(CHECK_KEYWORD(num_encoding_colormodels_key)) { pos = line + strlen(num_encoding_colormodels_key); codec->num_encoding_colormodels = atoi(pos); if(codec->num_encoding_colormodels) { codec->encoding_colormodels = malloc((codec->num_encoding_colormodels+1) * sizeof(*codec->encoding_colormodels)); /* terminate */ codec->encoding_colormodels[codec->num_encoding_colormodels] = LQT_COLORMODEL_NONE; } else codec->encoding_colormodels = (int*)0; } /* Encoding colormodels */ else if(CHECK_KEYWORD(encoding_colormodel_key)) { pos = line + strlen(encoding_colormodel_key); codec->encoding_colormodels[encoding_colormodels_read] = lqt_string_to_colormodel(pos); encoding_colormodels_read++; } /* Number of image sizes */ else if(CHECK_KEYWORD(num_image_sizes_key)) { pos = line + strlen(num_image_sizes_key); codec->num_image_sizes = atoi(pos); if(codec->num_image_sizes) codec->image_sizes = malloc(codec->num_image_sizes * sizeof(*codec->image_sizes)); else codec->image_sizes = NULL; } /* Image size */ else if(CHECK_KEYWORD(image_size_key)) { pos = line + strlen(image_size_key); sscanf(pos, "%d %d", &codec->image_sizes[image_sizes_read].width, &codec->image_sizes[image_sizes_read].height); image_sizes_read++; } /* Number of parameters */ else if(CHECK_KEYWORD(num_encoding_parameters_key)) { pos = line + strlen(num_encoding_parameters_key); codec->num_encoding_parameters = atoi(pos); if(codec->num_encoding_parameters) codec->encoding_parameters = calloc(codec->num_encoding_parameters, sizeof(lqt_parameter_info_t)); else codec->encoding_parameters = (lqt_parameter_info_t*)0; } else if(CHECK_KEYWORD(num_decoding_parameters_key)) { pos = line + strlen(num_decoding_parameters_key); codec->num_decoding_parameters = atoi(pos); if(codec->num_decoding_parameters) codec->decoding_parameters = calloc(codec->num_decoding_parameters, sizeof(lqt_parameter_info_t)); else codec->decoding_parameters = (lqt_parameter_info_t*)0; } /* Read parameters */ else if(CHECK_KEYWORD(begin_parameter_e_key)) { read_parameter_info(input, &codec->encoding_parameters[encoding_parameters_read], line); encoding_parameters_read++; } else if(CHECK_KEYWORD(begin_parameter_d_key)) { read_parameter_info(input, &codec->decoding_parameters[decoding_parameters_read], line); decoding_parameters_read++; } else if(CHECK_KEYWORD(end_codec_key)) break; } } lqt_codec_info_t * lqt_registry_read(char ** audio_order, char ** video_order) { FILE * input; char * line; char * pos = (char*)0; char * filename_buffer = create_filename(); lqt_codec_info_t * ret = (lqt_codec_info_t *)0; lqt_codec_info_t * ret_end = (lqt_codec_info_t *)0; if(!filename_buffer || (*filename_buffer == '\0')) return NULL; input = fopen(filename_buffer, "r"); if(!input) { free(filename_buffer); return (lqt_codec_info_t*)0; } line = malloc(READ_BUFFER_SIZE); while(1) { fgets(line, READ_BUFFER_SIZE-1, input); if(feof(input)) break; pos = strchr(line, '\n'); if(pos) *pos = '\0'; pos = line; /* Skip comment lines */ if(*pos == '#') continue; else if(CHECK_KEYWORD(audio_order_key)) { if(audio_order) { pos += strlen(audio_order_key); *audio_order = __lqt_strdup(pos); } continue; } else if(CHECK_KEYWORD(video_order_key)) { if(video_order) { pos += strlen(video_order_key); *video_order = __lqt_strdup(pos); } continue; } else if(CHECK_KEYWORD(begin_codec_key)) { if(!ret_end) { ret = calloc(1, sizeof(lqt_codec_info_t)); ret_end = ret; } else { ret_end->next = calloc(1, sizeof(lqt_codec_info_t)); ret_end = ret_end->next; } read_codec_info(input, ret_end, pos); ret_end->next = (lqt_codec_info_t*)0; } } fclose(input); free(filename_buffer); free(line); return ret; } static void write_help_string(FILE * output, char * help_string) { int i, imax; fprintf(output, "%s", help_string_key); imax = strlen(help_string); for(i = 0; i < imax; i++) { if(help_string[i] == '\n') fprintf(output, "\\n"); else fprintf(output, "%c", help_string[i]); } fprintf(output, "\n"); } static void write_parameter_info(FILE * output, const lqt_parameter_info_t * info, int encode) { const char * tmp = (const char*)0; int i; fprintf(output, "%s%s\n", (encode ? begin_parameter_e_key : begin_parameter_d_key), info->name); fprintf(output, "%s%s\n", real_name_key, info->real_name); switch(info->type) { case LQT_PARAMETER_INT: tmp = type_int; break; case LQT_PARAMETER_FLOAT: tmp = type_float; break; case LQT_PARAMETER_STRING: tmp = type_string; break; case LQT_PARAMETER_STRINGLIST: tmp = type_stringlist; break; case LQT_PARAMETER_SECTION: tmp = type_section; break; } fprintf(output, "%s%s\n", type_key, tmp); /* * Print the value */ switch(info->type) { case LQT_PARAMETER_INT: fprintf(output, "%s%d\n", value_key, info->val_default.val_int); if(info->val_min.val_int < info->val_max.val_int) { fprintf(output, "%s%d\n", min_value_key, info->val_min.val_int); fprintf(output, "%s%d\n", max_value_key, info->val_max.val_int); } break; case LQT_PARAMETER_FLOAT: fprintf(output, "%s%f\n", value_key, info->val_default.val_float); if(info->val_min.val_float < info->val_max.val_float) { fprintf(output, "%s%f\n", min_value_key, info->val_min.val_float); fprintf(output, "%s%f\n", max_value_key, info->val_max.val_float); } fprintf(output, "%s%d\n", num_digits_key, info->num_digits); break; case LQT_PARAMETER_STRING: fprintf(output, "%s%s\n", value_key, info->val_default.val_string); break; case LQT_PARAMETER_STRINGLIST: fprintf(output, "%s%s\n", value_key, info->val_default.val_string); /* * Print options */ fprintf(output, "%s%d\n", num_options_key, info->num_stringlist_options); for(i = 0; i < info->num_stringlist_options; i++) fprintf(output, "%s%s\n", option_key, info->stringlist_options[i]); for(i = 0; i < info->num_stringlist_options; i++) fprintf(output, "%s%s\n", label_key, info->stringlist_labels[i]); break; case LQT_PARAMETER_SECTION: break; } if(info->help_string) { write_help_string(output, info->help_string); } fprintf(output, "%s\n", end_parameter_key); } /* * Write codec info, return FALSE on error */ static int write_codec_info(const lqt_codec_info_t * info, FILE * output) { const char * tmp; int i; fprintf(output, "%s%s\n", begin_codec_key, info->name); fprintf(output, "%s%s\n", long_name_key, info->long_name); fprintf(output, "%s%s\n", description_key, info->description); tmp = NULL; switch(info->type) { case LQT_CODEC_AUDIO: tmp = type_audio; break; case LQT_CODEC_VIDEO: tmp = type_video; break; } if(tmp) fprintf(output, "%s%s\n", type_key, tmp); if(info->compression_id != LQT_COMPRESSION_NONE) { fprintf(output, "%s%s\n", compression_id_key, lqt_compression_id_to_string(info->compression_id)); } switch(info->direction) { case LQT_DIRECTION_DECODE: tmp = direction_decode; break; case LQT_DIRECTION_ENCODE: tmp = direction_encode; break; case LQT_DIRECTION_BOTH: tmp = direction_both; break; } if(tmp) fprintf(output, "%s%s\n", direction_key, tmp); fprintf(output, "%s%08x\n", compatibility_key, info->compatibility_flags); if(info->num_fourccs) { fprintf(output, "%s%d\n", num_fourccs_key, info->num_fourccs); fprintf(output, "%s", fourccs_key); for(i = 0; i < info->num_fourccs; i++) fprintf(output, "0x%08X ", LQT_STRING_2_FOURCC(info->fourccs[i])); fprintf(output, "\n"); } if(info->num_wav_ids) { fprintf(output, "%s%d\n", num_wav_ids_key, info->num_wav_ids); fprintf(output, "%s", wav_ids_key); for(i = 0; i < info->num_wav_ids; i++) fprintf(output, "0x%02X ", info->wav_ids[i]); fprintf(output, "\n"); } fprintf(output, "%s%d\n", num_encoding_parameters_key, info->num_encoding_parameters); for(i = 0; i < info->num_encoding_parameters; i++) { write_parameter_info(output, &info->encoding_parameters[i], 1); } fprintf(output, "%s%d\n", num_decoding_parameters_key, info->num_decoding_parameters); for(i = 0; i < info->num_decoding_parameters; i++) { write_parameter_info(output, &info->decoding_parameters[i], 0); } if((info->type == LQT_CODEC_VIDEO) && (info->direction != LQT_DIRECTION_DECODE)) { fprintf(output, "%s%d\n", num_encoding_colormodels_key, info->num_encoding_colormodels); for(i = 0; i < info->num_encoding_colormodels; i++) { fprintf(output, "%s%s\n", encoding_colormodel_key, lqt_colormodel_to_string(info->encoding_colormodels[i])); } } if((info->type == LQT_CODEC_VIDEO) && (info->direction != LQT_DIRECTION_DECODE)) { fprintf(output, "%s%d\n", num_image_sizes_key, info->num_image_sizes); for(i = 0; i < info->num_image_sizes; i++) { fprintf(output, "%s%d %d\n", image_size_key, info->image_sizes[i].width, info->image_sizes[i].height); } } /* Module filename and index */ fprintf(output, "%s%s\n", module_filename_key, info->module_filename); fprintf(output, "%s%d\n", module_index_key, info->module_index); fprintf(output, "%s%u\n", module_file_time_key, info->file_time); if(info->gettext_domain) fprintf(output, "%s%s\n", gettext_domain_key, info->gettext_domain); if(info->gettext_directory) fprintf(output, "%s%s\n", gettext_directory_key, info->gettext_directory); if(fprintf(output, "%s\n", end_codec_key) < 0) return 0; return 1; } void lqt_registry_write() { int i; FILE * output; char * filename_buffer = create_filename(); lqt_codec_info_t * codec_info; lqt_registry_lock(); if(!filename_buffer || (*filename_buffer == '\0')) { lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "Codec registry filename could not be generated"); return; } output = fopen(filename_buffer, "w"); if(!output) { lqt_registry_unlock(); free(filename_buffer); return; } /* * Write initial comment */ fprintf(output, "# This is the codec database file for libquicktime\n\ # It is automatically generated and should not be edited.\n\ # If you changed it and your libquicktime program doesn't work\n\ # anymore, delete it, and you will get a new one\n"); /* Write the sort strings */ if(lqt_num_audio_codecs) { codec_info = lqt_audio_codecs; fprintf(output, "%s", audio_order_key); for(i = 0; i < lqt_num_audio_codecs; i++) { fprintf(output, "%s", codec_info->name); if(i == lqt_num_audio_codecs - 1) fprintf(output, "\n"); else fprintf(output, ","); codec_info = codec_info->next; } } if(lqt_num_video_codecs) { codec_info = lqt_video_codecs; fprintf(output, "%s", video_order_key); for(i = 0; i < lqt_num_video_codecs; i++) { fprintf(output, "%s", codec_info->name); if(i == lqt_num_video_codecs - 1) fprintf(output, "\n"); else fprintf(output, ","); codec_info = codec_info->next; } } codec_info = lqt_audio_codecs; for(i = 0; i < lqt_num_audio_codecs; i++) { if(!write_codec_info(codec_info, output)) goto fail; codec_info = codec_info->next; } codec_info = lqt_video_codecs; for(i = 0; i < lqt_num_video_codecs; i++) { if(!write_codec_info(codec_info, output)) goto fail; codec_info = codec_info->next; } fclose(output); lqt_registry_unlock(); free(filename_buffer); return; fail: fclose(output); lqt_registry_unlock(); free(filename_buffer); lqt_log(NULL, LQT_LOG_INFO, LOG_DOMAIN, "%s could not be written, deleting imcomplete file", filename_buffer); remove(filename_buffer); } libquicktime-1.2.4/src/Makefile.am0000644000175000017500000000327111351273205013746 00000000000000localedir = $(datadir)/locale lib_LTLIBRARIES= libquicktime.la AM_CFLAGS = -DLOCALE_DIR=\"$(localedir)\" # # Library dependencies # Maybe we need zlib to read compressed quicktime headers # libquicktime_la_LIBADD = @ICONV_LIBS@ @LTLIBINTL@ libquicktime_la_LDFLAGS = -export-dynamic # build only the files, which can be compiled # Different files for dynamic plugins and others if HAVE_FSEEKO FSEEKO_SRC = else FSEEKO_SRC = lqt_fseeko.c endif lqt_sources = lqt_codecs.c lqt_quicktime.c $(FSEEKO_SRC) # lqt_sources = codecs.c plugin.c quicktime.c libquicktime_la_SOURCES= \ audio.c \ $(lqt_sources) \ atom.c \ avi_avih.c \ avi_guid.c \ avi_hdrl.c \ avi_idx1.c \ avi_info.c \ avi_indx.c \ avi_ix.c \ avi_movi.c \ avi_odml.c \ avi_riff.c \ avi_strf.c \ avi_strh.c \ avi_strl.c \ chan.c \ charset.c \ clap.c \ cmodel_default.c \ cmodel_yuv420p.c \ cmodel_yuv422.c \ colormodels.c \ colr.c \ compression.c \ ctab.c \ ctts.c \ dinf.c \ dref.c \ edts.c \ elst.c \ enda.c \ esds.c \ fiel.c \ frma.c \ ftab.c \ ftyp.c \ gama.c \ gmhd.c \ gmhd_text.c \ gmin.c \ hdlr.c \ imgp.c \ impn.c \ iods.c \ language.c \ log.c \ matrix.c \ mdat.c \ mdhd.c \ mdia.c \ minf.c \ moov.c \ mvhd.c \ multichannel.c \ navg.c \ ndhd.c \ nloc.c \ nmhd.c \ obji.c \ pano.c \ pasp.c \ pdat.c \ pHdr.c \ qtatom.c \ qtvr.c \ smhd.c \ stbl.c \ stco.c \ stsc.c \ stsd.c \ stsdtable.c \ stss.c \ stsz.c \ stts.c \ texttrack.c \ timecode.c \ tkhd.c \ trak.c \ translation.c \ tcmi.c \ tmcd.c \ tref.c \ udta.c \ useratoms.c \ util.c \ vmhd.c \ vrsc.c \ vrnp.c \ vrni.c \ wave.c \ workarounds.c \ lqt_bufalloc.c \ lqt_codecfile.c \ lqt_color.c \ lqt_codecinfo.c \ lqt_divx.c \ lqt_qtvr.c INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include libquicktime-1.2.4/src/dref.c0000644000175000017500000001166211511622756013010 00000000000000/******************************************************************************* dref.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include void quicktime_dref_table_init(quicktime_dref_table_t *table, lqt_file_type_t type) { table->size = 0; if(IS_MP4(type)) { table->type[0] = 'u'; table->type[1] = 'r'; table->type[2] = 'l'; table->type[3] = ' '; } else { table->type[0] = 'a'; table->type[1] = 'l'; table->type[2] = 'i'; table->type[3] = 's'; } table->version = 0; table->flags = 0x0001; table->data_reference = malloc(256); table->data_reference[0] = 0; } void quicktime_dref_table_delete(quicktime_dref_table_t *table) { if(table->data_reference) free(table->data_reference); table->data_reference = 0; } void quicktime_read_dref_table(quicktime_t *file, quicktime_dref_table_t *table) { table->size = quicktime_read_int32(file); quicktime_read_char32(file, table->type); table->version = quicktime_read_char(file); table->flags = quicktime_read_int24(file); if(table->data_reference) free(table->data_reference); table->data_reference = malloc(table->size); if(table->size > 12) quicktime_read_data(file, (uint8_t*)(table->data_reference), table->size - 12); table->data_reference[table->size - 12] = 0; } void quicktime_write_dref_table(quicktime_t *file, quicktime_dref_table_t *table) { int len = strlen(table->data_reference); quicktime_write_int32(file, 12 + len); quicktime_write_char32(file, table->type); quicktime_write_char(file, table->version); quicktime_write_int24(file, table->flags); if(len) quicktime_write_data(file, (uint8_t*)(table->data_reference), len); } void quicktime_dref_table_dump(quicktime_dref_table_t *table) { lqt_dump(" data reference table (dref)\n"); lqt_dump(" type %c%c%c%c\n", table->type[0], table->type[1], table->type[2], table->type[3]); lqt_dump(" version %d\n", table->version); lqt_dump(" flags %ld\n", table->flags); lqt_dump(" data %s\n", table->data_reference); } void quicktime_dref_init(quicktime_dref_t *dref) { dref->version = 0; dref->flags = 0; dref->total_entries = 0; dref->table = 0; } void quicktime_dref_init_all(quicktime_dref_t *dref, lqt_file_type_t type) { if(!dref->total_entries) { dref->total_entries = 1; dref->table = (quicktime_dref_table_t *)malloc(sizeof(quicktime_dref_table_t) * dref->total_entries); quicktime_dref_table_init(&dref->table[0], type); } } void quicktime_dref_delete(quicktime_dref_t *dref) { if(dref->table) { int i; for(i = 0; i < dref->total_entries; i++) quicktime_dref_table_delete(&dref->table[i]); free(dref->table); } dref->total_entries = 0; } void quicktime_dref_dump(quicktime_dref_t *dref) { int i; lqt_dump(" data reference (dref)\n"); lqt_dump(" version %d\n", dref->version); lqt_dump(" flags %ld\n", dref->flags); for(i = 0; i < dref->total_entries; i++) { quicktime_dref_table_dump(&dref->table[i]); } } void quicktime_read_dref(quicktime_t *file, quicktime_dref_t *dref) { int i; dref->version = quicktime_read_char(file); dref->flags = quicktime_read_int24(file); dref->total_entries = quicktime_read_int32(file); dref->table = (quicktime_dref_table_t*)malloc(sizeof(quicktime_dref_table_t) * dref->total_entries); for(i = 0; i < dref->total_entries; i++) { quicktime_dref_table_init(&dref->table[i], file->file_type); quicktime_read_dref_table(file, &dref->table[i]); } } void quicktime_write_dref(quicktime_t *file, quicktime_dref_t *dref) { int i; quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "dref"); quicktime_write_char(file, dref->version); quicktime_write_int24(file, dref->flags); quicktime_write_int32(file, dref->total_entries); for(i = 0; i < dref->total_entries; i++) { quicktime_write_dref_table(file, &dref->table[i]); } quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/stts.c0000644000175000017500000001731111511622757013063 00000000000000/******************************************************************************* stts.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include void quicktime_stts_init(quicktime_stts_t *stts) { stts->version = 0; stts->flags = 0; stts->total_entries = 0; } void quicktime_stts_init_table(quicktime_stts_t *stts) { if(!stts->total_entries) { stts->total_entries = 1; stts->entries_allocated = 1; stts->table = calloc(stts->total_entries, sizeof(*stts->table)); } } void quicktime_stts_init_qtvr(quicktime_t *file, quicktime_stts_t *stts, int frame_duration) { quicktime_stts_table_t *table; quicktime_stts_init_table(stts); table = &stts->table[0]; table->sample_duration = frame_duration; } void quicktime_stts_init_panorama(quicktime_t *file, quicktime_stts_t *stts, int frame_duration) { quicktime_stts_table_t *table; quicktime_stts_init_table(stts); table = &stts->table[0]; table->sample_duration = frame_duration; } void quicktime_stts_init_video(quicktime_t *file, quicktime_stts_t *stts, int frame_duration) { quicktime_stts_table_t *table; quicktime_stts_init_table(stts); table = &stts->table[0]; table->sample_duration = frame_duration; stts->default_duration = frame_duration; } void quicktime_stts_init_audio(quicktime_t *file, quicktime_stts_t *stts, int sample_rate) { quicktime_stts_table_t *table; quicktime_stts_init_table(stts); table = &stts->table[0]; table->sample_duration = 1; } void quicktime_stts_init_timecode(quicktime_t *file, quicktime_stts_t *stts) { quicktime_stts_init_table(stts); } void quicktime_stts_delete(quicktime_stts_t *stts) { if(stts->total_entries) free(stts->table); stts->total_entries = 0; } void quicktime_stts_dump(quicktime_stts_t *stts) { int i; lqt_dump(" time to sample (stts)\n"); lqt_dump(" version %d\n", stts->version); lqt_dump(" flags %ld\n", stts->flags); lqt_dump(" total_entries %ld\n", stts->total_entries); for(i = 0; i < stts->total_entries; i++) { lqt_dump(" count %d duration %d\n", stts->table[i].sample_count, stts->table[i].sample_duration); } } void quicktime_read_stts(quicktime_t *file, quicktime_stts_t *stts) { int i; stts->version = quicktime_read_char(file); stts->flags = quicktime_read_int24(file); stts->total_entries = quicktime_read_int32(file); stts->table = malloc(sizeof(*stts->table) * stts->total_entries); for(i = 0; i < stts->total_entries; i++) { stts->table[i].sample_count = quicktime_read_int32(file); stts->table[i].sample_duration = quicktime_read_int32(file); } } void quicktime_write_stts(quicktime_t *file, quicktime_stts_t *stts) { int i; quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "stts"); quicktime_write_char(file, stts->version); quicktime_write_int24(file, stts->flags); quicktime_write_int32(file, stts->total_entries); for(i = 0; i < stts->total_entries; i++) { quicktime_write_int32(file, stts->table[i].sample_count); quicktime_write_int32(file, stts->table[i].sample_duration); } quicktime_atom_write_footer(file, &atom); } int64_t quicktime_time_to_sample(quicktime_stts_t *stts, int64_t * time, int64_t * stts_index, int64_t * stts_count) { int64_t ret = 0; int64_t time_count = 0; *stts_index = 0; while(1) { if(time_count + stts->table[*stts_index].sample_duration * stts->table[*stts_index].sample_count >= *time) { *stts_count = (*time - time_count) / stts->table[*stts_index].sample_duration; time_count += *stts_count * stts->table[*stts_index].sample_duration; ret += *stts_count; break; } else { time_count += stts->table[*stts_index].sample_duration * stts->table[*stts_index].sample_count; ret += stts->table[*stts_index].sample_count; (*stts_index)++; } if(*stts_index >= stts->total_entries) break; } *time = time_count; return ret; } /* sample = -1 returns the total duration */ int64_t quicktime_sample_to_time(quicktime_stts_t *stts, int64_t sample, int64_t * stts_index, int64_t * stts_count) { int64_t ret = 0; int64_t sample_count; if(sample < 0) { for(*stts_index = 0; *stts_index < stts->total_entries; (*stts_index)++) { ret += stts->table[*stts_index].sample_duration * stts->table[*stts_index].sample_count; } return ret; } *stts_index = 0; // *stts_count = 0; sample_count = 0; while(1) { if(sample_count + stts->table[*stts_index].sample_count > sample) { *stts_count = (sample - sample_count); ret += *stts_count * stts->table[*stts_index].sample_duration; break; } else { sample_count += stts->table[*stts_index].sample_count; ret += stts->table[*stts_index].sample_count * stts->table[*stts_index].sample_duration; (*stts_index)++; } } return ret; } /* If one calls quicktime_update_stts(), the table is set up with one entry per sample. Before writing, call quicktime_compress_stts() to kick out redundant entries */ void quicktime_update_stts(quicktime_stts_t *stts, long sample, long duration) { if(sample >= stts->entries_allocated) { stts->entries_allocated = sample + 1024; stts->table = realloc(stts->table, stts->entries_allocated * sizeof(*(stts->table))); } stts->table[sample].sample_count = 1; if(duration) stts->table[sample].sample_duration = duration; else stts->table[sample].sample_duration = stts->default_duration; if(sample >= stts->total_entries) stts->total_entries = sample + 1; } void quicktime_compress_stts(quicktime_stts_t *stts) { long sample = 0; long i; int compress; if(stts->total_entries <= 1) return; while(sample < stts->total_entries) { i = 1; compress = 0; while(sample + i < stts->total_entries) { if(stts->table[sample + i].sample_duration == stts->table[sample].sample_duration) { stts->table[sample].sample_count += stts->table[sample + i].sample_count; compress++; } else { break; } i++; } if(stts->table[sample].sample_count > 1) { /* Compress */ if(stts->total_entries - sample - i) memmove(&stts->table[sample + 1], &stts->table[sample + i], sizeof(stts->table[sample + i]) * (stts->total_entries - sample - i)); stts->total_entries -= compress; } sample++; } } libquicktime-1.2.4/src/gmhd_text.c0000644000175000017500000000547111511622756014054 00000000000000/******************************************************************************* gmhd_text.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #define LOG_DOMAIN "gmhd_text" /* No idea, what these values mean, they are taken from the hexdump of a Quicktime file. It's not even clear, if they are organized as 32 bit integers or something else :) */ void quicktime_gmhd_text_init(quicktime_gmhd_text_t *gmhd_text) { gmhd_text->unk[0] = 0x00010000; gmhd_text->unk[1] = 0x00000000; gmhd_text->unk[2] = 0x00000000; gmhd_text->unk[3] = 0x00000000; gmhd_text->unk[4] = 0x00010000; gmhd_text->unk[5] = 0x00000000; gmhd_text->unk[6] = 0x00000000; gmhd_text->unk[7] = 0x00000000; gmhd_text->unk[8] = 0x40000000; } void quicktime_gmhd_text_delete(quicktime_gmhd_text_t *gmhd_text) { } void quicktime_gmhd_text_dump(quicktime_gmhd_text_t *gmhd_text) { int i; lqt_dump(" gmhd text atom (no idea what this is)\n"); for(i = 0; i < 9; i++) { lqt_dump(" Unknown %d: 0x%08x\n", i, gmhd_text->unk[i]); } } void quicktime_read_gmhd_text(quicktime_t *file, quicktime_gmhd_text_t *gmhd_text, quicktime_atom_t *parent_atom) { int i; for(i = 0; i < 9; i++) gmhd_text->unk[i] = quicktime_read_int32(file); if(quicktime_position(file) < parent_atom->end) { lqt_log(file, LQT_LOG_WARNING, LOG_DOMAIN, "More than 36 bytes in the gmhd text atom\n"); quicktime_atom_skip(file, parent_atom); } } void quicktime_write_gmhd_text(quicktime_t *file, quicktime_gmhd_text_t *gmhd_text) { int i; quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "text"); for(i = 0; i < 9; i++) { quicktime_write_int32(file, gmhd_text->unk[i]); } quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/chan.c0000644000175000017500000014151311511622756013000 00000000000000/******************************************************************************* chan.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include /* * Quicktime chan atom. * * I didn't find any official documentation about the channel * description atom (which is needed for multichannel support). * There is, however this document about the CAF format by Apple: * * http://developer.apple.com/documentation/MusicAudio/Reference/CAFSpec/index.html * The guess was, that the chan atoms in CAF and Quicktime files are the same, * and the guess turned out to be true :) */ typedef enum { CHANNEL_LABEL_Unknown = 0xFFFFFFFF, // unknown role or uspecified // other use for channel CHANNEL_LABEL_Unused = 0, // channel is present, but // has no intended role or destination CHANNEL_LABEL_UseCoordinates = 100, // channel is described // solely by the mCoordinates fields CHANNEL_LABEL_Left = 1, CHANNEL_LABEL_Right = 2, CHANNEL_LABEL_Center = 3, CHANNEL_LABEL_LFEScreen = 4, CHANNEL_LABEL_LeftSurround = 5, // WAVE (.wav files): "Back Left" CHANNEL_LABEL_RightSurround = 6, // WAVE: "Back Right" CHANNEL_LABEL_LeftCenter = 7, CHANNEL_LABEL_RightCenter = 8, CHANNEL_LABEL_CenterSurround = 9, // WAVE: "Back Center or // plain "Rear Surround" CHANNEL_LABEL_LeftSurroundDirect = 10, // WAVE: "Side Left" CHANNEL_LABEL_RightSurroundDirect = 11, // WAVE: "Side Right" CHANNEL_LABEL_TopCenterSurround = 12, CHANNEL_LABEL_VerticalHeightLeft = 13, // WAVE: "Top Front Left CHANNEL_LABEL_VerticalHeightCenter = 14, // WAVE: "Top Front Center CHANNEL_LABEL_VerticalHeightRight = 15, // WAVE: "Top Front Right CHANNEL_LABEL_TopBackLeft = 16, CHANNEL_LABEL_TopBackCenter = 17, CHANNEL_LABEL_TopBackRight = 18, CHANNEL_LABEL_RearSurroundLeft = 33, CHANNEL_LABEL_RearSurroundRight = 34, CHANNEL_LABEL_LeftWide = 35, CHANNEL_LABEL_RightWide = 36, CHANNEL_LABEL_LFE2 = 37, CHANNEL_LABEL_LeftTotal = 38, // matrix encoded 4 channels CHANNEL_LABEL_RightTotal = 39, // matrix encoded 4 channels CHANNEL_LABEL_HearingImpaired = 40, CHANNEL_LABEL_Narration = 41, CHANNEL_LABEL_Mono = 42, CHANNEL_LABEL_DialogCentricMix = 43, CHANNEL_LABEL_CenterSurroundDirect = 44, // back center, non diffuse // first order ambisonic channels CHANNEL_LABEL_Ambisonic_W = 200, CHANNEL_LABEL_Ambisonic_X = 201, CHANNEL_LABEL_Ambisonic_Y = 202, CHANNEL_LABEL_Ambisonic_Z = 203, // Mid/Side Recording CHANNEL_LABEL_MS_Mid = 204, CHANNEL_LABEL_MS_Side = 205, // X-Y Recording CHANNEL_LABEL_XY_X = 206, CHANNEL_LABEL_XY_Y = 207, // other CHANNEL_LABEL_HeadphonesLeft = 301, CHANNEL_LABEL_HeadphonesRight = 302, CHANNEL_LABEL_ClickTrack = 304, CHANNEL_LABEL_ForeignLanguage = 305 } channel_label_t; static struct { channel_label_t label; char * name; } channel_label_names[] = { { CHANNEL_LABEL_Unknown, "Unknown" }, { CHANNEL_LABEL_Unused, "Unused" }, // has no intended role or destination { CHANNEL_LABEL_UseCoordinates, "Use Coordinates" }, { CHANNEL_LABEL_Left, "Left" }, { CHANNEL_LABEL_Right, "Right" }, { CHANNEL_LABEL_Center, "Center" }, { CHANNEL_LABEL_LFEScreen, "LFE" }, { CHANNEL_LABEL_LeftSurround, "Left Surround" }, // WAVE (.wav files): Back Left { CHANNEL_LABEL_RightSurround, "Right Surround" }, // WAVE: "Back Right" { CHANNEL_LABEL_LeftCenter, "Left Center" }, { CHANNEL_LABEL_RightCenter, "Right Center" }, { CHANNEL_LABEL_CenterSurround, "Center Surround" }, // WAVE: "Back Center or // plain "Rear Surround" { CHANNEL_LABEL_LeftSurroundDirect, "Side Left" }, // WAVE: "Side Left" { CHANNEL_LABEL_RightSurroundDirect, "Side Right" }, // WAVE: "Side Right" { CHANNEL_LABEL_TopCenterSurround, "Top Center Surround" }, { CHANNEL_LABEL_VerticalHeightLeft, "Top Front Left" }, // WAVE: Top Front Left { CHANNEL_LABEL_VerticalHeightCenter, "Top Front Center" }, // WAVE: Top Front Center { CHANNEL_LABEL_VerticalHeightRight, "Top Front Right" }, // WAVE: "Top Front Right" { CHANNEL_LABEL_TopBackLeft, "Top Back Left" }, { CHANNEL_LABEL_TopBackCenter, "Top Back Center" } , { CHANNEL_LABEL_TopBackRight, "Top Back Right" }, { CHANNEL_LABEL_RearSurroundLeft, "Rear Surround Left" }, { CHANNEL_LABEL_RearSurroundRight, "Rear Surround Right" }, { CHANNEL_LABEL_LeftWide, "Left Wide" }, { CHANNEL_LABEL_RightWide, "Right Wide" }, { CHANNEL_LABEL_LFE2, "LFE 2" }, { CHANNEL_LABEL_LeftTotal, "Left Total" }, // matrix encoded 4 channels { CHANNEL_LABEL_RightTotal, "Right Total" }, // matrix encoded 4 channels { CHANNEL_LABEL_HearingImpaired, "Hearing Impaired" }, { CHANNEL_LABEL_Narration, "Narration" }, { CHANNEL_LABEL_Mono, "Mono" }, { CHANNEL_LABEL_DialogCentricMix, "Dialog Centric Mix" }, { CHANNEL_LABEL_CenterSurroundDirect, "Center Surround Direct" }, // back center, non diffuse // first order ambisonic channels { CHANNEL_LABEL_Ambisonic_W, "Ambisonic W" }, { CHANNEL_LABEL_Ambisonic_X, "Ambisonic X" }, { CHANNEL_LABEL_Ambisonic_Y, "Ambisonic Y" }, { CHANNEL_LABEL_Ambisonic_Z, "Ambisonic Z" }, // Mid/Side Recording { CHANNEL_LABEL_MS_Mid, "MS Mid" }, { CHANNEL_LABEL_MS_Side, "MS Side" }, // X-Y Recording { CHANNEL_LABEL_XY_X, "Label XY X" }, { CHANNEL_LABEL_XY_Y, "Label XY Y" }, // other { CHANNEL_LABEL_HeadphonesLeft, "Headphones Left" }, { CHANNEL_LABEL_HeadphonesRight, "Headphones Right" }, { CHANNEL_LABEL_ClickTrack, "Click Track" }, { CHANNEL_LABEL_ForeignLanguage, "Foreign Language" }, }; static const char * get_channel_name(channel_label_t label) { int i; for(i = 0; i < sizeof(channel_label_names)/sizeof(channel_label_names[0]); i++) { if(channel_label_names[i].label == label) return channel_label_names[i].name; } return (char*)0; } typedef enum { CHANNEL_BIT_Left = (1<<0), CHANNEL_BIT_Right = (1<<1), CHANNEL_BIT_Center = (1<<2), CHANNEL_BIT_LFEScreen = (1<<3), CHANNEL_BIT_LeftSurround = (1<<4), // WAVE: "Back Left" CHANNEL_BIT_RightSurround = (1<<5), // WAVE: "Back Right" CHANNEL_BIT_LeftCenter = (1<<6), CHANNEL_BIT_RightCenter = (1<<7), CHANNEL_BIT_CenterSurround = (1<<8), // WAVE: "Back Center" CHANNEL_BIT_LeftSurroundDirect = (1<<9), // WAVE: "Side Left" CHANNEL_BIT_RightSurroundDirect = (1<<10), // WAVE: "Side Right" CHANNEL_BIT_TopCenterSurround = (1<<11), CHANNEL_BIT_VerticalHeightLeft = (1<<12), // WAVE: "Top Front Left" CHANNEL_BIT_VerticalHeightCenter = (1<<13), // WAVE: "Top Front Center" CHANNEL_BIT_VerticalHeightRight = (1<<14), // WAVE: "Top Front Right" CHANNEL_BIT_TopBackLeft = (1<<15), CHANNEL_BIT_TopBackCenter = (1<<16), CHANNEL_BIT_TopBackRight = (1<<17) } channel_bit_t; static struct { channel_bit_t bit; channel_label_t label; } channel_bits[] = { { CHANNEL_BIT_Left, CHANNEL_LABEL_Left }, { CHANNEL_BIT_Right, CHANNEL_LABEL_Right }, { CHANNEL_BIT_Center, CHANNEL_LABEL_Center }, { CHANNEL_BIT_LFEScreen, CHANNEL_LABEL_LFEScreen }, { CHANNEL_BIT_LeftSurround, CHANNEL_LABEL_LeftSurround }, // WAVE: "Back Left" { CHANNEL_BIT_RightSurround, CHANNEL_LABEL_RightSurround },// WAVE: "Back Right" { CHANNEL_BIT_LeftCenter, CHANNEL_LABEL_LeftCenter }, { CHANNEL_BIT_RightCenter, CHANNEL_LABEL_RightCenter }, { CHANNEL_BIT_CenterSurround, CHANNEL_LABEL_CenterSurround }, // WAVE: "Back Center" { CHANNEL_BIT_LeftSurroundDirect, CHANNEL_LABEL_LeftSurroundDirect }, // WAVE: "Side Left" { CHANNEL_BIT_RightSurroundDirect, CHANNEL_LABEL_RightSurroundDirect }, // WAVE: "Side Right" { CHANNEL_BIT_TopCenterSurround, CHANNEL_LABEL_TopCenterSurround }, { CHANNEL_BIT_VerticalHeightLeft, CHANNEL_LABEL_VerticalHeightLeft }, // WAVE: "Top Front Left" { CHANNEL_BIT_VerticalHeightCenter, CHANNEL_LABEL_VerticalHeightCenter }, // WAVE: "Top Front Center" { CHANNEL_BIT_VerticalHeightRight, CHANNEL_LABEL_VerticalHeightRight }, // WAVE: "Top Front Right" { CHANNEL_BIT_TopBackLeft, CHANNEL_LABEL_TopBackLeft }, { CHANNEL_BIT_TopBackCenter, CHANNEL_LABEL_TopBackCenter }, { CHANNEL_BIT_TopBackRight, CHANNEL_LABEL_TopBackRight }, }; static channel_label_t channel_bit_2_channel_label(uint32_t bit) { int i; for(i = 0; i < sizeof(channel_bits) / sizeof(channel_bits[0]); i++) { if(bit == channel_bits[i].bit) return channel_bits[i].label; } return CHANNEL_LABEL_Unknown; } static struct { lqt_channel_t lqt_channel; channel_label_t channel_label; } lqt_channels[] = { { LQT_CHANNEL_UNKNOWN, CHANNEL_LABEL_Unknown }, { LQT_CHANNEL_FRONT_LEFT, CHANNEL_LABEL_Left }, { LQT_CHANNEL_FRONT_RIGHT, CHANNEL_LABEL_Right }, { LQT_CHANNEL_FRONT_CENTER, CHANNEL_LABEL_Center }, { LQT_CHANNEL_FRONT_CENTER_LEFT, CHANNEL_LABEL_LeftCenter }, { LQT_CHANNEL_FRONT_CENTER_RIGHT, CHANNEL_LABEL_RightCenter }, { LQT_CHANNEL_BACK_CENTER, CHANNEL_LABEL_CenterSurround }, { LQT_CHANNEL_BACK_LEFT, CHANNEL_LABEL_LeftSurround }, { LQT_CHANNEL_BACK_RIGHT, CHANNEL_LABEL_RightSurround }, { LQT_CHANNEL_SIDE_LEFT, CHANNEL_LABEL_LeftSurroundDirect }, { LQT_CHANNEL_SIDE_RIGHT, CHANNEL_LABEL_RightSurroundDirect }, { LQT_CHANNEL_LFE, CHANNEL_LABEL_LFEScreen }, }; static lqt_channel_t channel_label_2_channel(channel_label_t channel_label) { int i; for(i = 0; i < sizeof(lqt_channels)/sizeof(lqt_channels[0]); i++) { if(lqt_channels[i].channel_label == channel_label) return lqt_channels[i].lqt_channel; } return LQT_CHANNEL_UNKNOWN; } static channel_label_t channel_2_channel_label(lqt_channel_t channel) { int i; for(i = 0; i < sizeof(lqt_channels)/sizeof(lqt_channels[0]); i++) { if(lqt_channels[i].lqt_channel == channel) return lqt_channels[i].channel_label; } return CHANNEL_LABEL_Unknown; } /* Layout tags */ typedef enum { CHANNEL_LAYOUT_UseChannelDescriptions = (0<<16) | 0, // use the array of AudioChannelDescriptions to define the mapping. CHANNEL_LAYOUT_UseChannelBitmap = (1<<16) | 0, // use the bitmap to define the mapping. // 1 Channel Layout CHANNEL_LAYOUT_Mono = (100<<16) | 1, // a standard mono stream // 2 Channel layouts CHANNEL_LAYOUT_Stereo = (101<<16) | 2, // a standard stereo stream (L R) CHANNEL_LAYOUT_StereoHeadphones = (102<<16) | 2, // a standard stereo stream (L R) - implied headphone playback CHANNEL_LAYOUT_MatrixStereo = (103<<16) | 2, // a matrix encoded stereo stream (Lt, Rt) CHANNEL_LAYOUT_MidSide = (104<<16) | 2, // mid/side recording CHANNEL_LAYOUT_XY = (105<<16) | 2, // coincident mic pair (often 2 figure 8's) CHANNEL_LAYOUT_Binaural = (106<<16) | 2, // binaural stereo (left, right) // Symetric arrangements - same distance between speaker locations CHANNEL_LAYOUT_Ambisonic_B_Format = (107<<16) | 4, // W, X, Y, Z CHANNEL_LAYOUT_Quadraphonic = (108<<16) | 4, // front left, front right, back left, back right CHANNEL_LAYOUT_Pentagonal = (109<<16) | 5, // left, right, rear left, rear right, center CHANNEL_LAYOUT_Hexagonal = (110<<16) | 6, // left, right, rear left, rear right, center, rear CHANNEL_LAYOUT_Octagonal = (111<<16) | 8, // front left, front right, rear left, rear right, // front center, rear center, side left, side right CHANNEL_LAYOUT_Cube = (112<<16) | 8, // left, right, rear left, rear right // top left, top right, top rear left, top rear right // MPEG defined layouts CHANNEL_LAYOUT_MPEG_1_0 = CHANNEL_LAYOUT_Mono, // C CHANNEL_LAYOUT_MPEG_2_0 = CHANNEL_LAYOUT_Stereo, // L R CHANNEL_LAYOUT_MPEG_3_0_A = (113<<16) | 3, // L R C CHANNEL_LAYOUT_MPEG_3_0_B = (114<<16) | 3, // C L R CHANNEL_LAYOUT_MPEG_4_0_A = (115<<16) | 4, // L R C Cs CHANNEL_LAYOUT_MPEG_4_0_B = (116<<16) | 4, // C L R Cs CHANNEL_LAYOUT_MPEG_5_0_A = (117<<16) | 5, // L R C Ls Rs CHANNEL_LAYOUT_MPEG_5_0_B = (118<<16) | 5, // L R Ls Rs C CHANNEL_LAYOUT_MPEG_5_0_C = (119<<16) | 5, // L C R Ls Rs CHANNEL_LAYOUT_MPEG_5_0_D = (120<<16) | 5, // C L R Ls Rs CHANNEL_LAYOUT_MPEG_5_1_A = (121<<16) | 6, // L R C LFE Ls Rs CHANNEL_LAYOUT_MPEG_5_1_B = (122<<16) | 6, // L R Ls Rs C LFE CHANNEL_LAYOUT_MPEG_5_1_C = (123<<16) | 6, // L C R Ls Rs LFE CHANNEL_LAYOUT_MPEG_5_1_D = (124<<16) | 6, // C L R Ls Rs LFE CHANNEL_LAYOUT_MPEG_6_1_A = (125<<16) | 7, // L R C LFE Ls Rs Cs CHANNEL_LAYOUT_MPEG_7_1_A = (126<<16) | 8, // L R C LFE Ls Rs Lc Rc CHANNEL_LAYOUT_MPEG_7_1_B = (127<<16) | 8, // C Lc Rc L R Ls Rs LFE CHANNEL_LAYOUT_MPEG_7_1_C = (128<<16) | 8, // L R C LFE Ls R Rls Rrs CHANNEL_LAYOUT_Emagic_Default_7_1 = (129<<16) | 8, // L R Ls Rs C LFE Lc Rc CHANNEL_LAYOUT_SMPTE_DTV = (130<<16) | 8, // L R C LFE Ls Rs Lt Rt // (CHANNEL_LAYOUT_ITU_5_1 plus a matrix encoded stereo mix) // ITU defined layouts CHANNEL_LAYOUT_ITU_1_0 = CHANNEL_LAYOUT_Mono, // C CHANNEL_LAYOUT_ITU_2_0 = CHANNEL_LAYOUT_Stereo, // L R CHANNEL_LAYOUT_ITU_2_1 = (131<<16) | 3, // L R Cs CHANNEL_LAYOUT_ITU_2_2 = (132<<16) | 4, // L R Ls Rs CHANNEL_LAYOUT_ITU_3_0 = CHANNEL_LAYOUT_MPEG_3_0_A, // L R C CHANNEL_LAYOUT_ITU_3_1 = CHANNEL_LAYOUT_MPEG_4_0_A, // L R C Cs CHANNEL_LAYOUT_ITU_3_2 = CHANNEL_LAYOUT_MPEG_5_0_A, // L R C Ls Rs CHANNEL_LAYOUT_ITU_3_2_1 = CHANNEL_LAYOUT_MPEG_5_1_A, // L R C LFE Ls Rs CHANNEL_LAYOUT_ITU_3_4_1 = CHANNEL_LAYOUT_MPEG_7_1_C, // L R C LFE Ls Rs Rls Rrs // DVD defined layouts CHANNEL_LAYOUT_DVD_0 = CHANNEL_LAYOUT_Mono, // C (mono) CHANNEL_LAYOUT_DVD_1 = CHANNEL_LAYOUT_Stereo, // L R CHANNEL_LAYOUT_DVD_2 = CHANNEL_LAYOUT_ITU_2_1, // L R Cs CHANNEL_LAYOUT_DVD_3 = CHANNEL_LAYOUT_ITU_2_2, // L R Ls Rs CHANNEL_LAYOUT_DVD_4 = (133<<16) | 3, // L R LFE CHANNEL_LAYOUT_DVD_5 = (134<<16) | 4, // L R LFE Cs CHANNEL_LAYOUT_DVD_6 = (135<<16) | 5, // L R LFE Ls Rs CHANNEL_LAYOUT_DVD_7 = CHANNEL_LAYOUT_MPEG_3_0_A,// L R C CHANNEL_LAYOUT_DVD_8 = CHANNEL_LAYOUT_MPEG_4_0_A,// L R C Cs CHANNEL_LAYOUT_DVD_9 = CHANNEL_LAYOUT_MPEG_5_0_A,// L R C Ls Rs CHANNEL_LAYOUT_DVD_10 = (136<<16) | 4, // L R C LFE CHANNEL_LAYOUT_DVD_11 = (137<<16) | 5, // L R C LFE Cs CHANNEL_LAYOUT_DVD_12 = CHANNEL_LAYOUT_MPEG_5_1_A,// L R C LFE Ls Rs // 13 through 17 are duplicates of 8 through 12. CHANNEL_LAYOUT_DVD_13 = CHANNEL_LAYOUT_DVD_8, // L R C Cs CHANNEL_LAYOUT_DVD_14 = CHANNEL_LAYOUT_DVD_9, // L R C Ls Rs CHANNEL_LAYOUT_DVD_15 = CHANNEL_LAYOUT_DVD_10, // L R C LFE CHANNEL_LAYOUT_DVD_16 = CHANNEL_LAYOUT_DVD_11, // L R C LFE Cs CHANNEL_LAYOUT_DVD_17 = CHANNEL_LAYOUT_DVD_12, // L R C LFE Ls Rs CHANNEL_LAYOUT_DVD_18 = (138<<16) | 5, // L R Ls Rs LFE CHANNEL_LAYOUT_DVD_19 = CHANNEL_LAYOUT_MPEG_5_0_B,// L R Ls Rs C CHANNEL_LAYOUT_DVD_20 = CHANNEL_LAYOUT_MPEG_5_1_B,// L R Ls Rs C LFE // These layouts are recommended for Mac OS X's AudioUnit use // These are the symmetrical layouts CHANNEL_LAYOUT_AudioUnit_4= CHANNEL_LAYOUT_Quadraphonic, CHANNEL_LAYOUT_AudioUnit_5= CHANNEL_LAYOUT_Pentagonal, CHANNEL_LAYOUT_AudioUnit_6= CHANNEL_LAYOUT_Hexagonal, CHANNEL_LAYOUT_AudioUnit_8= CHANNEL_LAYOUT_Octagonal, // These are the surround-based layouts CHANNEL_LAYOUT_AudioUnit_5_0 = CHANNEL_LAYOUT_MPEG_5_0_B, // L R Ls Rs C CHANNEL_LAYOUT_AudioUnit_6_0 = (139<<16) | 6, // L R Ls Rs C Cs CHANNEL_LAYOUT_AudioUnit_7_0 = (140<<16) | 7, // L R Ls Rs C Rls Rrs CHANNEL_LAYOUT_AudioUnit_5_1 = CHANNEL_LAYOUT_MPEG_5_1_A, // L R C LFE Ls Rs CHANNEL_LAYOUT_AudioUnit_6_1 = CHANNEL_LAYOUT_MPEG_6_1_A, // L R C LFE Ls Rs Cs CHANNEL_LAYOUT_AudioUnit_7_1 = CHANNEL_LAYOUT_MPEG_7_1_C, // L R C LFE Ls Rs Rls Rrs // These layouts are used for AAC Encoding within the MPEG-4 Specification CHANNEL_LAYOUT_AAC_Quadraphonic = CHANNEL_LAYOUT_Quadraphonic, // L R Ls Rs CHANNEL_LAYOUT_AAC_4_0= CHANNEL_LAYOUT_MPEG_4_0_B, // C L R Cs CHANNEL_LAYOUT_AAC_5_0= CHANNEL_LAYOUT_MPEG_5_0_D, // C L R Ls Rs CHANNEL_LAYOUT_AAC_5_1= CHANNEL_LAYOUT_MPEG_5_1_D, // C L R Ls Rs Lfe CHANNEL_LAYOUT_AAC_6_0= (141<<16) | 6, // C L R Ls Rs Cs CHANNEL_LAYOUT_AAC_6_1= (142<<16) | 7, // C L R Ls Rs Cs Lfe CHANNEL_LAYOUT_AAC_7_0= (143<<16) | 7, // C L R Ls Rs Rls Rrs CHANNEL_LAYOUT_AAC_7_1= CHANNEL_LAYOUT_MPEG_7_1_B, // C Lc Rc L R Ls Rs Lfe CHANNEL_LAYOUT_AAC_Octagonal = (144<<16) | 8, // C L R Ls Rs Rls Rrs Cs CHANNEL_LAYOUT_TMH_10_2_std = (145<<16) | 16, // L R C Vhc Lsd Rsd Ls Rs Vhl Vhr Lw Rw Csd Cs LFE1 LFE2 CHANNEL_LAYOUT_TMH_10_2_full = (146<<16) | 21, // TMH_10_2_std plus: Lc Rc HI VI Haptic CHANNEL_LAYOUT_RESERVED_DO_NOT_USE= (147<<16) } channel_layout_t; static struct { channel_layout_t layout; channel_label_t * channels; } channel_locations[] = { { CHANNEL_LAYOUT_Mono, (channel_label_t[]){ CHANNEL_LABEL_Center } }, // a standard mono stream // 2 Channel layouts { CHANNEL_LAYOUT_Stereo, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right } }, // a standard stereo stream (L R) { CHANNEL_LAYOUT_StereoHeadphones, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right } }, // a standard stereo stream (L R) - implied headphone playback { CHANNEL_LAYOUT_MatrixStereo, (channel_label_t[]){ CHANNEL_LABEL_LeftTotal, CHANNEL_LABEL_RightTotal } }, // a matrix encoded stereo stream (Lt, Rt) { CHANNEL_LAYOUT_MidSide, (channel_label_t[]){ CHANNEL_LABEL_MS_Mid, CHANNEL_LABEL_MS_Side } }, // mid/side recording { CHANNEL_LAYOUT_XY, (channel_label_t[]){ CHANNEL_LABEL_XY_X, CHANNEL_LABEL_XY_Y } }, // coincident mic pair (often 2 figure 8's) { CHANNEL_LAYOUT_Binaural, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right } }, // binaural stereo (left, right) // Symetric arrangements - same distance between speaker locations { CHANNEL_LAYOUT_Ambisonic_B_Format, (channel_label_t[]){ CHANNEL_LABEL_Ambisonic_W, CHANNEL_LABEL_Ambisonic_X, CHANNEL_LABEL_Ambisonic_Y, CHANNEL_LABEL_Ambisonic_Z } }, // W, X, Y, Z { CHANNEL_LAYOUT_Quadraphonic, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround } }, // front left, front right, back left, back right { CHANNEL_LAYOUT_Pentagonal, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_Center } }, // left, right, rear left, rear right, center { CHANNEL_LAYOUT_Hexagonal, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_Center, CHANNEL_LABEL_CenterSurround } }, // left, right, rear left, rear right, center, rear { CHANNEL_LAYOUT_Octagonal, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_Center, CHANNEL_LABEL_CenterSurround, CHANNEL_LABEL_LeftSurroundDirect, CHANNEL_LABEL_RightSurroundDirect } }, // front left, front right, rear left, rear right, // front center, rear center, side left, side right { CHANNEL_LAYOUT_Cube, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_VerticalHeightLeft, CHANNEL_LABEL_VerticalHeightRight, CHANNEL_LABEL_TopBackLeft, CHANNEL_LABEL_TopBackRight } }, // left, right, rear left, rear right // top left, top right, top rear left, top rear right // MPEG defined layouts { CHANNEL_LAYOUT_MPEG_3_0_A, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_Center } }, // L R C { CHANNEL_LAYOUT_MPEG_4_0_A, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_Center, CHANNEL_LABEL_CenterSurround } }, // L R C Cs { CHANNEL_LAYOUT_MPEG_5_0_A, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_Center, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround } }, // L R C Ls Rs { CHANNEL_LAYOUT_MPEG_5_1_A, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_Center, CHANNEL_LABEL_LFEScreen, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround } }, // L R C LFE Ls Rs { CHANNEL_LAYOUT_MPEG_6_1_A, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_Center, CHANNEL_LABEL_LFEScreen, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_CenterSurround } }, // L R C LFE Ls Rs Cs { CHANNEL_LAYOUT_MPEG_7_1_A, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_Center, CHANNEL_LABEL_LFEScreen, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_LeftCenter, CHANNEL_LABEL_RightCenter } }, // L R C LFE Ls Rs Lc Rc { CHANNEL_LAYOUT_MPEG_5_0_B, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_Center } }, // L R Ls Rs C { CHANNEL_LAYOUT_MPEG_5_1_B, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_Center, CHANNEL_LABEL_LFEScreen } }, // L R Ls Rs C LFE { CHANNEL_LAYOUT_MPEG_3_0_B, (channel_label_t[]){ CHANNEL_LABEL_Center, CHANNEL_LABEL_Left, CHANNEL_LABEL_Right } }, // C L R { CHANNEL_LAYOUT_MPEG_4_0_B, (channel_label_t[]){ CHANNEL_LABEL_Center, CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_CenterSurround } }, // C L R Cs { CHANNEL_LAYOUT_MPEG_5_0_D, (channel_label_t[]){ CHANNEL_LABEL_Center, CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround } }, // C L R Ls Rs { CHANNEL_LAYOUT_MPEG_5_1_D, (channel_label_t[]){ CHANNEL_LABEL_Center, CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_LFEScreen } }, // C L R Ls Rs LFE { CHANNEL_LAYOUT_MPEG_5_0_C, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Center, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround } }, // L C R Ls Rs { CHANNEL_LAYOUT_MPEG_5_1_C, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Center, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_LFEScreen } }, // L C R Ls Rs LFE { CHANNEL_LAYOUT_MPEG_7_1_B, (channel_label_t[]){ CHANNEL_LABEL_Center, CHANNEL_LABEL_LeftCenter, CHANNEL_LABEL_RightCenter, CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_LFEScreen } }, // C Lc Rc L R Ls Rs LFE { CHANNEL_LAYOUT_MPEG_7_1_C, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_Center, CHANNEL_LABEL_LFEScreen, CHANNEL_LABEL_LeftSurroundDirect, CHANNEL_LABEL_RightSurroundDirect, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround } }, // L R C LFE Ls Rs Rls Rrs { CHANNEL_LAYOUT_Emagic_Default_7_1, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_Center, CHANNEL_LABEL_LFEScreen, CHANNEL_LABEL_LeftCenter, CHANNEL_LABEL_RightCenter } },// L R Ls Rs C LFE Lc Rc { CHANNEL_LAYOUT_SMPTE_DTV, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_Center, CHANNEL_LABEL_LFEScreen, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_LeftTotal, CHANNEL_LABEL_RightTotal } }, // L R C LFE Ls Rs Lt Rt // (CHANNEL_LAYOUT_ITU_5_1 plus a matrix encoded stereo mix) // ITU defined layouts { CHANNEL_LAYOUT_ITU_2_1, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_CenterSurround } }, // L R Cs { CHANNEL_LAYOUT_ITU_2_2, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround } }, // L R Ls Rs // DVD defined layouts { CHANNEL_LAYOUT_DVD_4, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LFEScreen } }, // L R LFE { CHANNEL_LAYOUT_DVD_5, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LFEScreen, CHANNEL_LABEL_CenterSurround } }, // L R LFE Cs { CHANNEL_LAYOUT_DVD_6, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LFEScreen, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround } }, // L R LFE Ls Rs { CHANNEL_LAYOUT_DVD_10, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_Center, CHANNEL_LABEL_LFEScreen } }, // L R C LFE { CHANNEL_LAYOUT_DVD_11, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_Center, CHANNEL_LABEL_LFEScreen, CHANNEL_LABEL_CenterSurround } }, // L R C LFE Cs // 13 through 17 are duplicates of 8 through 12. { CHANNEL_LAYOUT_DVD_18, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_LFEScreen } }, // L R Ls Rs LFE // These are the surround-based layouts { CHANNEL_LAYOUT_AudioUnit_6_0, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_Center, CHANNEL_LABEL_CenterSurround } }, // L R Ls Rs C Cs { CHANNEL_LAYOUT_AudioUnit_7_0, (channel_label_t[]){ CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurroundDirect, CHANNEL_LABEL_RightSurroundDirect, CHANNEL_LABEL_Center, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround } }, // L R Ls Rs C Rls Rrs // These layouts are used for AAC Encoding within the MPEG-4 Specification { CHANNEL_LAYOUT_AAC_6_0, (channel_label_t[]){ CHANNEL_LABEL_Center, CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_CenterSurround } }, // C L R Ls Rs Cs { CHANNEL_LAYOUT_AAC_6_1, (channel_label_t[]){ CHANNEL_LABEL_Center, CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_CenterSurround, CHANNEL_LABEL_LFEScreen } }, // C L R Ls Rs Cs Lfe { CHANNEL_LAYOUT_AAC_7_0, (channel_label_t[]){ CHANNEL_LABEL_Center, CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurroundDirect, CHANNEL_LABEL_RightSurroundDirect, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround } }, // C L R Ls Rs Rls Rrs { CHANNEL_LAYOUT_AAC_Octagonal, (channel_label_t[]){ CHANNEL_LABEL_Center, CHANNEL_LABEL_Left, CHANNEL_LABEL_Right, CHANNEL_LABEL_LeftSurroundDirect, CHANNEL_LABEL_RightSurroundDirect, CHANNEL_LABEL_LeftSurround, CHANNEL_LABEL_RightSurround, CHANNEL_LABEL_CenterSurround } }, // C L R Ls Rs Rls Rrs Cs /* No, sorry the following 2 a to weird. The one who has such files, can program it */ // { CHANNEL_LAYOUT_TMH_10_2_std, (channel_label_t[]){ } }, // L R C Vhc Lsd Rsd Ls Rs Vhl Vhr Lw Rw Csd Cs LFE1 LFE2 // { CHANNEL_LAYOUT_TMH_10_2_full, (channel_label_t[]){ } }, // TMH_10_2_std plus: Lc Rc HI VI Haptic }; static channel_label_t * get_channel_locations(uint32_t layout, int * num_channels) { int i; *num_channels = layout & 0xffff; for(i = 0; i < sizeof(channel_locations)/sizeof(channel_locations[0]); i++) { if(channel_locations[i].layout == layout) { return channel_locations[i].channels; } } return (channel_label_t*)0; } void quicktime_chan_init(quicktime_chan_t *chan) { } void quicktime_chan_delete(quicktime_chan_t *chan) { if(chan->ChannelDescriptions) free(chan->ChannelDescriptions); } void quicktime_chan_dump(quicktime_chan_t *chan) { channel_label_t * channel_labels; int num_channels; int i, j; uint32_t mask; lqt_dump(" channel description\n"); lqt_dump(" version %d\n", chan->version); lqt_dump(" flags %ld\n", chan->flags); lqt_dump(" mChannelLayoutTag: 0x%08x", chan->mChannelLayoutTag); if(chan->mChannelLayoutTag == CHANNEL_LAYOUT_UseChannelDescriptions) { lqt_dump(" [Use channel decriptions]\n"); } else if(chan->mChannelLayoutTag == CHANNEL_LAYOUT_UseChannelBitmap) { lqt_dump(" [Use channel bitmap]\n"); } else { channel_labels = get_channel_locations(chan->mChannelLayoutTag, &num_channels); lqt_dump(" ["); if(channel_labels) { for(i = 0; i < num_channels; i++) { lqt_dump("%s", get_channel_name(channel_labels[i])); if(i < num_channels-1) lqt_dump(", "); } } else { lqt_dump("Not available"); } lqt_dump("]\n"); } lqt_dump(" mChannelBitmap: 0x%08x", chan->mChannelBitmap); if(chan->mChannelLayoutTag == CHANNEL_LAYOUT_UseChannelBitmap) { lqt_dump(" ["); j = 0; mask = 1; for(i = 0; i < 32; i++) { if(chan->mChannelBitmap & mask) { if(j) lqt_dump(", "); lqt_dump("%s", get_channel_name(channel_bit_2_channel_label(mask))); j++; } mask <<= 1; } lqt_dump("]\n"); } else lqt_dump("\n"); lqt_dump(" mNumberChannelDescriptions: %d\n", chan->mNumberChannelDescriptions); for(i = 0; i < chan->mNumberChannelDescriptions; i++) { lqt_dump(" mChannelLabel[%d]: 0x%08x [%s]\n", i, chan->ChannelDescriptions[i].mChannelLabel, get_channel_name(chan->ChannelDescriptions[i].mChannelLabel)); lqt_dump(" mChannelFlags[%d]: 0x%08x\n", i, chan->ChannelDescriptions[i].mChannelFlags); lqt_dump(" mCoordinates[%d]: [%f %f %f]\n", i, chan->ChannelDescriptions[i].mCoordinates[0], chan->ChannelDescriptions[i].mCoordinates[1], chan->ChannelDescriptions[i].mCoordinates[2]); } } void quicktime_read_chan(quicktime_t *file, quicktime_chan_t *chan) { int i; chan->version = quicktime_read_char(file); chan->flags = quicktime_read_int24(file); chan->mChannelLayoutTag = quicktime_read_int32(file); chan->mChannelBitmap = quicktime_read_int32(file); chan->mNumberChannelDescriptions = quicktime_read_int32(file); if(chan->mNumberChannelDescriptions) { chan->ChannelDescriptions = calloc(chan->mNumberChannelDescriptions, sizeof(*(chan->ChannelDescriptions))); for(i = 0; i < chan->mNumberChannelDescriptions; i++) { chan->ChannelDescriptions[i].mChannelLabel = quicktime_read_int32(file); chan->ChannelDescriptions[i].mChannelFlags = quicktime_read_int32(file); chan->ChannelDescriptions[i].mCoordinates[0] = quicktime_read_float32(file); chan->ChannelDescriptions[i].mCoordinates[1] = quicktime_read_float32(file); chan->ChannelDescriptions[i].mCoordinates[2] = quicktime_read_float32(file); } } } void quicktime_write_chan(quicktime_t *file, quicktime_chan_t *chan) { quicktime_atom_t atom; int i; quicktime_atom_write_header(file, &atom, "chan"); quicktime_write_char(file, chan->version); quicktime_write_int24(file, chan->flags); quicktime_write_int32(file, chan->mChannelLayoutTag); quicktime_write_int32(file, chan->mChannelBitmap); quicktime_write_int32(file, chan->mNumberChannelDescriptions); for(i = 0; i < chan->mNumberChannelDescriptions; i++) { quicktime_write_int32(file, chan->ChannelDescriptions[i].mChannelLabel); quicktime_write_int32(file, chan->ChannelDescriptions[i].mChannelFlags); quicktime_write_float32(file, chan->ChannelDescriptions[i].mCoordinates[0]); quicktime_write_float32(file, chan->ChannelDescriptions[i].mCoordinates[1]); quicktime_write_float32(file, chan->ChannelDescriptions[i].mCoordinates[2]); } quicktime_atom_write_footer(file, &atom); } /* Update an atrack from a chan atom */ void quicktime_get_chan(quicktime_audio_map_t * atrack) { int i, num_channels; uint32_t mask; quicktime_chan_t * chan; const channel_label_t * channel_labels; chan = &atrack->track->mdia.minf.stbl.stsd.table[0].chan; if(chan->mChannelLayoutTag == CHANNEL_LAYOUT_UseChannelDescriptions) { atrack->channel_setup = calloc(chan->mNumberChannelDescriptions, sizeof(*atrack->channel_setup)); atrack->channels = chan->mNumberChannelDescriptions; for(i = 0; i < chan->mNumberChannelDescriptions; i++) atrack->channel_setup[i] = channel_label_2_channel(chan->ChannelDescriptions[i].mChannelLabel); } else if(chan->mChannelLayoutTag == CHANNEL_LAYOUT_UseChannelBitmap) { /* Count the channels */ mask = 1; num_channels = 0; for(i = 0; i < 32; i++) { if(chan->mChannelBitmap & mask) num_channels++; mask <<= 1; } /* Set the channels */ atrack->channels = num_channels; atrack->channel_setup = calloc(num_channels, sizeof(*atrack->channel_setup)); mask = 1; num_channels = 0; for(i = 0; i < 32; i++) { if(chan->mChannelBitmap & mask) { atrack->channel_setup[num_channels] = channel_label_2_channel(channel_bit_2_channel_label(mask)); num_channels++; } mask <<= 1; } } else /* Predefined channel layout */ { channel_labels = get_channel_locations(chan->mChannelLayoutTag, &num_channels); atrack->channels = num_channels; if(channel_labels) { atrack->channel_setup = calloc(num_channels, sizeof(*atrack->channel_setup)); for(i = 0; i < num_channels; i++) atrack->channel_setup[i] = channel_label_2_channel(channel_labels[i]); } } } static int layout_equal(channel_label_t * labels, lqt_channel_t * channels, int num_channels) { int i; for(i = 0; i < num_channels; i++) { if(channels[i] != channel_label_2_channel(labels[i])) return 0; } return 1; } static int layout_similar(channel_label_t * labels, lqt_channel_t * channels, int num_channels) { int i, j, found; for(i = 0; i < num_channels; i++) { found = 0; for(j = 0; j < num_channels; j++) { if(channels[i] == channel_label_2_channel(labels[j])) { found = 1; break; } } if(!found) return 0; } return 1; } /* Set the chan atom of an atrack */ void quicktime_set_chan(quicktime_audio_map_t * atrack) { int i, j; quicktime_chan_t * chan; if(!atrack->channel_setup) return; chan = &atrack->track->mdia.minf.stbl.stsd.table[0].chan; /* Search for a equal channel setup */ for(i = 0; i < sizeof(channel_locations) / sizeof(channel_locations[0]); i++) { if(((channel_locations[i].layout & 0xffff) == atrack->channels) && layout_equal(channel_locations[i].channels, atrack->channel_setup, atrack->channels)) { chan->mChannelLayoutTag = channel_locations[i].layout; atrack->track->mdia.minf.stbl.stsd.table[0].has_chan = 1; return; } } /* Search for a similar channel setup */ for(i = 0; i < sizeof(channel_locations) / sizeof(channel_locations[0]); i++) { if(((channel_locations[i].layout & 0xffff) == atrack->channels) && layout_similar(channel_locations[i].channels, atrack->channel_setup, atrack->channels)) { chan->mChannelLayoutTag = channel_locations[i].layout; atrack->track->mdia.minf.stbl.stsd.table[0].has_chan = 1; for(j = 0; j < atrack->channels; j++) atrack->channel_setup[j] = channel_label_2_channel(channel_locations[i].channels[j]); return; } } /* Nothing found, create a custom channel setup */ chan->ChannelDescriptions = calloc(atrack->channels, sizeof(*(chan->ChannelDescriptions))); chan->mNumberChannelDescriptions = atrack->channels; chan->mChannelLayoutTag = CHANNEL_LAYOUT_UseChannelDescriptions; for(i = 0; i < chan->mNumberChannelDescriptions; i++) { chan->ChannelDescriptions[i].mChannelLabel = channel_2_channel_label(atrack->channel_setup[i]); } atrack->track->mdia.minf.stbl.stsd.table[0].has_chan = 1; } libquicktime-1.2.4/src/lqt_fseeko.c0000644000175000017500000000467011511622756014225 00000000000000/******************************************************************************* lqt_fseeko.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ /* 64-bit versions of fseeko/ftello. Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group Portions Copyright (c) 1994, Regents of the University of California */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifndef HAVE_FSEEKO #include #include #include #include /* * On BSD/OS and NetBSD, off_t and fpos_t are the same. Standards * say off_t is an arithmetic type, but not necessarily integral, * while fpos_t might be neither. */ int lqt_fseeko(FILE *stream, off_t offset, int whence) { off_t floc; struct stat filestat; switch (whence) { case SEEK_CUR: flockfile(stream); if (fgetpos(stream, &floc) != 0) goto failure; floc += offset; if (fsetpos(stream, &floc) != 0) goto failure; funlockfile(stream); return 0; break; case SEEK_SET: if (fsetpos(stream, &offset) != 0) return -1; return 0; break; case SEEK_END: flockfile(stream); if (fstat(fileno(stream), &filestat) != 0) goto failure; floc = filestat.st_size; if (fsetpos(stream, &floc) != 0) goto failure; funlockfile(stream); return 0; break; default: errno = EINVAL; return -1; } failure: funlockfile(stream); return -1; } off_t lqt_ftello(FILE *stream) { off_t floc; if (fgetpos(stream, &floc) != 0) return -1; return floc; } #endif libquicktime-1.2.4/src/smhd.c0000644000175000017500000000427111511622757013022 00000000000000/******************************************************************************* smhd.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" void quicktime_smhd_init(quicktime_smhd_t *smhd) { smhd->version = 0; smhd->flags = 0; smhd->balance = 0; smhd->reserved = 0; } void quicktime_smhd_delete(quicktime_smhd_t *smhd) { } void quicktime_smhd_dump(quicktime_smhd_t *smhd) { lqt_dump(" sound media header (smhd)\n"); lqt_dump(" version %d\n", smhd->version); lqt_dump(" flags %ld\n", smhd->flags); lqt_dump(" balance %d\n", smhd->balance); lqt_dump(" reserved %d\n", smhd->reserved); } void quicktime_read_smhd(quicktime_t *file, quicktime_smhd_t *smhd) { smhd->version = quicktime_read_char(file); smhd->flags = quicktime_read_int24(file); smhd->balance = quicktime_read_int16(file); smhd->reserved = quicktime_read_int16(file); } void quicktime_write_smhd(quicktime_t *file, quicktime_smhd_t *smhd) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "smhd"); quicktime_write_char(file, smhd->version); quicktime_write_int24(file, smhd->flags); quicktime_write_int16(file, smhd->balance); quicktime_write_int16(file, smhd->reserved); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/pano.c0000644000175000017500000001460311511622757013024 00000000000000/******************************************************************************* pano.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" int quicktime_pano_init(quicktime_pano_t *pano) { pano->version = 0; pano->revision = 0; pano->STrack = 0; pano->LowResSTrack = 0; pano->HSTrack = 0; pano->HPanStart = 0; pano->HPanEnd = 360; pano->VPanStart = 30; pano->VPanEnd = -30; pano->MinZoom = 0; pano->MaxZoom = 0; pano->SHeight = 0; pano->SWidth = 0; pano->NumFrames = 1; pano->SNumFramesHeight = 1; pano->SNumFramesWidth = 1; pano->SDepth = 32; pano->HSHeight = 0; pano->HSWidth = 0; pano->HSNumFramesHeight = 0; pano->HSNumFramesWidth = 0; pano->HSDepth = 8; return 0; } int quicktime_pano_delete(quicktime_pano_t *pano) { return 0; } void quicktime_pano_dump(quicktime_pano_t *pano) { lqt_dump(" panorama (pano)\n"); lqt_dump(" version %i\n", pano->version ); lqt_dump(" revision %i\n", pano->revision ); lqt_dump(" scene track %ld\n", pano->STrack ); lqt_dump(" lowres scene track %ld\n", pano->LowResSTrack ); lqt_dump(" hotspot track %ld\n", pano->HSTrack ); lqt_dump(" horizontal start pan %f\n", pano->HPanStart ); lqt_dump(" horizontal end pan %f\n", pano->HPanEnd ); lqt_dump(" vertical start pan %f\n", pano->VPanStart ); lqt_dump(" vertical end pan %f\n", pano->VPanEnd ); lqt_dump(" minimum zoom %f\n", pano->MinZoom ); lqt_dump(" maximum zoom %f\n", pano->MaxZoom ); lqt_dump(" scene height %ld\n", pano->SHeight ); lqt_dump(" scene width %ld\n", pano->SWidth ); lqt_dump(" num frames %ld\n", pano->NumFrames ); lqt_dump(" num frames(height) %i\n", pano->SNumFramesHeight ); lqt_dump(" num frames(width) %i\n", pano->SNumFramesWidth ); lqt_dump(" scene depth %i\n", pano->SDepth ); lqt_dump(" hotspot height %ld\n", pano->HSHeight ); lqt_dump(" hotspot width %ld\n", pano->HSWidth ); lqt_dump(" num. hotspot frames (height) %i\n", pano->HSNumFramesHeight ); lqt_dump(" num. hotspot frames (width) %i\n", pano->HSNumFramesWidth ); lqt_dump(" hotspot depth %i\n", pano->HSDepth ); } int quicktime_read_pano(quicktime_t *file, quicktime_pano_t *pano, quicktime_atom_t *pano_atom) { pano->version = quicktime_read_int16(file); pano->revision = quicktime_read_int16(file); pano->STrack = quicktime_read_int32(file); pano->LowResSTrack = quicktime_read_int32(file); quicktime_read_data(file, (uint8_t *)pano->reserved3, 4 * 6); pano->HSTrack = quicktime_read_int32(file); quicktime_read_data(file, (uint8_t *)pano->reserved4, 4 * 9); pano->HPanStart = quicktime_read_fixed32(file); pano->HPanEnd = quicktime_read_fixed32(file); pano->VPanStart = quicktime_read_fixed32(file); pano->VPanEnd = quicktime_read_fixed32(file); pano->MinZoom = quicktime_read_fixed32(file); pano->MaxZoom = quicktime_read_fixed32(file); pano->SHeight = quicktime_read_int32(file); pano->SWidth = quicktime_read_int32(file); pano->NumFrames = quicktime_read_int32(file); pano->reserved5 = quicktime_read_int16(file); pano->SNumFramesHeight = quicktime_read_int16(file); pano->SNumFramesWidth = quicktime_read_int16(file); pano->SDepth = quicktime_read_int16(file); pano->HSHeight = quicktime_read_int32(file); pano->HSWidth = quicktime_read_int32(file); pano->reserved6 = quicktime_read_int16(file); pano->HSNumFramesHeight = quicktime_read_int16(file); pano->HSNumFramesWidth = quicktime_read_int16(file); pano->HSDepth = quicktime_read_int16(file); return 0; } void quicktime_write_pano(quicktime_t *file, quicktime_pano_t *pano) { quicktime_write_int16(file, pano->version); quicktime_write_int16(file, pano->revision); quicktime_write_int32(file, pano->STrack); quicktime_write_int32(file, pano->LowResSTrack); quicktime_write_data(file, (uint8_t *)pano->reserved3, 4 * 6); quicktime_write_int32(file, pano->HSTrack); quicktime_write_data(file, (uint8_t *)pano->reserved4, 4 * 9); quicktime_write_fixed32(file, pano->HPanStart); quicktime_write_fixed32(file, pano->HPanEnd); quicktime_write_fixed32(file, pano->VPanStart); quicktime_write_fixed32(file, pano->VPanEnd); quicktime_write_fixed32(file, pano->MinZoom); quicktime_write_fixed32(file, pano->MaxZoom); quicktime_write_int32(file, pano->SHeight); quicktime_write_int32(file, pano->SWidth); quicktime_write_int32(file, pano->NumFrames); quicktime_write_int16(file, pano->reserved5); quicktime_write_int16(file, pano->SNumFramesHeight); quicktime_write_int16(file, pano->SNumFramesWidth); quicktime_write_int16(file, pano->SDepth); quicktime_write_int32(file, pano->HSHeight); quicktime_write_int32(file, pano->HSWidth); quicktime_write_int16(file, pano->reserved6); quicktime_write_int16(file, pano->HSNumFramesHeight); quicktime_write_int16(file, pano->HSNumFramesWidth); quicktime_write_int16(file, pano->HSDepth); } libquicktime-1.2.4/src/lqt_bufalloc.c0000644000175000017500000000640611511622756014537 00000000000000/******************************************************************************* lqt_bufalloc.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ /* Aligned buffer allocation routine. This routine should be used everywhere that a SIMD (MMX/MMX2/SSE/Altivec) routine may operate on allocated buffers. SIMD routines require that the buffers be aligned on a 16 byte boundary (SSE/SSE2 require 64 byte alignment). */ #include "lqt_private.h" #include #include #include #include #define LOG_DOMAIN "bufalloc" /* * Allocate memory aligned to suit SIMD */ #define powerof2(x) ((((x)-1)&(x))==0) #if !defined(HAVE_POSIX_MEMALIGN) static int posix_memalign(void **ptr, size_t alignment, size_t size) { void *mem; if (alignment % sizeof (void *) != 0 || !powerof2(alignment) != 0) return(EINVAL); mem = malloc((size + alignment - 1) & ~(alignment - 1)); if (mem != NULL) { *ptr = mem; return(0); } return(ENOMEM); } #endif #if !defined(HAVE_MEMALIGN) static void * memalign(size_t alignment, size_t size) { if (alignment % sizeof (void *) || !powerof2(alignment)) { errno = EINVAL; return(NULL); } return(malloc((size + alignment - 1) & ~(alignment - 1))); } #else /* some systems have memalign() but no declaration for it */ void * memalign (size_t align, size_t size); #endif void *lqt_bufalloc(size_t size) { static size_t simd_alignment = 16; static int bufalloc_init = 0; int pgsize; void *buf = NULL; if (!bufalloc_init) { #ifdef ARCH_X86 simd_alignment = 64; /* X86 requires 64 for SSE */ bufalloc_init = 1; #endif } pgsize = sysconf(_SC_PAGESIZE); /* * If posix_memalign fails it could be a broken glibc that caused the error, * so try again with a page aligned memalign request */ if (posix_memalign( &buf, simd_alignment, size)) buf = memalign(pgsize, size); if (buf && ((size_t)buf & (simd_alignment - 1))) { free(buf); buf = memalign(pgsize, size); } if (buf == NULL) lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "malloc of %d bytes failed", (int)size); else memset(buf, '\0', size); if ((size_t)buf & (simd_alignment - 1)) lqt_log(NULL, LQT_LOG_ERROR, LOG_DOMAIN, "could not allocate %d bytes aligned on a %d byte boundary", (int)size, (int)simd_alignment); return buf; } libquicktime-1.2.4/src/edts.c0000644000175000017500000000414011511622756013020 00000000000000/******************************************************************************* edts.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" void quicktime_edts_init(quicktime_edts_t *edts) { quicktime_elst_init(&edts->elst); } void quicktime_edts_delete(quicktime_edts_t *edts) { quicktime_elst_delete(&edts->elst); } void quicktime_edts_init_table(quicktime_edts_t *edts) { quicktime_elst_init_all(&edts->elst); } void quicktime_read_edts(quicktime_t *file, quicktime_edts_t *edts, quicktime_atom_t *edts_atom) { quicktime_atom_t leaf_atom; do { quicktime_atom_read_header(file, &leaf_atom); if(quicktime_atom_is(&leaf_atom, "elst")) { quicktime_read_elst(file, &edts->elst); } else quicktime_atom_skip(file, &leaf_atom); }while(quicktime_position(file) < edts_atom->end); } void quicktime_edts_dump(quicktime_edts_t *edts) { lqt_dump(" edit atom (edts)\n"); quicktime_elst_dump(&edts->elst); } void quicktime_write_edts(quicktime_t *file, quicktime_edts_t *edts) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "edts"); quicktime_write_elst(file, &edts->elst); quicktime_atom_write_footer(file, &atom); } libquicktime-1.2.4/src/vrnp.c0000644000175000017500000000424711511622757013057 00000000000000/******************************************************************************* vrnp.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" int quicktime_vrnp_init(quicktime_vrnp_t *vrnp) { vrnp->children = 0; quicktime_vrni_init(&vrnp->vrni[0]); return 0; } int quicktime_vrnp_delete(quicktime_vrnp_t *vrnp) { return 0; } void quicktime_vrnp_dump(quicktime_vrnp_t *vrnp) { int i; lqt_dump(" node parent (vrnp)\n"); lqt_dump(" nodes %i\n", vrnp->children); for (i = 0; i < vrnp->children; i++) { quicktime_vrni_dump(&vrnp->vrni[i]); } } int quicktime_read_vrnp(quicktime_t *file, quicktime_vrnp_t *vrnp, quicktime_qtatom_t *vrnp_atom) { quicktime_qtatom_t leaf_atom; int result = 0; int i; quicktime_qtatom_read_header(file, &leaf_atom); for (i = 0; i < vrnp->children; i++ ) { vrnp->vrni[i].ID = leaf_atom.ID; result += quicktime_read_vrni(file, &vrnp->vrni[i], &leaf_atom); } return result; } void quicktime_write_vrnp(quicktime_t *file, quicktime_vrnp_t *vrnp ) { quicktime_qtatom_t atom; quicktime_qtatom_write_header(file, &atom, "vrnp", 1); atom.child_count = 1; quicktime_write_vrni(file, &vrnp->vrni[0]); quicktime_qtatom_write_footer(file, &atom); } libquicktime-1.2.4/src/translation.c0000644000175000017500000000277211511622757014431 00000000000000/******************************************************************************* translation.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include #include #include static pthread_mutex_t translation_mutex = PTHREAD_MUTEX_INITIALIZER; static int translation_initialized = 0; void lqt_translation_init() { pthread_mutex_lock(&translation_mutex); if(!translation_initialized) { bindtextdomain(PACKAGE, LOCALE_DIR); translation_initialized = 1; } pthread_mutex_unlock(&translation_mutex); } libquicktime-1.2.4/src/stsz.c0000644000175000017500000001304611511622757013072 00000000000000/******************************************************************************* stsz.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include void quicktime_stsz_init(quicktime_stsz_t *stsz) { stsz->version = 0; stsz->flags = 0; stsz->sample_size = 0; stsz->total_entries = 0; stsz->entries_allocated = 0; } void quicktime_stsz_init_video(quicktime_t *file, quicktime_stsz_t *stsz) { stsz->sample_size = 0; if(!stsz->entries_allocated) { stsz->entries_allocated = 2048; stsz->total_entries = 0; stsz->table = (quicktime_stsz_table_t*)calloc(sizeof(quicktime_stsz_table_t), stsz->entries_allocated); } } void quicktime_stsz_init_timecode(quicktime_stsz_t *stsz) { stsz->sample_size = 4; #if 0 if(!stsz->entries_allocated) { stsz->entries_allocated = 2048; stsz->total_entries = 0; stsz->table = (quicktime_stsz_table_t*)calloc(sizeof(quicktime_stsz_table_t), stsz->entries_allocated); } #endif } void quicktime_stsz_init_audio(quicktime_t *file, quicktime_stsz_t *stsz, int channels, int bits, char *compressor) { /*stsz->sample_size = channels * bits / 8; */ stsz->sample_size = 1; stsz->total_entries = 0; /* set this when closing */ stsz->entries_allocated = 0; } void quicktime_stsz_delete(quicktime_stsz_t *stsz) { if(stsz->table) free(stsz->table); } void quicktime_stsz_dump(quicktime_stsz_t *stsz) { int i; lqt_dump(" sample size (stsz)\n"); lqt_dump(" version %d\n", stsz->version); lqt_dump(" flags %ld\n", stsz->flags); lqt_dump(" sample_size %lld\n", (long long)(stsz->sample_size)); lqt_dump(" total_entries %ld\n", stsz->total_entries); if(!stsz->sample_size) { for(i = 0; i < stsz->total_entries; i++) { lqt_dump(" sample_size %llx (%lld)\n", (long long)(stsz->table[i].size), (long long)(stsz->table[i].size)); } } } void quicktime_read_stsz(quicktime_t *file, quicktime_stsz_t *stsz) { int i; stsz->version = quicktime_read_char(file); stsz->flags = quicktime_read_int24(file); stsz->sample_size = quicktime_read_int32(file); stsz->total_entries = quicktime_read_int32(file); stsz->entries_allocated = stsz->total_entries; if(!stsz->sample_size) // if(stsz->total_entries) { // stsz->sample_size = 0; stsz->table = (quicktime_stsz_table_t*)calloc(sizeof(quicktime_stsz_table_t), stsz->entries_allocated); for(i = 0; i < stsz->total_entries; i++) { stsz->table[i].size = quicktime_read_int32(file); } } } void quicktime_write_stsz(quicktime_t *file, quicktime_stsz_t *stsz) { int i; quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "stsz"); /* optimize if possible */ /* Xanim requires an unoptimized table for video. */ /* if(!stsz->sample_size) */ /* { */ /* for(i = 0, result = 0; i < stsz->total_entries && !result; i++) */ /* { */ /* if(stsz->table[i].size != stsz->table[0].size) result = 1; */ /* } */ /* */ /* if(!result) */ /* { */ /* stsz->sample_size = stsz->table[0].size; */ /* stsz->total_entries = 0; */ /* free(stsz->table); */ /* } */ /* } */ quicktime_write_char(file, stsz->version); quicktime_write_int24(file, stsz->flags); // Force idiosynchratic handling of fixed bitrate audio. // Since audio has millions of samples it's not practical to declare a size // of each sample. Instead Quicktime stores a 1 for every sample's size and // relies on the samples per chunk table to determine the chunk size. quicktime_write_int32(file, stsz->sample_size); quicktime_write_int32(file, stsz->total_entries); if(!stsz->sample_size) { for(i = 0; i < stsz->total_entries; i++) { quicktime_write_int32(file, stsz->table[i].size); } } quicktime_atom_write_footer(file, &atom); } void quicktime_update_stsz(quicktime_stsz_t *stsz, long sample, long sample_size) { if(!stsz->sample_size) { if(sample >= stsz->entries_allocated) { stsz->entries_allocated += 1024; stsz->table = (quicktime_stsz_table_t*)realloc(stsz->table, sizeof(quicktime_stsz_table_t) * stsz->entries_allocated); } stsz->table[sample].size = sample_size; if(sample >= stsz->total_entries) stsz->total_entries = sample + 1; } } libquicktime-1.2.4/src/avi_strf.c0000644000175000017500000003047711511622756013712 00000000000000/******************************************************************************* avi_strf.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include void quicktime_read_strf_audio(quicktime_t *file, quicktime_strf_t *strf, quicktime_atom_t *parent_atom) { strf->wf.type = LQT_WAVEFORMAT_WAVEFORMAT; strf->wf.f.WAVEFORMAT.wFormatTag = quicktime_read_int16_le(file); /* value that identifies compression format */ strf->wf.f.WAVEFORMAT.nChannels = quicktime_read_int16_le(file); strf->wf.f.WAVEFORMAT.nSamplesPerSec = quicktime_read_int32_le(file); strf->wf.f.WAVEFORMAT.nAvgBytesPerSec = quicktime_read_int32_le(file); strf->wf.f.WAVEFORMAT.nBlockAlign = quicktime_read_int16_le(file); /* size of a data sample */ if(parent_atom->size >= 16) { strf->wf.type = LQT_WAVEFORMAT_PCMWAVEFORMAT; strf->wf.f.PCMWAVEFORMAT.wBitsPerSample = quicktime_read_int16_le(file); } if(parent_atom->size >= 18) { strf->wf.type = LQT_WAVEFORMAT_WAVEFORMATEX; strf->wf.f.WAVEFORMATEX.cbSize = quicktime_read_int16_le(file); if(strf->wf.f.WAVEFORMATEX.cbSize) { if(strf->wf.f.WAVEFORMAT.wFormatTag == 0xfffe && (strf->wf.f.WAVEFORMATEX.cbSize >= 22)) { strf->wf.type = LQT_WAVEFORMAT_WAVEFORMATEXTENSIBLE; strf->wf.f.WAVEFORMATEXTENSIBLE.Samples.wValidBitsPerSample = quicktime_read_int16_le(file);; strf->wf.f.WAVEFORMATEXTENSIBLE.dwChannelMask = quicktime_read_int32_le(file);; quicktime_GUID_read(file, &strf->wf.f.WAVEFORMATEXTENSIBLE.SubFormat); if((strf->wf.f.WAVEFORMATEX.cbSize > 22) && (parent_atom->size >= 18 + strf->wf.f.WAVEFORMATEX.cbSize - 22)) { strf->wf.f.WAVEFORMATEX.ext_data = malloc(strf->wf.f.WAVEFORMATEX.cbSize - 22); strf->wf.f.WAVEFORMATEX.ext_size = strf->wf.f.WAVEFORMATEX.cbSize - 22; quicktime_read_data(file, strf->wf.f.WAVEFORMATEX.ext_data, strf->wf.f.WAVEFORMATEX.cbSize - 22); } } else { if((parent_atom->size >= 18 + strf->wf.f.WAVEFORMATEX.cbSize)) { strf->wf.f.WAVEFORMATEX.ext_data = malloc(strf->wf.f.WAVEFORMATEX.cbSize); strf->wf.f.WAVEFORMATEX.ext_size = strf->wf.f.WAVEFORMATEX.cbSize; quicktime_read_data(file, strf->wf.f.WAVEFORMATEX.ext_data, strf->wf.f.WAVEFORMATEX.cbSize); } } } } } void quicktime_write_strf_audio(quicktime_t *file, quicktime_strf_t *strf) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "strf"); quicktime_write_int16_le(file, strf->wf.f.WAVEFORMAT.wFormatTag); /* value that identifies compression format */ quicktime_write_int16_le(file, strf->wf.f.WAVEFORMAT.nChannels); quicktime_write_int32_le(file, strf->wf.f.WAVEFORMAT.nSamplesPerSec); quicktime_write_int32_le(file, strf->wf.f.WAVEFORMAT.nAvgBytesPerSec); quicktime_write_int16_le(file, strf->wf.f.WAVEFORMAT.nBlockAlign); /* size of a data sample */ switch(strf->wf.type) { case LQT_WAVEFORMAT_WAVEFORMAT: break; case LQT_WAVEFORMAT_PCMWAVEFORMAT: quicktime_write_int16_le(file, strf->wf.f.PCMWAVEFORMAT.wBitsPerSample); break; case LQT_WAVEFORMAT_WAVEFORMATEX: quicktime_write_int16_le(file, strf->wf.f.PCMWAVEFORMAT.wBitsPerSample); quicktime_write_int16_le(file, strf->wf.f.WAVEFORMATEX.cbSize); break; case LQT_WAVEFORMAT_WAVEFORMATEXTENSIBLE: quicktime_write_int16_le(file, strf->wf.f.PCMWAVEFORMAT.wBitsPerSample); quicktime_write_int16_le(file, strf->wf.f.WAVEFORMATEX.cbSize); quicktime_write_int16_le(file, strf->wf.f.WAVEFORMATEXTENSIBLE.Samples.wValidBitsPerSample); quicktime_write_int32_le(file, strf->wf.f.WAVEFORMATEXTENSIBLE.dwChannelMask);; quicktime_GUID_write(file, &strf->wf.f.WAVEFORMATEXTENSIBLE.SubFormat); break; } if(strf->wf.f.WAVEFORMATEX.ext_data) quicktime_write_data(file, strf->wf.f.WAVEFORMATEX.ext_data, strf->wf.f.WAVEFORMATEX.ext_size); quicktime_atom_write_footer(file, &atom); } void quicktime_strf_dump_audio(quicktime_strf_t *strf) { switch(strf->wf.type) { case LQT_WAVEFORMAT_WAVEFORMAT: lqt_dump(" strf (WAVEFORMAT)"); break; case LQT_WAVEFORMAT_PCMWAVEFORMAT: lqt_dump(" strf (PCMWAVEFORMAT)"); break; case LQT_WAVEFORMAT_WAVEFORMATEX: lqt_dump(" strf (WAVEFORMATEX)"); break; case LQT_WAVEFORMAT_WAVEFORMATEXTENSIBLE: lqt_dump(" strf (WAVEFORMATEXTENSIBLE)"); break; } lqt_dump("\n wFormatTag: %04x\n", strf->wf.f.WAVEFORMAT.wFormatTag); /* value that identifies compression format */ lqt_dump(" nChannels: %d\n", strf->wf.f.WAVEFORMAT.nChannels); lqt_dump(" nSamplesPerSec: %d\n", strf->wf.f.WAVEFORMAT.nSamplesPerSec); lqt_dump(" nAvgBytesPerSec: %d\n", strf->wf.f.WAVEFORMAT.nAvgBytesPerSec); lqt_dump(" nBlockAlign: %d\n", strf->wf.f.WAVEFORMAT.nBlockAlign); /* size of a data sample */ switch(strf->wf.type) { case LQT_WAVEFORMAT_WAVEFORMAT: break; case LQT_WAVEFORMAT_PCMWAVEFORMAT: lqt_dump(" wBitsPerSample: %d\n", strf->wf.f.PCMWAVEFORMAT.wBitsPerSample); break; case LQT_WAVEFORMAT_WAVEFORMATEX: lqt_dump(" wBitsPerSample: %d\n", strf->wf.f.PCMWAVEFORMAT.wBitsPerSample); lqt_dump(" cbSize: %d\n", strf->wf.f.WAVEFORMATEX.cbSize); break; case LQT_WAVEFORMAT_WAVEFORMATEXTENSIBLE: lqt_dump(" wBitsPerSample: %d\n", strf->wf.f.PCMWAVEFORMAT.wBitsPerSample); lqt_dump(" cbSize: %d\n", strf->wf.f.WAVEFORMATEX.cbSize); lqt_dump(" wValidBitsPerSample: %d\n", strf->wf.f.WAVEFORMATEXTENSIBLE.Samples.wValidBitsPerSample); lqt_dump(" dwChannelMask: %d\n", strf->wf.f.WAVEFORMATEXTENSIBLE.dwChannelMask); lqt_dump(" SubFormat: "); quicktime_GUID_dump(&strf->wf.f.WAVEFORMATEXTENSIBLE.SubFormat); lqt_dump(" \n"); break; } if(strf->wf.f.WAVEFORMATEX.ext_data) { lqt_dump(" Extradata: %d bytes (hexdump follows)\n", strf->wf.f.WAVEFORMATEX.ext_size); lqt_hexdump_stdout(strf->wf.f.WAVEFORMATEX.ext_data, strf->wf.f.WAVEFORMATEX.ext_size, 16); } } void quicktime_strf_set_audio_extradata(quicktime_strf_t *strf, const uint8_t * data, int len) { strf->wf.f.WAVEFORMATEX.ext_data = malloc(len); memcpy(strf->wf.f.WAVEFORMATEX.ext_data, data, len); strf->wf.f.WAVEFORMATEX.ext_size = len; strf->wf.f.WAVEFORMATEX.cbSize += len; } void quicktime_strf_delete_audio(quicktime_strf_t *strf) { if(strf->wf.f.WAVEFORMATEX.ext_data) free(strf->wf.f.WAVEFORMATEX.ext_data); } #if 0 uint32_t biSize; /* sizeof(BITMAPINFOHEADER) */ uint32_t biWidth; uint32_t biHeight; uint16_t biPlanes; /* unused */ uint16_t biBitCount; char biCompression[4]; /* fourcc of image */ uint32_t biSizeImage; /* size of image. For uncompressed images */ /* ( biCompression 0 or 3 ) can be zero. */ uint32_t biXPelsPerMeter; /* unused */ uint32_t biYPelsPerMeter; /* unused */ uint32_t biClrUsed; /* valid only for palettized images. */ /* Number of colors in palette. */ uint32_t biClrImportant; */ #endif void quicktime_read_strf_video(quicktime_t *file, quicktime_strf_t *strf, quicktime_atom_t *parent_atom) { strf->bh.biSize = quicktime_read_int32_le(file); /* sizeof(BITMAPINFOHEADER) */ strf->bh.biWidth = quicktime_read_int32_le(file); strf->bh.biHeight = quicktime_read_int32_le(file); strf->bh.biPlanes = quicktime_read_int16_le(file); /* unused */ strf->bh.biBitCount = quicktime_read_int16_le(file); quicktime_read_data(file, (uint8_t*)strf->bh.biCompression, 4); strf->bh.biSizeImage = quicktime_read_int32_le(file); /* size of image. For uncompressed images */ /* ( biCompression 0 or 3 ) can be zero. */ strf->bh.biXPelsPerMeter = quicktime_read_int32_le(file); /* unused */ strf->bh.biYPelsPerMeter = quicktime_read_int32_le(file); /* unused */ strf->bh.biClrUsed = quicktime_read_int32_le(file); /* valid only for palettized images. */ /* Number of colors in palette. */ strf->bh.biClrImportant = quicktime_read_int32_le(file); if(parent_atom->size > 40) { strf->bh.ext_size = parent_atom->size - 40; strf->bh.ext_data = malloc(strf->bh.ext_size); quicktime_read_data(file, strf->bh.ext_data, strf->bh.ext_size); } } void quicktime_write_strf_video(quicktime_t *file, quicktime_strf_t *strf) { quicktime_atom_t atom; quicktime_atom_write_header(file, &atom, "strf"); quicktime_write_int32_le(file, strf->bh.biSize); /* sizeof(BITMAPINFOHEADER) */ quicktime_write_int32_le(file, strf->bh.biWidth); quicktime_write_int32_le(file, strf->bh.biHeight); quicktime_write_int16_le(file, strf->bh.biPlanes); /* unused */ quicktime_write_int16_le(file, strf->bh.biBitCount); quicktime_write_data(file, (uint8_t*)strf->bh.biCompression, 4); quicktime_write_int32_le(file, strf->bh.biSizeImage); /* size of image. For uncompressed images */ /* ( biCompression 0 or 3 ) can be zero. */ quicktime_write_int32_le(file, strf->bh.biXPelsPerMeter); /* unused */ quicktime_write_int32_le(file, strf->bh.biYPelsPerMeter); /* unused */ quicktime_write_int32_le(file, strf->bh.biClrUsed); /* valid only for palettized images. */ /* Number of colors in palette. */ quicktime_write_int32_le(file, strf->bh.biClrImportant); if(strf->bh.ext_data) { quicktime_write_data(file, strf->bh.ext_data, strf->bh.ext_size); } quicktime_atom_write_footer(file, &atom); } void quicktime_strf_dump_video(quicktime_strf_t *strf) { lqt_dump(" strf (BITMAPINFOHEADER)\n"); lqt_dump(" biSize: %d\n", strf->bh.biSize); /* sizeof(BITMAPINFOHEADER) */ lqt_dump(" biWidth: %d\n", strf->bh.biWidth); lqt_dump(" biHeight: %d\n", strf->bh.biHeight); lqt_dump(" biPlanes: %d\n", strf->bh.biPlanes); /* unused */ lqt_dump(" biBitCount: %d\n", strf->bh.biBitCount); lqt_dump(" biCompression: %4s\n", strf->bh.biCompression); /* fourcc of image */ lqt_dump(" biSizeImage: %d\n", strf->bh.biSizeImage); /* size of image. For uncompressed images */ /* ( biCompression 0 or 3 ) can be zero. */ lqt_dump(" biXPelsPerMeter: %d\n", strf->bh.biXPelsPerMeter); /* unused */ lqt_dump(" biYPelsPerMeter: %d\n", strf->bh.biYPelsPerMeter); /* unused */ lqt_dump(" biClrUsed: %d\n", strf->bh.biClrUsed); /* valid only for palettized images. */ /* Number of colors in palette. */ lqt_dump(" biClrImportant: %d\n", strf->bh.biClrImportant); if(strf->bh.ext_data) { lqt_dump(" Extradata: %d bytes (hexdump follows)\n", strf->bh.ext_size); lqt_hexdump_stdout(strf->bh.ext_data, strf->bh.ext_size, 16); } } void quicktime_strf_set_video_extradata(quicktime_strf_t *strf, const uint8_t * data, int len) { strf->bh.ext_data = malloc(len); memcpy(strf->bh.ext_data, data, len); strf->bh.ext_size = len; strf->bh.biSize += len; } void quicktime_strf_delete_video(quicktime_strf_t *strf) { if(strf->bh.ext_data) free(strf->bh.ext_data); } libquicktime-1.2.4/src/avi_idx1.c0000644000175000017500000001313011511622756013564 00000000000000/******************************************************************************* avi_idx1.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include typedef struct { char tag[4]; int32_t flags; int32_t offset; int32_t size; } avi_tag_t; void quicktime_delete_idx1(quicktime_idx1_t *idx1) { if(idx1->table) free(idx1->table); } void quicktime_idx1_dump(quicktime_idx1_t *idx1) { int i; lqt_dump("idx1\n"); for(i = 0; i < idx1->table_size; i++) { quicktime_idx1table_t *idx1table = idx1->table + i; lqt_dump(" T: %c%c%c%c, F: %08x, O: %d, S: %d\n", idx1table->tag[0], idx1table->tag[1], idx1table->tag[2], idx1table->tag[3], idx1table->flags, idx1table->offset, idx1table->size); } } void quicktime_read_idx1(quicktime_t *file, quicktime_riff_t *riff, quicktime_atom_t *parent_atom) { int i; quicktime_idx1_t *idx1 = &riff->idx1; // Allocate table. idx1->table_size = (parent_atom->end - quicktime_position(file)) / 16; if(idx1->table_size <= 0) { idx1->table_size = 0; return; } idx1->table_allocation = idx1->table_size; idx1->table = calloc(sizeof(quicktime_idx1table_t), idx1->table_size); // Store it in idx1 table now. // Wait for full ix table discovery before converting to stco. for(i = 0; i < idx1->table_size; i++) { quicktime_idx1table_t *idx1table = idx1->table + i; quicktime_read_data(file, (uint8_t*)(idx1table->tag), 4); idx1table->flags = quicktime_read_int32_le(file); idx1table->offset = quicktime_read_int32_le(file); idx1table->size = quicktime_read_int32_le(file); } } void quicktime_write_idx1(quicktime_t *file, quicktime_idx1_t *idx1) { int i; quicktime_idx1table_t *table = idx1->table; int table_size = idx1->table_size; // Write table quicktime_atom_write_header(file, &idx1->atom, "idx1"); for(i = 0; i < table_size; i++) { quicktime_idx1table_t *entry = &table[i]; quicktime_write_char32(file, entry->tag); quicktime_write_int32_le(file, entry->flags); quicktime_write_int32_le(file, entry->offset); quicktime_write_int32_le(file, entry->size); } quicktime_atom_write_footer(file, &idx1->atom); } void quicktime_set_idx1_keyframe(quicktime_t *file, quicktime_trak_t *trak, int new_keyframe) { quicktime_riff_t *riff = file->riff[0]; quicktime_hdrl_t *hdrl = &riff->hdrl; quicktime_strl_t *strl = hdrl->strl[trak->tkhd.track_id - 1]; char *tag = strl->tag; quicktime_idx1_t *idx1 = &riff->idx1; int i; int counter = -1; // Search through entire index for right numbered tag. // Since all the tracks are combined in the same index, this is unavoidable. for(i = 0; i < idx1->table_size; i++) { quicktime_idx1table_t *idx1_table = &idx1->table[i]; if(!memcmp(idx1_table->tag, tag, 4)) { counter++; if(counter == new_keyframe) { idx1_table->flags |= AVI_KEYFRAME; break; } } } } void quicktime_update_idx1table(quicktime_t *file, quicktime_trak_t *trak, int offset, int size) { quicktime_riff_t *riff = file->riff[0]; quicktime_strl_t *strl = trak->strl; char *tag = strl->tag; quicktime_idx1_t *idx1 = &riff->idx1; quicktime_movi_t *movi = &riff->movi; quicktime_idx1table_t *idx1_table; #if 0 int keyframe_frame = idx1->table_size + 1; // Set flag for keyframe for(i = stss->total_entries - 1; i >= 0; i--) { if(stss->table[i].sample == keyframe_frame) { flags |= AVI_KEYFRAME; break; } else if(stss->table[i].sample < keyframe_frame) { break; } } #endif // Allocation if(idx1->table_size >= idx1->table_allocation) { idx1->table_allocation += 1024; idx1->table = realloc(idx1->table, sizeof(*idx1->table) * idx1->table_allocation); memset(idx1->table + idx1->table_size, 0, sizeof(*idx1->table) * (idx1->table_allocation - idx1->table_size)); } // Appendage idx1_table = &idx1->table[idx1->table_size]; memcpy(idx1_table->tag, tag, 4); if(trak->mdia.minf.is_audio || !trak->mdia.minf.stbl.stss.total_entries) idx1_table->flags = AVI_KEYFRAME; else idx1_table->flags = 0; idx1_table->offset = offset - 8 - movi->atom.start; idx1_table->size = size; idx1->table_size++; } libquicktime-1.2.4/depcomp0000755000175000017500000004426711735135716012524 00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2009-04-28.21; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free # Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, 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 . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by `PROGRAMS ARGS'. object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputing dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u="sed s,\\\\\\\\,/,g" depmode=msvisualcpp fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add `dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two # compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.o.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: libquicktime-1.2.4/utils/0000755000175000017500000000000011735135733012351 500000000000000libquicktime-1.2.4/utils/qtstreamize.c0000644000175000017500000000256711511622757015016 00000000000000/******************************************************************************* qtstreamize.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include int main(int argc, char *argv[]) { if(argc < 3 || argv[1][0] == '-') { printf("usage: %s \n", argv[0]); exit(1); } if(quicktime_make_streamable(argv[1], argv[2])) exit(1); return 0; } libquicktime-1.2.4/utils/test_codec.c0000644000175000017500000000351611511622757014555 00000000000000/******************************************************************************* test_codec.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ /*************************************************** * This program prints informations about all * installed libquicktime codecs ***************************************************/ #include "lqt_private.h" #include "lqt_codecinfo_private.h" #include int main() { int num; int i; /* Initialize codecs */ fprintf(stderr, "Libquicktime codec test, Codec API Version %d\n", lqt_get_codec_api_version()); lqt_registry_init(); #if 1 num = lqt_get_num_audio_codecs(); for(i = 0; i < num; i++) { lqt_dump_codec_info(lqt_get_audio_codec_info(i)); } num = lqt_get_num_video_codecs(); for(i = 0; i < num; i++) { lqt_dump_codec_info(lqt_get_video_codec_info(i)); } #endif return 0; } libquicktime-1.2.4/utils/common.h0000644000175000017500000000220111511622757013724 00000000000000/******************************************************************************* common.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ void quicktime_print_info(quicktime_t * qtfile); libquicktime-1.2.4/utils/qtinfo.c0000644000175000017500000000370111511622757013735 00000000000000/******************************************************************************* qtinfo.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include #include #include #include #include "common.h" #include #include // ONLY for the PACKAGE macro. Usually, applications never need // to include config.h #define _(str) dgettext(PACKAGE, str) static void file_info(char *filename) { quicktime_t* qtfile; qtfile = quicktime_open(filename, 1, 0); if(!qtfile) { printf(_("Couldn't open %s\n"), filename); return; } quicktime_print_info(qtfile); quicktime_close(qtfile); } int main(int argc, char *argv[]) { int i; setlocale(LC_MESSAGES, ""); setlocale(LC_CTYPE, ""); bindtextdomain(PACKAGE, LOCALE_DIR); if(argc < 2) { printf(_("Usage: %s filename...\n"), argv[0]); return 1; } for(i = 1; i < argc; i++) { file_info(argv[i]); } return 0; } libquicktime-1.2.4/utils/cpuinfo.c0000644000175000017500000002437611260501244014077 00000000000000/* small utility to extract CPU information Used by configure to set CPU optimization levels on some operating systems where /proc/cpuinfo is non-existent or unreliable. */ #include #include #include #include #include #if defined(__MINGW32__) && (__MINGW32_MAJOR_VERSION <= 3) && (__MINGW32_MINOR_VERSION < 10) #include void gettimeofday(struct timeval* t,void* timezone) { struct timeb timebuffer; ftime( &timebuffer ); t->tv_sec=timebuffer.time; t->tv_usec=1000*timebuffer.millitm; } #endif #ifdef __MINGW32__ #define MISSING_USLEEP #include #define sleep(t) Sleep(1000*t); #endif #ifdef __BEOS__ #define usleep(t) snooze(t) #endif #ifdef M_UNIX typedef long long int64_t; #define MISSING_USLEEP #else #include #endif #define CPUID_FEATURE_DEF(bit, desc, description) \ { bit, desc } typedef struct cpuid_regs { unsigned int eax; unsigned int ebx; unsigned int ecx; unsigned int edx; } cpuid_regs_t; static cpuid_regs_t cpuid(int func) { cpuid_regs_t regs; #define CPUID ".byte 0x0f, 0xa2; " #ifdef __x86_64__ asm("mov %%rbx, %%rsi\n\t" #else asm("mov %%ebx, %%esi\n\t" #endif CPUID"\n\t" #ifdef __x86_64__ "xchg %%rsi, %%rbx\n\t" #else "xchg %%esi, %%ebx\n\t" #endif : "=a" (regs.eax), "=S" (regs.ebx), "=c" (regs.ecx), "=d" (regs.edx) : "0" (func)); return regs; } static int64_t rdtsc(void) { uint64_t i; #define RDTSC ".byte 0x0f, 0x31; " asm volatile (RDTSC : "=A"(i) : ); return i; } static const char* brandname(int i) { const static char* brandmap[] = { NULL, "Intel(R) Celeron(R) processor", "Intel(R) Pentium(R) III processor", "Intel(R) Pentium(R) III Xeon(tm) processor", "Intel(R) Pentium(R) III processor", NULL, "Mobile Intel(R) Pentium(R) III processor-M", "Mobile Intel(R) Celeron(R) processor" }; if (i >= sizeof(brandmap)) return NULL; else return brandmap[i]; } static void store32(char *d, unsigned int v) { d[0] = v & 0xff; d[1] = (v >> 8) & 0xff; d[2] = (v >> 16) & 0xff; d[3] = (v >> 24) & 0xff; } int main(int argc, char **argv) { cpuid_regs_t regs, regs_ext; char idstr[13]; unsigned max_cpuid; unsigned max_ext_cpuid; unsigned int amd_flags; unsigned int amd_flags2; const char *model_name = NULL; int i; char processor_name[49]; regs = cpuid(0); max_cpuid = regs.eax; /* printf("%d CPUID function codes\n", max_cpuid+1); */ store32(idstr+0, regs.ebx); store32(idstr+4, regs.edx); store32(idstr+8, regs.ecx); idstr[12] = 0; printf("vendor_id\t: %s\n", idstr); regs_ext = cpuid((1<<31) + 0); max_ext_cpuid = regs_ext.eax; if (max_ext_cpuid >= (1<<31) + 1) { regs_ext = cpuid((1<<31) + 1); amd_flags = regs_ext.edx; amd_flags2 = regs_ext.ecx; if (max_ext_cpuid >= (1<<31) + 4) { for (i = 2; i <= 4; i++) { regs_ext = cpuid((1<<31) + i); store32(processor_name + (i-2)*16, regs_ext.eax); store32(processor_name + (i-2)*16 + 4, regs_ext.ebx); store32(processor_name + (i-2)*16 + 8, regs_ext.ecx); store32(processor_name + (i-2)*16 + 12, regs_ext.edx); } processor_name[48] = 0; model_name = processor_name; while (*model_name == ' ') { model_name++; } } } else { amd_flags = 0; amd_flags2 = 0; } if (max_cpuid >= 1) { static struct { int bit; char *desc; } cap[] = { CPUID_FEATURE_DEF(0, "fpu", "Floating-point unit on-chip"), CPUID_FEATURE_DEF(1, "vme", "Virtual Mode Enhancements"), CPUID_FEATURE_DEF(2, "de", "Debugging Extension"), CPUID_FEATURE_DEF(3, "pse", "Page Size Extension"), CPUID_FEATURE_DEF(4, "tsc", "Time Stamp Counter"), CPUID_FEATURE_DEF(5, "msr", "Pentium Processor MSR"), CPUID_FEATURE_DEF(6, "pae", "Physical Address Extension"), CPUID_FEATURE_DEF(7, "mce", "Machine Check Exception"), CPUID_FEATURE_DEF(8, "cx8", "CMPXCHG8B Instruction Supported"), CPUID_FEATURE_DEF(9, "apic", "On-chip APIC Hardware Enabled"), CPUID_FEATURE_DEF(11, "sep", "SYSENTER and SYSEXIT"), CPUID_FEATURE_DEF(12, "mtrr", "Memory Type Range Registers"), CPUID_FEATURE_DEF(13, "pge", "PTE Global Bit"), CPUID_FEATURE_DEF(14, "mca", "Machine Check Architecture"), CPUID_FEATURE_DEF(15, "cmov", "Conditional Move/Compare Instruction"), CPUID_FEATURE_DEF(16, "pat", "Page Attribute Table"), CPUID_FEATURE_DEF(17, "pse36", "Page Size Extension 36-bit"), CPUID_FEATURE_DEF(18, "pn", "Processor Serial Number"), CPUID_FEATURE_DEF(19, "clflush", "CFLUSH instruction"), CPUID_FEATURE_DEF(21, "dts", "Debug Store"), CPUID_FEATURE_DEF(22, "acpi", "Thermal Monitor and Clock Ctrl"), CPUID_FEATURE_DEF(23, "mmx", "MMX Technology"), CPUID_FEATURE_DEF(24, "fxsr", "FXSAVE/FXRSTOR"), CPUID_FEATURE_DEF(25, "sse", "SSE Extensions"), CPUID_FEATURE_DEF(26, "sse2", "SSE2 Extensions"), CPUID_FEATURE_DEF(27, "ss", "Self Snoop"), CPUID_FEATURE_DEF(28, "ht", "Multi-threading"), CPUID_FEATURE_DEF(29, "tm", "Therm. Monitor"), CPUID_FEATURE_DEF(30, "ia64", "IA-64 Processor"), CPUID_FEATURE_DEF(31, "pbe", "Pend. Brk. EN."), { -1 } }; static struct { int bit; char *desc; } cap2[] = { CPUID_FEATURE_DEF(0, "pni", "SSE3 Extensions"), CPUID_FEATURE_DEF(3, "monitor", "MONITOR/MWAIT"), CPUID_FEATURE_DEF(4, "ds_cpl", "CPL Qualified Debug Store"), CPUID_FEATURE_DEF(5, "vmx", "Virtual Machine Extensions"), CPUID_FEATURE_DEF(6, "smx", "Safer Mode Extensions"), CPUID_FEATURE_DEF(7, "est", "Enhanced Intel SpeedStep Technology"), CPUID_FEATURE_DEF(8, "tm2", "Thermal Monitor 2"), CPUID_FEATURE_DEF(9, "ssse3", "Supplemental SSE3"), CPUID_FEATURE_DEF(10, "cid", "L1 Context ID"), CPUID_FEATURE_DEF(13, "cx16", "CMPXCHG16B Available"), CPUID_FEATURE_DEF(14, "xtpr", "xTPR Disable"), CPUID_FEATURE_DEF(15, "pdcm", "Perf/Debug Capability MSR"), CPUID_FEATURE_DEF(18, "dca", "Direct Cache Access"), CPUID_FEATURE_DEF(19, "sse41", "SSE4.1 Extensions"), CPUID_FEATURE_DEF(20, "sse42", "SSE4.2 Extensions"), CPUID_FEATURE_DEF(23, "popcnt", "Pop Count Instruction"), { -1 } }; static struct { int bit; char *desc; } cap_amd[] = { CPUID_FEATURE_DEF(11, "syscall", "SYSCALL and SYSRET"), CPUID_FEATURE_DEF(19, "mp", "MP Capable"), CPUID_FEATURE_DEF(20, "nx", "No-Execute Page Protection"), CPUID_FEATURE_DEF(22, "mmxext", "MMX Technology (AMD Extensions)"), CPUID_FEATURE_DEF(25, "fxsr_opt", "Fast FXSAVE/FXRSTOR"), CPUID_FEATURE_DEF(26, "pdpe1gb", "PDP Entry for 1GiB Page"), CPUID_FEATURE_DEF(27, "rdtscp", "RDTSCP Instruction"), CPUID_FEATURE_DEF(29, "lm", "Long Mode Capable"), CPUID_FEATURE_DEF(30, "3dnowext", "3DNow! Extensions"), CPUID_FEATURE_DEF(31, "3dnow", "3DNow!"), { -1 } }; static struct { int bit; char *desc; } cap_amd2[] = { CPUID_FEATURE_DEF(0, "lahf_lm", "LAHF/SAHF Supported in 64-bit Mode"), CPUID_FEATURE_DEF(1, "cmp_legacy", "Chip Multi-Core"), CPUID_FEATURE_DEF(2, "svm", "Secure Virtual Machine"), CPUID_FEATURE_DEF(3, "extapic", "Extended APIC Space"), CPUID_FEATURE_DEF(4, "cr8legacy", "CR8 Available in Legacy Mode"), CPUID_FEATURE_DEF(5, "abm", "Advanced Bit Manipulation"), CPUID_FEATURE_DEF(6, "sse4a", "SSE4A Extensions"), CPUID_FEATURE_DEF(7, "misalignsse", "Misaligned SSE Mode"), CPUID_FEATURE_DEF(8, "3dnowprefetch", "3DNow! Prefetch/PrefetchW"), CPUID_FEATURE_DEF(9, "osvw", "OS Visible Workaround"), CPUID_FEATURE_DEF(10, "ibs", "Instruction Based Sampling"), { -1 } }; unsigned int family, model, stepping; regs = cpuid(1); family = (regs.eax >> 8) & 0xf; model = (regs.eax >> 4) & 0xf; stepping = regs.eax & 0xf; if (family == 0xf) family += (regs.eax >> 20) & 0xff; if (family == 0xf || family == 6) model += ((regs.eax >> 16) & 0xf) << 4; printf("cpu family\t: %d\n" "model\t\t: %d\n" "stepping\t: %d\n" , family, model, stepping); if (strstr(idstr, "Intel") && !model_name) { if (family == 6 && model == 0xb && stepping == 1) model_name = "Intel (R) Celeron (R) processor"; else model_name = brandname(regs.ebx & 0xf); } printf("flags\t\t:"); for (i = 0; cap[i].bit >= 0; i++) { if (regs.edx & (1 << cap[i].bit)) { printf(" %s", cap[i].desc); } } for (i = 0; cap2[i].bit >= 0; i++) { if (regs.ecx & (1 << cap2[i].bit)) { printf(" %s", cap2[i].desc); } } /* k6_mtrr is supported by some AMD K6-2/K6-III CPUs but it is not indicated by a CPUID feature bit, so we have to check the family, model and stepping instead. */ if (strstr(idstr, "AMD") && family == 5 && (model >= 9 || model == 8 && stepping >= 8)) printf(" %s", "k6_mtrr"); /* similar for cyrix_arr. */ if (strstr(idstr, "Cyrix") && (family == 5 && model < 4 || family == 6)) printf(" %s", "cyrix_arr"); /* as well as centaur_mcr. */ if (strstr(idstr, "Centaur") && family == 5) printf(" %s", "centaur_mcr"); for (i = 0; cap_amd[i].bit >= 0; i++) { if (amd_flags & (1 << cap_amd[i].bit)) { printf(" %s", cap_amd[i].desc); } } for (i = 0; cap_amd2[i].bit >= 0; i++) { if (amd_flags2 & (1 << cap_amd2[i].bit)) { printf(" %s", cap_amd2[i].desc); } } printf("\n"); if (regs.edx & (1 << 4)) { int64_t tsc_start, tsc_end; struct timeval tv_start, tv_end; int usec_delay; tsc_start = rdtsc(); gettimeofday(&tv_start, NULL); #ifdef MISSING_USLEEP sleep(1); #else usleep(100000); #endif tsc_end = rdtsc(); gettimeofday(&tv_end, NULL); usec_delay = 1000000 * (tv_end.tv_sec - tv_start.tv_sec) + (tv_end.tv_usec - tv_start.tv_usec); printf("cpu MHz\t\t: %.3f\n", (double)(tsc_end-tsc_start) / usec_delay); } } printf("model name\t: "); if (model_name) printf("%s\n", model_name); else printf("Unknown %s CPU\n", idstr); } libquicktime-1.2.4/utils/testqt.c0000644000175000017500000001267611511622757013774 00000000000000/******************************************************************************* testqt.c libquicktime - A library for reading and writing quicktime/avi/mp4 files. http://libquicktime.sourceforge.net Copyright (C) 2002 Heroine Virtual Ltd. Copyright (C) 2002-2011 Members of the libquicktime project. 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 *******************************************************************************/ #include "lqt_private.h" #include #include #include int main(int argc, char** argv) { char *pcInputFN = argv[1]; char *pcOutputFN = argv[2]; char *pcAudioPrefix = argv[3]; int i; quicktime_t *pxQuicktimeInput; quicktime_t *pxQuicktimeOutput; if( argc != 4 ) { printf( "usage: testqt