diff -Nru exempi-2.5.2/aclocal.m4 exempi-2.6.1/aclocal.m4 --- exempi-2.5.2/aclocal.m4 2020-06-24 01:39:50.000000000 +0000 +++ exempi-2.6.1/aclocal.m4 2022-02-13 05:34:24.000000000 +0000 @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.16.1 -*- Autoconf -*- +# generated automatically by aclocal 1.16.2 -*- Autoconf -*- -# Copyright (C) 1996-2018 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -20,7 +20,7 @@ If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) -# Copyright (C) 2002-2018 Free Software Foundation, Inc. +# Copyright (C) 2002-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -35,7 +35,7 @@ [am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.16.1], [], +m4_if([$1], [1.16.2], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,14 +51,14 @@ # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.16.1])dnl +[AM_AUTOMAKE_VERSION([1.16.2])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -110,7 +110,7 @@ # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997-2018 Free Software Foundation, Inc. +# Copyright (C) 1997-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -141,7 +141,7 @@ Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# Copyright (C) 1999-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -332,7 +332,7 @@ # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# Copyright (C) 1999-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -371,7 +371,9 @@ done if test $am_rc -ne 0; then AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments - for automatic dependency tracking. Try re-running configure with the + for automatic dependency tracking. If GNU make was not used, consider + re-running the configure script with MAKE="gmake" (or whatever is + necessary). You can also try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking).]) fi @@ -398,7 +400,7 @@ # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2018 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -595,7 +597,7 @@ done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -616,7 +618,7 @@ fi AC_SUBST([install_sh])]) -# Copyright (C) 2003-2018 Free Software Foundation, Inc. +# Copyright (C) 2003-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -638,7 +640,7 @@ # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering -# Copyright (C) 1996-2018 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -673,7 +675,7 @@ # Check to see how 'make' treats includes. -*- Autoconf -*- -# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -716,7 +718,7 @@ # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2018 Free Software Foundation, Inc. +# Copyright (C) 1997-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -755,7 +757,7 @@ # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -784,7 +786,7 @@ AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# Copyright (C) 1999-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -831,7 +833,7 @@ # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) -# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -850,7 +852,7 @@ # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2018 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -931,7 +933,7 @@ rm -f conftest.file ]) -# Copyright (C) 2009-2018 Free Software Foundation, Inc. +# Copyright (C) 2009-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -991,7 +993,7 @@ _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) -# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1019,7 +1021,7 @@ INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2018 Free Software Foundation, Inc. +# Copyright (C) 2006-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1038,7 +1040,7 @@ # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2018 Free Software Foundation, Inc. +# Copyright (C) 2004-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff -Nru exempi-2.5.2/build/GNUmakefile.in exempi-2.6.1/build/GNUmakefile.in --- exempi-2.5.2/build/GNUmakefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/build/GNUmakefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# GNUmakefile.in generated by automake 1.16.1 from GNUmakefile.am. +# GNUmakefile.in generated by automake 1.16.2 from GNUmakefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -317,6 +317,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/build/XMP_BuildInfo.h exempi-2.6.1/build/XMP_BuildInfo.h --- exempi-2.5.2/build/XMP_BuildInfo.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/build/XMP_BuildInfo.h 2021-11-18 03:53:54.000000000 +0000 @@ -3,15 +3,15 @@ /* // ================================================================================================= -// Copyright 2002 Adobe Systems Incorporated +// Copyright 2002 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= */ -#define kXMP_Copyright Copyright (c) 2016 -#define kXMP_CopyrightStr "Copyright (c) 2016" +#define kXMP_Copyright Copyright (c) 2019 +#define kXMP_CopyrightStr "Copyright (c) 2019" #endif /* __XMP_BuildInfo_h__ */ diff -Nru exempi-2.5.2/CODE_OF_CONDUCT.md exempi-2.6.1/CODE_OF_CONDUCT.md --- exempi-2.5.2/CODE_OF_CONDUCT.md 1970-01-01 00:00:00.000000000 +0000 +++ exempi-2.6.1/CODE_OF_CONDUCT.md 2021-11-18 03:53:53.000000000 +0000 @@ -0,0 +1,74 @@ +# Adobe Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at Grp-opensourceoffice@adobe.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff -Nru exempi-2.5.2/configure exempi-2.6.1/configure --- exempi-2.5.2/configure 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/configure 2022-02-13 05:34:26.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for exempi 2.5.2. +# Generated by GNU Autoconf 2.69 for exempi 2.6.1. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -587,8 +587,8 @@ # Identity of this package. PACKAGE_NAME='exempi' PACKAGE_TARNAME='exempi' -PACKAGE_VERSION='2.5.2' -PACKAGE_STRING='exempi 2.5.2' +PACKAGE_VERSION='2.6.1' +PACKAGE_STRING='exempi 2.6.1' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -762,6 +762,7 @@ docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -856,6 +857,7 @@ sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1108,6 +1110,15 @@ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1245,7 +1256,7 @@ for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1358,7 +1369,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures exempi 2.5.2 to adapt to many kinds of systems. +\`configure' configures exempi 2.6.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1398,6 +1409,7 @@ --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -1428,7 +1440,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of exempi 2.5.2:";; + short | recursive ) echo "Configuration of exempi 2.6.1:";; esac cat <<\_ACEOF @@ -1553,7 +1565,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -exempi configure 2.5.2 +exempi configure 2.6.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2126,7 +2138,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by exempi $as_me 2.5.2, which was +It was created by exempi $as_me 2.6.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2989,7 +3001,7 @@ # Define the identity of the package. PACKAGE='exempi' - VERSION='2.5.2' + VERSION='2.6.1' cat >>confdefs.h <<_ACEOF @@ -3146,11 +3158,11 @@ AM_BACKSLASH='\' -EXEMPI_REVISION=2 +EXEMPI_REVISION=1 -EXEMPI_AGE=0 +EXEMPI_AGE=1 -EXEMPI_CURRENT=8 +EXEMPI_CURRENT=9 EXEMPI_CURRENT_MIN=`expr $EXEMPI_CURRENT - $EXEMPI_AGE` @@ -18769,7 +18781,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by exempi $as_me 2.5.2, which was +This file was extended by exempi $as_me 2.6.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -18826,7 +18838,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -exempi config.status 2.5.2 +exempi config.status 2.6.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -19867,7 +19879,9 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "Something went wrong bootstrapping makefile fragments - for automatic dependency tracking. Try re-running configure with the + for automatic dependency tracking. If GNU make was not used, consider + re-running the configure script with MAKE=\"gmake\" (or whatever is + necessary). You can also try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking). See \`config.log' for more details" "$LINENO" 5; } diff -Nru exempi-2.5.2/configure.ac exempi-2.6.1/configure.ac --- exempi-2.5.2/configure.ac 2020-06-24 01:39:38.000000000 +0000 +++ exempi-2.6.1/configure.ac 2022-02-13 05:34:02.000000000 +0000 @@ -8,7 +8,7 @@ dnl the same distribution terms as the rest of that program. AC_PREREQ(2.50) -AC_INIT(exempi,2.5.2) +AC_INIT(exempi,2.6.1) AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects]) AM_MAINTAINER_MODE m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])]) @@ -67,9 +67,11 @@ dnl 2.5.0 is the revision 8.0.0 -- Removed XMP SDK symbols. dnl 2.5.1 is the revision 8.0.1 dnl 2.5.2 is the revision 8.0.2 -AC_SUBST([EXEMPI_REVISION], [2]) -AC_SUBST([EXEMPI_AGE], [0]) -AC_SUBST([EXEMPI_CURRENT], [8]) +dnl 2.6.0 is the revision 9.1.0 +dnl 2.6.1 is the revision 9.1.1 +AC_SUBST([EXEMPI_REVISION], [1]) +AC_SUBST([EXEMPI_AGE], [1]) +AC_SUBST([EXEMPI_CURRENT], [9]) AC_SUBST([EXEMPI_CURRENT_MIN], [`expr $EXEMPI_CURRENT - $EXEMPI_AGE`]) AC_SUBST([EXEMPI_VERSION_INFO], diff -Nru exempi-2.5.2/CONTRIBUTING.md exempi-2.6.1/CONTRIBUTING.md --- exempi-2.5.2/CONTRIBUTING.md 1970-01-01 00:00:00.000000000 +0000 +++ exempi-2.6.1/CONTRIBUTING.md 2021-11-18 03:53:53.000000000 +0000 @@ -0,0 +1,47 @@ +# Contributing + +Thanks for choosing to contribute! + +The following are a set of guidelines to follow when contributing to this project. + +## Code Of Conduct + +This project adheres to the Adobe [code of conduct](https://github.com/adobe/XMP-Toolkit-SDK/blob/master/CODE_OF_CONDUCT.md). By participating, +you are expected to uphold this code. Please report unacceptable behavior to +[Grp-opensourceoffice@adobe.com](mailto:Grp-opensourceoffice@adobe.com). + +## Have A Question? + +Start by filing an issue. The existing committers on this project work to reach +consensus around project direction and issue solutions within issue threads +(when appropriate). + +## Contributor License Agreement + +All third-party contributions to this project must be accompanied by a signed contributor +license agreement. This gives Adobe permission to redistribute your contributions +as part of the project. [Sign our CLA](http://opensource.adobe.com/cla.html) . You +only need to submit an Adobe CLA one time, so if you have submitted one previously, +you are good to go! + +## Code Reviews + +All submissions should come in the form of pull requests and need to be reviewed +by project committers. Read [GitHub's pull request documentation](https://help.github.com/articles/about-pull-requests/) +for more information on sending pull requests. + +Lastly, please follow the pull request template when +submitting a pull request! + +## From Contributor To Committer + +We love contributions from our community! If you'd like to go a step beyond contributor +and become a committer with full write access and a say in the project, you must +be invited to the project. The existing committers employ an internal nomination +process that must reach lazy consensus (silence is approval) before invitations +are issued. If you feel you are qualified and want to get more deeply involved, +feel free to reach out to existing committers to have a conversation about that. + +## Security Issues + +Security issues shouldn't be reported on this issue tracker. Instead, [file an issue to our security experts](https://helpx.adobe.com/security/alertus.html) diff -Nru exempi-2.5.2/debian/changelog exempi-2.6.1/debian/changelog --- exempi-2.5.2/debian/changelog 2021-10-07 10:11:26.000000000 +0000 +++ exempi-2.6.1/debian/changelog 2022-06-15 04:13:07.000000000 +0000 @@ -1,8 +1,26 @@ -exempi (2.5.2-1build1) impish; urgency=medium +exempi (2.6.1-2) unstable; urgency=medium - * No-change rebuild to build packages with zstd compression. + * XMPFiles/source/XMPFiles_Impl.cpp: fix arm build with gcc 10 + (Closes: #1009733) - -- Matthias Klose Thu, 07 Oct 2021 12:11:26 +0200 + -- Michael Biebl Wed, 15 Jun 2022 06:13:07 +0200 + +exempi (2.6.1-1) unstable; urgency=medium + + * New upstream version 2.6.1 + * Ship README.md and README-Adobe.md + * Update debian/watch to version 4 + + -- Michael Biebl Sun, 13 Feb 2022 19:15:36 +0100 + +exempi (2.6.0-1) unstable; urgency=medium + + * New upstream version 2.6.0 + * Drop override for dh_missing + * Bump Standards-Version to 4.6.0 + * Drop README and TODO from dh_installdocs override + + -- Michael Biebl Sun, 13 Feb 2022 10:54:23 +0100 exempi (2.5.2-1) unstable; urgency=medium diff -Nru exempi-2.5.2/debian/control exempi-2.6.1/debian/control --- exempi-2.5.2/debian/control 2020-06-24 13:52:18.000000000 +0000 +++ exempi-2.6.1/debian/control 2022-06-15 04:13:07.000000000 +0000 @@ -5,7 +5,7 @@ Build-Depends: debhelper-compat (= 13), libexpat1-dev, zlib1g-dev, -Standards-Version: 4.5.0 +Standards-Version: 4.6.0 Rules-Requires-Root: no Vcs-Git: https://salsa.debian.org/debian/exempi.git Vcs-Browser: https://salsa.debian.org/debian/exempi diff -Nru exempi-2.5.2/debian/patches/0001-XMPFiles-source-XMPFiles_Impl.cpp-fix-arm-build-with.patch exempi-2.6.1/debian/patches/0001-XMPFiles-source-XMPFiles_Impl.cpp-fix-arm-build-with.patch --- exempi-2.5.2/debian/patches/0001-XMPFiles-source-XMPFiles_Impl.cpp-fix-arm-build-with.patch 1970-01-01 00:00:00.000000000 +0000 +++ exempi-2.6.1/debian/patches/0001-XMPFiles-source-XMPFiles_Impl.cpp-fix-arm-build-with.patch 2022-06-15 04:13:07.000000000 +0000 @@ -0,0 +1,37 @@ +From: Fabrice Fontaine +Date: Thu, 17 Mar 2022 17:27:28 +0100 +Subject: XMPFiles/source/XMPFiles_Impl.cpp: fix arm build with gcc 10 + +Fix the following build failure with exempi on arm with gcc 10 raised +since version 2.6.0 and +https://gitlab.freedesktop.org/libopenraw/exempi/-/commit/0872e35a30457d2ecf746a1bebdb7d94636d0e2f +https://github.com/adobe/XMP-Toolkit-SDK/commit/0872e35a30457d2ecf746a1bebdb7d94636d0e2f: + +/home/giuliobenetti/autobuild/run/instance-3/output-1/host/lib/gcc/arm-buildroot-linux-uclibcgnueabi/10.3.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: ../../XMPFiles/source/.libs/libXMPFiles.a(XMPFiles_Impl.o):(.rodata+0x5c): multiple definition of `typeinfo name for TXMPMeta, std::allocator > >'; XMPFilesCoverage.o:(.rodata+0x0): first defined here + +More information can be found on a similar issue here: +https://github.com/OpenKinect/libfreenect2/issues/157 + +Fixes: + - http://autobuild.buildroot.org/results/c440719de02a154c6bdae11bda06ea30c131c71d + +Signed-off-by: Fabrice Fontaine +--- + XMPFiles/source/XMPFiles_Impl.cpp | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/XMPFiles/source/XMPFiles_Impl.cpp b/XMPFiles/source/XMPFiles_Impl.cpp +index 2f918ac..ff45040 100644 +--- a/XMPFiles/source/XMPFiles_Impl.cpp ++++ b/XMPFiles/source/XMPFiles_Impl.cpp +@@ -47,7 +47,9 @@ using namespace std; + /// This file ... + /// + // ================================================================================================= +-#include "public/include/XMP.incl_cpp" ++#if ! XMP_StaticBuild ++ #include "public/include/XMP.incl_cpp" ++#endif + + #if XMP_WinBuild + #pragma warning ( disable : 4290 ) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) diff -Nru exempi-2.5.2/debian/patches/series exempi-2.6.1/debian/patches/series --- exempi-2.5.2/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ exempi-2.6.1/debian/patches/series 2022-06-15 04:13:07.000000000 +0000 @@ -0,0 +1 @@ +0001-XMPFiles-source-XMPFiles_Impl.cpp-fix-arm-build-with.patch diff -Nru exempi-2.5.2/debian/rules exempi-2.6.1/debian/rules --- exempi-2.5.2/debian/rules 2020-06-24 13:52:18.000000000 +0000 +++ exempi-2.6.1/debian/rules 2022-06-15 04:13:07.000000000 +0000 @@ -9,11 +9,8 @@ dh_auto_configure -- --disable-unittest override_dh_installdocs: - dh_installdocs --all AUTHORS NEWS README TODO + dh_installdocs --all AUTHORS NEWS README.md README-Adobe.md override_dh_install: find debian/tmp -name '*.la' -print -delete dh_install - -dh_missing: - dh_missing --fail-missing diff -Nru exempi-2.5.2/debian/watch exempi-2.6.1/debian/watch --- exempi-2.5.2/debian/watch 2020-06-24 13:52:18.000000000 +0000 +++ exempi-2.6.1/debian/watch 2022-06-15 04:13:07.000000000 +0000 @@ -1,2 +1,2 @@ -version=3 -opts=pgpsigurlmangle=s/$/.asc/ https://libopenraw.freedesktop.org/exempi/ .*/exempi-(.*)\.tar\.(?:gz|bz2|xz) +version=4 +opts=pgpsigurlmangle=s/$/.asc/ https://libopenraw.freedesktop.org/@PACKAGE@/ .*/@PACKAGE@@ANY_VERSION@@ARCHIVE_EXT@ diff -Nru exempi-2.5.2/exempi/doc/Makefile.in exempi-2.6.1/exempi/doc/Makefile.in --- exempi-2.5.2/exempi/doc/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/exempi/doc/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -296,6 +296,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/exempi/Makefile.in exempi-2.6.1/exempi/Makefile.in --- exempi-2.5.2/exempi/Makefile.in 2020-06-24 02:13:11.000000000 +0000 +++ exempi-2.6.1/exempi/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -774,6 +774,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/Makefile.am exempi-2.6.1/Makefile.am --- exempi-2.5.2/Makefile.am 2019-07-28 02:00:47.000000000 +0000 +++ exempi-2.6.1/Makefile.am 2022-02-13 15:00:19.000000000 +0000 @@ -39,4 +39,5 @@ SUBDIRS = third-party source XMPCore XMPFiles samples exempi DIST_SUBDIRS = build third-party source XMPCore XMPFiles XMPFilesPlugins samples exempi public -EXTRA_DIST = autogen.sh ORIGINSTORY.md +EXTRA_DIST = autogen.sh ORIGINSTORY.md CODE_OF_CONDUCT.md CONTRIBUTING.md \ + README-Adobe.md README.md diff -Nru exempi-2.5.2/Makefile.in exempi-2.6.1/Makefile.in --- exempi-2.5.2/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/Makefile.in 2022-02-13 15:00:45.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -201,8 +201,8 @@ CTAGS = ctags CSCOPE = cscope am__DIST_COMMON = $(srcdir)/Makefile.in AUTHORS COPYING ChangeLog \ - INSTALL NEWS README TODO compile config.guess config.sub \ - depcomp install-sh ltmain.sh missing + INSTALL NEWS TODO compile config.guess config.sub depcomp \ + install-sh ltmain.sh missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) @@ -377,6 +377,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -388,7 +389,9 @@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS = third-party source XMPCore XMPFiles samples exempi DIST_SUBDIRS = build third-party source XMPCore XMPFiles XMPFilesPlugins samples exempi public -EXTRA_DIST = autogen.sh ORIGINSTORY.md +EXTRA_DIST = autogen.sh ORIGINSTORY.md CODE_OF_CONDUCT.md CONTRIBUTING.md \ + README-Adobe.md README.md + all: all-recursive .SUFFIXES: @@ -623,6 +626,10 @@ tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) +dist-zstd: distdir + tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst + $(am__post_remove_distdir) + dist-tarZ: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @@ -665,6 +672,8 @@ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ + *.tar.zst*) \ + zstd -dc $(distdir).tar.zst | $(am__untar) ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) @@ -842,17 +851,18 @@ am--refresh check check-am clean clean-cscope clean-generic \ clean-libtool cscope cscopelist-am ctags ctags-am dist \ dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \ - dist-xz dist-zip distcheck distclean distclean-generic \ - distclean-libtool distclean-tags distcleancheck distdir \ - distuninstallcheck 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-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ - ps ps-am tags tags-am uninstall uninstall-am + dist-xz dist-zip dist-zstd distcheck distclean \ + distclean-generic distclean-libtool distclean-tags \ + distcleancheck distdir distuninstallcheck 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-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am .PRECIOUS: Makefile diff -Nru exempi-2.5.2/NEWS exempi-2.6.1/NEWS --- exempi-2.5.2/NEWS 2020-06-24 03:49:05.000000000 +0000 +++ exempi-2.6.1/NEWS 2022-02-13 15:01:39.000000000 +0000 @@ -1,3 +1,39 @@ +2.6.1 - + +- Bug #26: Addressed missing README.md and others from tarball. + https://gitlab.freedesktop.org/libopenraw/exempi/-/issues/26 + +2.6.0 - 2022/02/13 + +- Update XMPCore to Adobe XMP SDK v2021.10 + (issue https://gitlab.freedesktop.org/libopenraw/exempi/-/issues/22) + - Changes in v2021.10 + - Fixing CTECHXMP-4170583, CTECHXMP-4170596, CTECHXMP-4170597, + CTECHXMP-4170598, CTECHXMP-4170599, CTECHXMP-4170632 and CTECHXMP-4170633 + (maintainer note: no idea what they are, but it seems to fix various buffer + size issues in WAVE and SVG) + - Changes in v2021.08 + - Security Fixes + - Fixes syntax errors like semicolons in the codebase + - Copyright note changes across the codebase + - Fixes broken license link in Read.md + - Fully implements kXMPFiles_OpenOnlyXMP flag for MPEG4 + - Changes in v2021.07 + - Security Fixes + - Write Exif 2.3.1 Time Zone Metadata - XMPFiles Should Read/Write + - Removal of words Master/Slave/Blacklist/Whitelist from codebase + - cmake scripts use --version instead of -dumpversion to get complete + gcc version string + - Updating ReadMe.txt + - Changes in v2020.1 + - iOS project generation issue + - iOS compilation issue with libc++ + - Android support with cmake version 3.6 + - CMake upgrade to version 3.15 (except for android) + - Add XCode 10.2 support + - Add VS2017 support + - Some fixes previously done in Exempi are now upstream. + 2.5.2 - 2020/06/24 - Bug #18: Remove an unnecessary message to stdout in the exempi tool. diff -Nru exempi-2.5.2/public/include/client-glue/Makefile.in exempi-2.6.1/public/include/client-glue/Makefile.in --- exempi-2.5.2/public/include/client-glue/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/public/include/client-glue/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -317,6 +317,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/public/include/client-glue/TXMPUtils.incl_cpp exempi-2.6.1/public/include/client-glue/TXMPUtils.incl_cpp --- exempi-2.5.2/public/include/client-glue/TXMPUtils.incl_cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/public/include/client-glue/TXMPUtils.incl_cpp 2021-11-18 03:53:54.000000000 +0000 @@ -130,8 +130,8 @@ XMP_StringPtr format, tStringObj * strValue ) { - #if XMP_MacBuild & XMP_64 // This is checked because on Mac 64 bit environment, long is of 64 bit and hence gives a warning during implicit - // typecasting to XMP_Int32. Now doing it explicitly in that case. + #if (XMP_MacBuild || XMP_iOSBuild) & XMP_64 // This is checked because on Mac 64 bit environment, long is of 64 bit and hence gives a warning during implicit + // typecasting to XMP_Int32. Now doing it explicitly in that case. Doing the same for iOS. WrapCheckVoid ( zXMPUtils_ConvertFromInt_1 ( (XMP_Int32)binValue, format, strValue, SetClientString ) ); #else WrapCheckVoid ( zXMPUtils_ConvertFromInt_1 ( binValue, format, strValue, SetClientString ) ); diff -Nru exempi-2.5.2/public/include/client-glue/WXMP_Common.hpp exempi-2.6.1/public/include/client-glue/WXMP_Common.hpp --- exempi-2.5.2/public/include/client-glue/WXMP_Common.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/client-glue/WXMP_Common.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,11 +2,11 @@ #define __WXMP_Common_hpp__ 1 // ================================================================================================= -// Copyright 2002 Adobe Systems Incorporated +// Copyright 2002 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include diff -Nru exempi-2.5.2/public/include/client-glue/WXMPFiles.hpp exempi-2.6.1/public/include/client-glue/WXMPFiles.hpp --- exempi-2.5.2/public/include/client-glue/WXMPFiles.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/client-glue/WXMPFiles.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __WXMPFiles_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2002 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2002 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "client-glue/WXMP_Common.hpp" diff -Nru exempi-2.5.2/public/include/client-glue/WXMPIterator.hpp exempi-2.6.1/public/include/client-glue/WXMPIterator.hpp --- exempi-2.5.2/public/include/client-glue/WXMPIterator.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/client-glue/WXMPIterator.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,11 +2,11 @@ #define __WXMPIterator_hpp__ 1 // ================================================================================================= -// Copyright 2002 Adobe Systems Incorporated +// Copyright 2002 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "client-glue/WXMP_Common.hpp" diff -Nru exempi-2.5.2/public/include/client-glue/WXMPMeta.hpp exempi-2.6.1/public/include/client-glue/WXMPMeta.hpp --- exempi-2.5.2/public/include/client-glue/WXMPMeta.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/client-glue/WXMPMeta.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,11 +2,11 @@ #define __WXMPMeta_hpp__ 1 // ================================================================================================= -// Copyright 2002 Adobe Systems Incorporated +// Copyright 2002 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "client-glue/WXMP_Common.hpp" @@ -17,7 +17,7 @@ // ================================================================================================= -inline XMP_Bool WrapErrorNotify ( XMPMeta_ErrorCallbackProc proc, void * context, +static inline XMP_Bool WrapErrorNotify ( XMPMeta_ErrorCallbackProc proc, void * context, XMP_ErrorSeverity severity, XMP_Int32 cause, XMP_StringPtr message ) { bool ok; diff -Nru exempi-2.5.2/public/include/client-glue/WXMPUtils.hpp exempi-2.6.1/public/include/client-glue/WXMPUtils.hpp --- exempi-2.5.2/public/include/client-glue/WXMPUtils.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/client-glue/WXMPUtils.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,11 +2,11 @@ #define __WXMPUtils_hpp__ 1 // ================================================================================================= -// Copyright 2002 Adobe Systems Incorporated +// Copyright 2002 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "client-glue/WXMP_Common.hpp" diff -Nru exempi-2.5.2/public/include/Makefile.in exempi-2.6.1/public/include/Makefile.in --- exempi-2.5.2/public/include/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/public/include/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -387,6 +387,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/public/include/TXMPFiles.hpp exempi-2.6.1/public/include/TXMPFiles.hpp --- exempi-2.5.2/public/include/TXMPFiles.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/TXMPFiles.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -6,12 +6,12 @@ #endif // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2002 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2002 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= // ================================================================================================= @@ -207,7 +207,6 @@ /// \li \c #kXMPFiles_OpenUsePacketScanning /// \li \c #kXMPFiles_OpenLimitedScanning /// - /// @return The new \c TXMPFiles object. TXMPFiles ( XMP_StringPtr filePath, XMP_FileFormat format = kXMP_UnknownFile, @@ -231,7 +230,6 @@ /// /// @param original The existing \c TXMPFiles object to copy. /// - /// @return The new \c TXMPFiles object. TXMPFiles ( const TXMPFiles & original ); @@ -254,7 +252,7 @@ /// @param xmpFilesObj The underlying reference object, obtained from some other XMP object /// with \c TXMPFiles::GetInternalRef(). /// - /// @return The new object. + TXMPFiles ( XMPFilesRef xmpFilesObj ); @@ -541,7 +539,8 @@ /// /// If the file is opened for update (passing \c #kXMPFiles_OpenForUpdate), the disk file remains /// open until \c CloseFile() is called. The disk file is only updated once, when \c CloseFile() - /// is called, regardless of how many calls are made to \c PutXMP(). + /// is called, regardless of how many calls are made to \c PutXMP(). When in-place update is not possible + /// we might write into a temporary file and then swap for corruption/crash safety. /* Documenatation update for CTECHXMP-4170278*/ /// /// @param closeFlags Option flags for optional closing actions. This bit-flag constant is /// defined: diff -Nru exempi-2.5.2/public/include/TXMPIterator.hpp exempi-2.6.1/public/include/TXMPIterator.hpp --- exempi-2.5.2/public/include/TXMPIterator.hpp 2014-12-17 11:11:42.000000000 +0000 +++ exempi-2.6.1/public/include/TXMPIterator.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -6,12 +6,12 @@ #endif // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2002 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2002 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= // ================================================================================================= @@ -106,7 +106,7 @@ /// Overloaded forms are provided to iterate the entire data tree, /// a subtree rooted at a specific node, or properties within a specific schema. /// - /// @param xmpObj The XMP object over which to iterate. + /// @param xmpObj The XMP object over which to iterate.The new TXMPIterator object is returned via xmpObj. /// /// @param schemaNS Optional schema namespace URI to restrict the iteration. To visit all of the /// schema, pass 0 or the empty string "". @@ -121,7 +121,7 @@ /// \li \c #kXMP_IterJustLeafName - Return just the leaf part of the path; default returns the full path. /// \li \c #kXMP_IterOmitQualifiers - Omit all qualifiers. /// - /// @return The new TXMPIterator object. + /// TXMPIterator ( const TXMPMeta & xmpObj, XMP_StringPtr schemaNS, @@ -135,7 +135,7 @@ /// forms are provided to iterate the entire data tree, a subtree rooted at a specific node, or /// properties within a specific schema. /// - /// @param xmpObj The XMP object over which to iterate. + /// @param xmpObj The XMP object over which to iterate.The new TXMPIterator object returned via xmpObj. /// /// @param schemaNS Optional schema namespace URI to restrict the iteration. To visit all of the /// schema, pass 0 or the empty string "". @@ -146,7 +146,7 @@ /// \li \c #kXMP_IterJustLeafName - Return just the leaf part of the path; default returns the full path. /// \li \c #kXMP_IterOmitQualifiers - Omit all qualifiers. /// - /// @return The new TXMPIterator object. + /// TXMPIterator ( const TXMPMeta & xmpObj, XMP_StringPtr schemaNS, @@ -159,15 +159,14 @@ /// forms are provided to iterate the entire data tree, a subtree rooted at a specific node, or /// properties within a specific schema. /// - /// @param xmpObj The XMP object over which to iterate. + /// @param xmpObj The XMP object over which to iterate. The new \c TXMPIterator object returned via xmpObj. /// /// @param options Option flags to control the iteration. A logical OR of these bit flag constants: /// \li \c #kXMP_IterJustChildren - Visit only the immediate children of the root; default visits subtrees. /// \li \c #kXMP_IterJustLeafNodes - Visit only the leaf nodes; default visits all nodes. /// \li \c #kXMP_IterJustLeafName - Return just the leaf part of the path; default returns the full path. /// \li \c #kXMP_IterOmitQualifiers - Omit all qualifiers. - /// - /// @return The new \c TXMPIterator object. + TXMPIterator ( const TXMPMeta & xmpObj, XMP_OptionBits options = 0 ); diff -Nru exempi-2.5.2/public/include/TXMPMeta.hpp exempi-2.6.1/public/include/TXMPMeta.hpp --- exempi-2.5.2/public/include/TXMPMeta.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/TXMPMeta.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -11,12 +11,12 @@ #endif // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2002 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2002 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= // ================================================================================================= @@ -115,8 +115,6 @@ /// @brief Default constructor, creates an empty object. /// /// The default constructor creates a new empty \c TXMPMeta object. - /// - /// @return The new object. */ TXMPMeta(); // --------------------------------------------------------------------------------------------- @@ -125,9 +123,8 @@ /// The copy constructor creates a new \c TXMPMeta object that refers to the same internal XMP /// object. as an existing \c TXMPMeta object. /// - /// @param original The object to copy. + /// @param original The object to copy. new object is returned via Original only. /// - /// @return The new object. */ TXMPMeta ( const TXMPMeta & original ); @@ -146,9 +143,9 @@ /// of an existing \c TXMPMeta object. Use to safely pass XMP objects across DLL boundaries. /// /// @param xmpRef The underlying reference object, obtained from some other XMP object with - /// \c TXMPMeta::GetInternalRef(). + /// \c TXMPMeta::GetInternalRef().returns The new object. + /// /// - /// @return The new object. TXMPMeta ( XMPMetaRef xmpRef ); @@ -168,7 +165,7 @@ /// /// @param xmpSize The length in bytes of the buffer. /// - /// @return The new object. + TXMPMeta ( XMP_StringPtr buffer, XMP_StringLen xmpSize ); diff -Nru exempi-2.5.2/public/include/TXMPUtils.hpp exempi-2.6.1/public/include/TXMPUtils.hpp --- exempi-2.5.2/public/include/TXMPUtils.hpp 2014-12-17 11:11:42.000000000 +0000 +++ exempi-2.6.1/public/include/TXMPUtils.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -6,12 +6,12 @@ #endif // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2002 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2002 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= // ================================================================================================= diff -Nru exempi-2.5.2/public/include/XMPCommon/XMPCommonDefines.h exempi-2.6.1/public/include/XMPCommon/XMPCommonDefines.h --- exempi-2.5.2/public/include/XMPCommon/XMPCommonDefines.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/XMPCommon/XMPCommonDefines.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,12 +1,11 @@ #ifndef __XMPCommonDefines_h__ #define __XMPCommonDefines_h__ 1 - // ================================================================================================= -// Copyright 2014 Adobe Systems Incorporated +// Copyright 2014 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= // ================================================================================================= @@ -28,7 +27,7 @@ // Macintosh Specific Settings // =========================== #if XMP_MacBuild - #define SUPPORT_STD_ATOMIC_IMPLEMENTATION 0 + #define SUPPORT_STD_ATOMIC_IMPLEMENTATION 1 #ifdef _LIBCPP_VERSION #define SUPPORT_SHARED_POINTERS_IN_TR1 0 #define SUPPORT_SHARED_POINTERS_IN_STD 1 @@ -40,13 +39,35 @@ #define BAD_EXCEPTION_SUPPORT_STRINGS 0 #define VECTOR_SUPPORT_CONST_ITERATOR_FUNCTIONS 0 #define SUPPORT_VARIADIC_TEMPLATES 0 - #endif + #define libcppNULL 0 + + + #endif + + #if XMP_AndroidBuild + #define SUPPORT_STD_ATOMIC_IMPLEMENTATION 0 + #ifdef _LIBCPP_VERSION + #define SUPPORT_SHARED_POINTERS_IN_TR1 0 + #define SUPPORT_SHARED_POINTERS_IN_STD 1 + #define libcppNULL nullptr + #else + #define SUPPORT_SHARED_POINTERS_IN_TR1 1 + #define SUPPORT_SHARED_POINTERS_IN_STD 0 + #define libcppNULL NULL + #endif + #define SUPPORT_SHARED_POINTERS_WITH_ALLOCATORS 0 + #define BAD_EXCEPTION_SUPPORT_STRINGS 0 + #define VECTOR_SUPPORT_CONST_ITERATOR_FUNCTIONS 0 + #define SUPPORT_VARIADIC_TEMPLATES 0 + + + #endif // ================================================================================================= // IOS Specific Settings // =========================== #if XMP_iOSBuild - #define SUPPORT_STD_ATOMIC_IMPLEMENTATION 0 + #define SUPPORT_STD_ATOMIC_IMPLEMENTATION 1 #ifdef _LIBCPP_VERSION #define SUPPORT_SHARED_POINTERS_IN_TR1 0 #define SUPPORT_SHARED_POINTERS_IN_STD 1 @@ -58,6 +79,7 @@ #define BAD_EXCEPTION_SUPPORT_STRINGS 0 #define VECTOR_SUPPORT_CONST_ITERATOR_FUNCTIONS 0 #define SUPPORT_VARIADIC_TEMPLATES 0 + #define libcppNULL 0 #endif // ================================================================================================= @@ -76,19 +98,25 @@ #endif #define BAD_EXCEPTION_SUPPORT_STRINGS 1 #define VECTOR_SUPPORT_CONST_ITERATOR_FUNCTIONS 1 + #define libcppNULL 0 #endif // ================================================================================================= // UNIX Specific Settings // ====================== #if XMP_UNIXBuild - #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) - #if GCC_VERSION >= 40800 + # if __clang__ #define SUPPORT_STD_ATOMIC_IMPLEMENTATION 1 - #else - #define REQ_FRIEND_CLASS_DECLARATION() template friend class std::_Sp_counted_ptr; - #define SUPPORT_STD_ATOMIC_IMPLEMENTATION 0 - #endif + #else + #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) + #if GCC_VERSION >= 40800 + #define SUPPORT_STD_ATOMIC_IMPLEMENTATION 1 + #else + #define REQ_FRIEND_CLASS_DECLARATION() template friend class std::_Sp_counted_ptr; + #define SUPPORT_STD_ATOMIC_IMPLEMENTATION 0 + #endif + #endif + #define SUPPORT_SHARED_POINTERS_IN_TR1 0 #define SUPPORT_SHARED_POINTERS_IN_STD 1 @@ -97,8 +125,8 @@ #define VECTOR_SUPPORT_CONST_ITERATOR_FUNCTIONS 1 #define SUPPORT_DYNAMIC_CAST_OPTIMIZATION 0 #define SUPPORT_VARIADIC_TEMPLATES 0 + #define libcppNULL 0 #endif - #ifndef SUPPORT_VARIADIC_TEMPLATES #define SUPPORT_VARIADIC_TEMPLATES 1 #endif diff -Nru exempi-2.5.2/public/include/XMPCommon/XMPCommonErrorCodes.h exempi-2.6.1/public/include/XMPCommon/XMPCommonErrorCodes.h --- exempi-2.5.2/public/include/XMPCommon/XMPCommonErrorCodes.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/XMPCommon/XMPCommonErrorCodes.h 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define XMPCommonErrorCodes_h__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2014 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2014 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "XMPCommon/XMPCommonDefines.h" diff -Nru exempi-2.5.2/public/include/XMPCommon/XMPCommonFwdDeclarations.h exempi-2.6.1/public/include/XMPCommon/XMPCommonFwdDeclarations.h --- exempi-2.5.2/public/include/XMPCommon/XMPCommonFwdDeclarations.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/XMPCommon/XMPCommonFwdDeclarations.h 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __XMPCommonFwdDeclarations_h__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2014 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2014 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "XMPCommon/XMPCommonDefines.h" @@ -125,11 +125,11 @@ //! //! @brief A function pointer to get the memory allocated from the library. - //! \param[in] size a value indicating the number of bytes to be allocated. + //! \param[in] size a value indicating the number of bytes to be allocated. //! \return a pointer to memory allocated by the library. //! \note NULL value is returned in case memory allocation fails. //! - typedef void * ( *MemAllocateProc )( sizet sz ); + typedef void * ( *MemAllocateProc )( sizet size ); void * MemAllocate( sizet size ) __NOTHROW__; //! diff -Nru exempi-2.5.2/public/include/XMPCommon/XMPCommonLatestInterfaceVersions.h exempi-2.6.1/public/include/XMPCommon/XMPCommonLatestInterfaceVersions.h --- exempi-2.5.2/public/include/XMPCommon/XMPCommonLatestInterfaceVersions.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/XMPCommon/XMPCommonLatestInterfaceVersions.h 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define XMPCommonLatestInterfaceVersions_h__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2015 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2015 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= //! diff -Nru exempi-2.5.2/public/include/XMP_Const.h exempi-2.6.1/public/include/XMP_Const.h --- exempi-2.5.2/public/include/XMP_Const.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/XMP_Const.h 2021-11-18 03:53:54.000000000 +0000 @@ -2,11 +2,11 @@ #define __XMP_Const_h__ 1 // ================================================================================================= -// Copyright 2002 Adobe Systems Incorporated +// Copyright 2002 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "XMP_Environment.h" @@ -19,7 +19,8 @@ #if XMP_MacBuild | XMP_iOSBuild // ! No stdint.h on Windows and some UNIXes. #include #endif -#if XMP_UNIXBuild // hopefully an inttypes.h on all UNIXes... +//Android has both inttypes and stdint. But inttypes includes stdint plus other functions +#if XMP_UNIXBuild | XMP_AndroidBuild // hopefully an inttypes.h on all UNIXes... #include #endif @@ -27,6 +28,12 @@ #define XMP_MARKER_EXTENSIBILITY_BACKWARD_COMPATIBILITY 1 #endif +#if XMP_iOSBuild + #define __AVAILABILITY_INTERNAL_DEPRECATED_XMP __AVAILABILITY_INTERNAL_DEPRECATED +#else + #define __AVAILABILITY_INTERNAL_DEPRECATED_XMP +#endif + #if __cplusplus extern "C" { #endif @@ -68,7 +75,7 @@ typedef unsigned long XMP_Uns32; typedef unsigned long long XMP_Uns64; -#elif XMP_UNIXBuild +#elif XMP_UNIXBuild | XMP_AndroidBuild #if ! XMP_64 @@ -98,7 +105,7 @@ #else - #error "XMP environment error - must define one of XMP_MacBuild, XMP_WinBuild, XMP_UNIXBuild or XMP_iOSBuild" + #error "XMP environment error - must define one of XMP_MacBuild, XMP_WinBuild, XMP_UNIXBuild, XMP_AndroidBuild or XMP_iOSBuild" #endif @@ -934,6 +941,10 @@ kXMP_AIFFFile = 0x41494646UL, /// Public file format constant: 'RED ', RED file format kXMP_REDFile = 0x52454420UL, + /// Public file format constant: 'ARRI', ARRI file format + kXMP_ARRIFile = 0x41525249UL, + /// Public file format constant: 'HEIF', HEIF file format + kXMP_HEIFFile = 0x48454946UL, /// Public file format constant: 'P2 ', a collection not really a single file kXMP_P2File = 0x50322020UL, /// Public file format constant: 'XDCF', a collection not really a single file @@ -1156,6 +1167,9 @@ /// The plugin handler is not capable for delay loading kXMPFiles_NeedsPreloading = 0x00004000, + /// The format needs file during Process XMP even if it's Read Only Operation. + /// So that file is not closed after OpenFile operation when kXMPFiles_OpenForUpdate not passed + kXMPFiles_NeedsLocalFileOpened = 0x00010000 }; /// @brief Option bit flags for \c TXMPFiles::OpenFile(). @@ -1239,7 +1253,7 @@ /// Recovery is not possible, an exception will be thrown, the file is corrupt and possibly unusable. kXMPErrSev_FileFatal = 2, /// Recovery is not possible, an exception will be thrown, the entire process should be aborted. - kXMPErrSev_ProcessFatal = 3 + kXMPErrSev_ProcessFatal = 3 }; // ------------------------------------------------------------------------------------------------- @@ -1448,8 +1462,8 @@ kXMPErr_BadBlockFormat = 116, /// File Path is not a file kXMPErr_FilePathNotAFile = 117, - /// Rejected File extension - kXMPErr_RejectedFileExtension = 118, + /// Rejected File extension + kXMPErr_RejectedFileExtension = 118, // ----------------------------------------------- // File format and internal structure error codes. @@ -1475,7 +1489,11 @@ /// IPTC format error kXMPErr_BadIPTC = 210, /// MPEG format error - kXMPErr_BadMPEG = 211 + kXMPErr_BadMPEG = 211, + /// HEIF format: Modify Operation is not supported for Construction Method 1 or 2 + kXMPErr_HEIFConstructionMethodNotSupported = 212, + /// PNG format error + kXMPErr_BadPNG = 213 }; diff -Nru exempi-2.5.2/public/include/XMPCore/XMPCoreDefines.h exempi-2.6.1/public/include/XMPCore/XMPCoreDefines.h --- exempi-2.5.2/public/include/XMPCore/XMPCoreDefines.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/XMPCore/XMPCoreDefines.h 2021-11-18 03:53:54.000000000 +0000 @@ -2,11 +2,11 @@ #define XMPCoreDefines_h__ 1 // ================================================================================================= -// Copyright 2014 Adobe Systems Incorporated +// Copyright 2014 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= // ================================================================================================= @@ -50,6 +50,14 @@ #if XMP_UNIXBuild #define ENABLE_CPP_DOM_MODEL 0 #endif + +// ================================================================================================= +// Android Specific Settings +// ====================== +#if XMP_AndroidBuild +#define ENABLE_CPP_DOM_MODEL 0 +#endif + #endif // ENABLE_CPP_DOM_MODEL #ifndef ENABLE_CPP_DOM_MODEL diff -Nru exempi-2.5.2/public/include/XMPCore/XMPCoreErrorCodes.h exempi-2.6.1/public/include/XMPCore/XMPCoreErrorCodes.h --- exempi-2.5.2/public/include/XMPCore/XMPCoreErrorCodes.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/XMPCore/XMPCoreErrorCodes.h 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define XMPCoreErrorCodes_h__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2015 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2015 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "XMPCore/XMPCoreDefines.h" diff -Nru exempi-2.5.2/public/include/XMPCore/XMPCoreFwdDeclarations.h exempi-2.6.1/public/include/XMPCore/XMPCoreFwdDeclarations.h --- exempi-2.5.2/public/include/XMPCore/XMPCoreFwdDeclarations.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/XMPCore/XMPCoreFwdDeclarations.h 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define XMPCoreFwdDeclarations_h__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2014 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2014 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= @@ -214,6 +214,18 @@ typedef shared_ptr< const ICoreConfigurationManager > spcICoreConfigurationManager; static const uint64 kICoreConfigurationManagerID ( 0x63436f6e664d6772 /* cConfMgr */ ); + // IMetadataConverterUtils + class IMetadataConverterUtils_v1; + typedef IMetadataConverterUtils_v1 IMetadataConverterUtils_base; + typedef IMetadataConverterUtils_v1 * pIMetadataConverterUtils_base; + typedef const IMetadataConverterUtils_v1 * pcIMetadataConverterUtils_base; + typedef BASE_CLASS( IMetadataConverterUtils, IMETADATACONVERTERUTILS_VERSION ) IMetadataConverterUtils; + typedef IMetadataConverterUtils * pIMetadataConverterUtils; + typedef const IMetadataConverterUtils * pcIMetadataConverterUtils; + typedef shared_ptr< IMetadataConverterUtils > spIMetadataConverterUtils; + typedef shared_ptr< const IMetadataConverterUtils > spcIMetadataConverterUtils; + static const uint64 kIMetadataConverterUtilsID ( 0x63436F6E5574696C /* cConUtil */ ); + } namespace AdobeXMPCore_Int { @@ -302,6 +314,11 @@ class ICoreConfigurationManager_I; typedef ICoreConfigurationManager_I * pICoreConfigurationManager_I; typedef const ICoreConfigurationManager_I * pcICoreConfigurationManager_I; + + // IMetadataConverterUtils_I + class IMetadataConverterUtils_I; + typedef IMetadataConverterUtils_I * pIMetadataConverterUtils_I; + typedef const IMetadataConverterUtils_I * pcIMetadataConverterUtils_I; } #endif // XMPCoreFwdDeclarations_h__ diff -Nru exempi-2.5.2/public/include/XMPCore/XMPCoreLatestInterfaceVersions.h exempi-2.6.1/public/include/XMPCore/XMPCoreLatestInterfaceVersions.h --- exempi-2.5.2/public/include/XMPCore/XMPCoreLatestInterfaceVersions.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/XMPCore/XMPCoreLatestInterfaceVersions.h 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define XMPCoreLatestInterfaceVersions_h__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2015 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2015 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= //! @@ -88,5 +88,10 @@ #define ICORECONFIGURATIONMANAGER_VERSION 1 #endif +#ifndef IMETADATACONVERTERUTILS_VERSION + #define IMETADATACONVERTERUTILS_VERSION 1 +#endif + + #endif // XMPCoreLatestInterfaceVersions_h__ diff -Nru exempi-2.5.2/public/include/XMP_Environment.h exempi-2.6.1/public/include/XMP_Environment.h --- exempi-2.5.2/public/include/XMP_Environment.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/XMP_Environment.h 2021-11-18 03:53:54.000000000 +0000 @@ -11,11 +11,11 @@ // ================================================================================================= // ================================================================================================= -// Copyright 2002 Adobe Systems Incorporated +// Copyright 2002 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= // ================================================================================================= @@ -29,20 +29,22 @@ // ! Tempting though it might be to have a standard macro for big or little endian, there seems to // ! be no decent way to do that on our own in UNIX. Forcing it on the client isn't acceptable. -#if defined ( MAC_ENV ) +#if defined ( MAC_ENV ) && !defined (IOS_ENV) #if 0 // ! maybe someday - ! MAC_ENV #error "MAC_ENV must be defined so that \"#if MAC_ENV\" is true" #endif - #if defined ( WIN_ENV ) || defined ( UNIX_ENV ) || defined ( IOS_ENV ) - #error "XMP environment error - must define only one of MAC_ENV, WIN_ENV, UNIX_ENV or IOS_ENV" + #if defined ( WIN_ENV ) || defined ( UNIX_ENV ) || defined ( ANDROID_ENV ) + #error "XMP environment error - must define only one of MAC_ENV, WIN_ENV, UNIX_ENV or ANDROID_ENV" #endif #define XMP_MacBuild 1 #define XMP_WinBuild 0 #define XMP_UNIXBuild 0 #define XMP_iOSBuild 0 + #define XMP_UWP 0 + #define XMP_AndroidBuild 0 #elif defined ( WIN_ENV ) @@ -50,23 +52,29 @@ #error "WIN_ENV must be defined so that \"#if WIN_ENV\" is true" #endif - #if defined ( MAC_ENV ) || defined ( UNIX_ENV ) || defined ( IOS_ENV ) - #error "XMP environment error - must define only one of MAC_ENV, WIN_ENV, UNIX_ENV or IOS_ENV" + #if defined ( MAC_ENV ) || defined ( UNIX_ENV ) || defined ( IOS_ENV ) || defined ( ANDROID_ENV ) + #error "XMP environment error - must define only one of MAC_ENV (or IOS_ENV), WIN_ENV, UNIX_ENV, ANDROID_ENV" #endif #define XMP_MacBuild 0 #define XMP_WinBuild 1 #define XMP_UNIXBuild 0 #define XMP_iOSBuild 0 + #if defined ( WIN_UNIVERSAL_ENV) + #define XMP_UWP 1 + #else + #define XMP_UWP 0 + #endif + #define XMP_AndroidBuild 0 -#elif defined ( UNIX_ENV ) +#elif defined ( UNIX_ENV ) && !defined (ANDROID_ENV) #if 0 // ! maybe someday - ! UNIX_ENV #error "UNIX_ENV must be defined so that \"#if UNIX_ENV\" is true" #endif - #if defined ( MAC_ENV ) || defined ( WIN_ENV ) || defined ( IOS_ENV ) - #error "XMP environment error - must define only one of MAC_ENV, WIN_ENV, UNIX_ENV or IOS_ENV" + #if defined ( MAC_ENV ) || defined ( WIN_ENV ) || defined ( IOS_ENV ) || defined ( ANDROID_ENV ) + #error "XMP environment error - must define only one of MAC_ENV (or IOS_ENV), WIN_ENV, UNIX_ENV, ANDROID_ENV" #endif #define XMP_MacBuild 0 @@ -74,14 +82,17 @@ #define XMP_UNIXBuild 1 #define XMP_iOSBuild 0 + #define XMP_UWP 0 + #define XMP_AndroidBuild 0 + #elif defined ( IOS_ENV ) #if 0 // ! maybe someday - ! IOS_ENV #error "IOS_ENV must be defined so that \"#if IOS_ENV\" is true" #endif - #if defined ( MAC_ENV ) || defined ( WIN_ENV ) || defined ( UNIX_ENV ) - #error "XMP environment error - must define only one of MAC_ENV, WIN_ENV, UNIX_ENV or IOS_ENV" + #if defined ( WIN_ENV ) || defined ( UNIX_ENV ) || defined ( ANDROID_ENV ) + #error "XMP environment error - must define only one of IOS_ENV, WIN_ENV, UNIX_ENV, ANDROID_ENV" #endif #define XMP_MacBuild 0 @@ -89,9 +100,29 @@ #define XMP_UNIXBuild 0 #define XMP_iOSBuild 1 + #define XMP_UWP 0 + + #define XMP_AndroidBuild 0 + +#elif defined ( ANDROID_ENV ) + + #if 0 // ! maybe someday - ! UNIX_ENV + #error "ANDROID_ENV must be defined so that \"#if ANDROID_ENV\" is true" + #endif + + #if defined ( MAC_ENV ) || defined ( WIN_ENV ) || defined ( IOS_ENV ) + #error "XMP environment error - must define only one of MAC_ENV (or IOS_ENV), WIN_ENV, UNIX_ENV, ANDROID_ENV" + #endif + + #define XMP_MacBuild 0 + #define XMP_WinBuild 0 + #define XMP_UNIXBuild 0 + #define XMP_iOSBuild 0 + #define XMP_AndroidBuild 1 + #else - #error "XMP environment error - must define one of MAC_ENV, WIN_ENV, UNIX_ENV or IOS_ENV" + #error "XMP environment error - must define one of MAC_ENV, WIN_ENV, UNIX_ENV , ANDROID_ENV or IOS_ENV" #endif @@ -153,7 +184,7 @@ // ================================================================================================= // UNIX Specific Settings // ====================== -#if (XMP_UNIXBuild) +#if (XMP_UNIXBuild) | (XMP_AndroidBuild) #define XMP_HELPER_DLL_IMPORT #define XMP_HELPER_DLL_EXPORT __attribute__ ((visibility ("default"))) #define XMP_HELPER_DLL_PRIVATE __attribute__ ((visibility ("hidden"))) diff -Nru exempi-2.5.2/public/include/XMP.hpp exempi-2.6.1/public/include/XMP.hpp --- exempi-2.5.2/public/include/XMP.hpp 2014-12-17 11:11:42.000000000 +0000 +++ exempi-2.6.1/public/include/XMP.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,11 +2,11 @@ #define __XMP_hpp__ 1 // ================================================================================================= -// Copyright 2002 Adobe Systems Incorporated +// Copyright 2002 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= // ================================================================================================ diff -Nru exempi-2.5.2/public/include/XMP_IO.hpp exempi-2.6.1/public/include/XMP_IO.hpp --- exempi-2.5.2/public/include/XMP_IO.hpp 2016-12-07 05:07:54.000000000 +0000 +++ exempi-2.6.1/public/include/XMP_IO.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __XMP_IO_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -41,7 +41,7 @@ class XMP_IO { public: - + enum { kReadAll = true }; // --------------------------------------------------------------------------------------------- /// @brief Read into a buffer, returning the number of bytes read. /// @@ -56,8 +56,6 @@ /// /// @return Returns the number of bytes read. - enum { kReadAll = true }; - virtual XMP_Uns32 Read ( void* buffer, XMP_Uns32 count, bool readAll = false ) = 0; inline XMP_Uns32 ReadAll ( void* buffer, XMP_Uns32 bytes ) @@ -164,7 +162,7 @@ /// share state across multiple XMP_IO objects. XMP_IO ( const XMP_IO & original ); - XMP_IO& operator= ( const XMP_IO& in ); + void operator= ( const XMP_IO& ) { /**this = in; *//* Avoid Win compile warnings. */ }; }; diff -Nru exempi-2.5.2/public/include/XMP_Version.h exempi-2.6.1/public/include/XMP_Version.h --- exempi-2.5.2/public/include/XMP_Version.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/public/include/XMP_Version.h 2021-11-18 03:53:54.000000000 +0000 @@ -7,11 +7,11 @@ /* // ================================================================================================= -// Copyright 2002 Adobe Systems Incorporated +// Copyright 2002 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= */ @@ -33,19 +33,19 @@ */ /* ============================================================================================= */ -#define XMPCORE_API_VERSION_MAJOR 5 -#define XMPCORE_API_VERSION_MINOR 6 +#define XMPCORE_API_VERSION_MAJOR 6 +#define XMPCORE_API_VERSION_MINOR 0 #define XMPCORE_API_VERSION_MICRO 0 -#define XMPCORE_API_VERSION 5.6.0 -#define XMPCORE_API_VERSION_STRING "5.6.0" +#define XMPCORE_API_VERSION 6.0.0 +#define XMPCORE_API_VERSION_STRING "6.0.0" -#define XMPFILES_API_VERSION_MAJOR 5 -#define XMPFILES_API_VERSION_MINOR 7 +#define XMPFILES_API_VERSION_MAJOR 6 +#define XMPFILES_API_VERSION_MINOR 0 #define XMPFILES_API_VERSION_MICRO 0 -#define XMPFILES_API_VERSION 5.7.0 -#define XMPFILES_API_VERSION_STRING "5.7.0" +#define XMPFILES_API_VERSION 6.0.0 +#define XMPFILES_API_VERSION_STRING "6.0.0" /* ============================================================================================= */ diff -Nru exempi-2.5.2/public/Makefile.in exempi-2.6.1/public/Makefile.in --- exempi-2.5.2/public/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/public/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -356,6 +356,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/README exempi-2.6.1/README --- exempi-2.5.2/README 2018-02-02 15:06:06.000000000 +0000 +++ exempi-2.6.1/README 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -exempi is a port of Adobe XMP SDK to work on UNIX and to be build with -GNU automake. - -It includes XMPCore and XMPFiles, libexempi, a C-based API and exempi -a command line tool. - -It require at least the gcc 4.6.0 C++ compiler or clang++ with some -support for C++11. - -It is maintained by Hubert Figuiere - -Contributors: - Frankie Dintino - - -Homepage: http://libopenraw.freedesktop.org/wiki/Exempi diff -Nru exempi-2.5.2/README-Adobe.md exempi-2.6.1/README-Adobe.md --- exempi-2.5.2/README-Adobe.md 1970-01-01 00:00:00.000000000 +0000 +++ exempi-2.6.1/README-Adobe.md 2021-11-18 03:53:53.000000000 +0000 @@ -0,0 +1,71 @@ +# XMP-Toolkit-SDK + +The XMP Toolkit allows you to integrate XMP functionality into your product or solution. It supports Macintosh, Windows, as well as UNIX and comes with samples, documentation, source code and scripts to generate project files. The XMP Toolkit is available under the BSD license. The specification is provided under the [XMP Specification Public Patent License](https://wwwimages2.adobe.com/content/dam/acom/en/devnet/xmp/pdfs/cs6/xmp_public_patent_license.pdf) + + +## SDK components + +The XMP Toolkit SDK contains two libraries, XMPCore and XMPFiles. XMPCore and XMPFiles are provided as C++ implementations. + +### XMPCore +This library supplies an API for parsing, manipulating, and serializing metadata, according to the XMP data model and regardless of the file format of the data it describes. + +### XMPFiles +This library supplies an API for locating, adding, or updating the XMP metadata in a file. The API allows you to retrieve the entire XMP Packet, which you can then pass to the XMPCore component in order to manipulate the individual XMP properties. + +*It also includes a plug-in SDK that allows you to create an XMPFiles Plug-in that handles metadata for additional file formats, or replaces built-in format handlers with custom ones.* + +## XMP Toolkit SDK Contents +This git repo contains the following folders under the root folder: + +Directory | Details +------------ | ------------- +/ | At the root level, the license agreement (BSD_License.txt) and this overview (XMP-Toolkit-SDK-Overview.pdf). +build/ | Contains Batch file, shell scripts, Makefile and CMake scripts to be used to create XMP Toolkit SDK project files on the supported platforms. Follow the instructions in README.txt to create the projects. +docs/ | The three-part XMP Specification, the XMP Toolkit SDK Programmer’s Guide, the API reference documentation (API/index.html) and the XMPFiles plug-in SDK documentation. +public/include/ | The header files and glue code that clients of the XMP Toolkit SDK must include. +samples/ | Sample source code and CMake scripts for building sample projects, with the necessary resources to run the sample code. See ‘‘Sample code and tools’’ below. +source/ | The common source code that is used by both components of the XMP Toolkit SDK. +XMPCore/ | The source code for XMPCore library. +XMPFiles/ | The source code for XMPFiles library. +third-party/
   expat/
   zlib/
   zuid/ | Placeholders for third party source files which are needed for the XMP Toolkit SDK, including ReadMe.txt files with information on how to obtain and install the tools. MD5 source code, needed by both components for MD5 hash computation, is included. +tools/ | Placeholder for downloading and placing CMake tool +XMPFilesPlugins/| The header files and glue code of the XMPFiles plug-in SDK and a sample plug-in. + +## How to Build and Use + +XMP Toolkit SDK provides build script to ease the process. This repository contains everything needed to build SDK libraries on Mac OS®, Windows®, UNIX®/Linux®, iOS and Android. For detailed build steps , refer the [Programmer's Guide](https://github.com/adobe/XMP-Toolkit-SDK/blob/master/docs/XMPProgrammersGuide.pdf) + +## Documentation +See extensive [API documentation](https://github.com/adobe/XMP-Toolkit-SDK/blob/master/docs/XMPProgrammersGuide.pdf) where a complete API Reference is available. + +The XMP Specification, available from [Adobe Developer Center (XMP)](http://adobe.com/devnet/xmp/), provides a complete formal +specification for XMP. Before working with the XMP Toolkit SDK, you must be familiar with, at a minimum, +the XMP Data Model. + +The specification has three parts: +- Part 1, Data Model, Serialization, and Core Properties covers the basic metadata representation model +that is the foundation of the XMP standard format. The Data Model prescribes how XMP metadata can +be organized; it is independent of file format or specific usage. The Serialization Model prescribes how +the Data Model is represented in XML, specifically RDF. +This document provides all the details a programmer would need to implement a metadata +manipulation system such as the XMP Toolkit SDK (which is available from Adobe). + +- Part 2, Additional Properties, provides detailed property lists and descriptions for standard XMP +metadata schemas; these include general-purpose schemas such as Dublin Core, and special-purpose +schemas for Adobe applications such as Photoshop®. It also provides information on extending +existing schemas and creating new schemas. + +- Part 3, Storage in Files, provides information about how serialized XMP metadata is packaged into XMP +Packets and embedded in different file formats. It includes information about how XMP relates to and +incorporates other metadata formats, and how to reconcile values that are represented in multiple +metadata formats. + +## Contributing +Contributions are welcomed! Read the [Contributing Guide](https://github.com/adobe/XMP-Toolkit-SDK/blob/master/CONTRIBUTING.md) for more information. + +## Licensing +This project is BSD licensed. See [LICENSE](https://github.com/adobe/XMP-Toolkit-SDK/blob/main/LICENSE) for more information. + +## Report Issues/Bugs +You can report the issues in the issues section of the github repo. diff -Nru exempi-2.5.2/README.md exempi-2.6.1/README.md --- exempi-2.5.2/README.md 1970-01-01 00:00:00.000000000 +0000 +++ exempi-2.6.1/README.md 2021-11-18 03:53:53.000000000 +0000 @@ -0,0 +1,20 @@ +exempi is a port of Adobe XMP SDK to work on UNIX and to be build with +GNU automake. + +[Adobe readme](README-Adobe.md) + +It is licensed under a BSD-style license. See [LICENSE](LICENSE). + +It includes XMPCore and XMPFiles, libexempi, a C-based API and exempi +a command line tool. + +It require at least the gcc 4.6.0 C++ compiler or clang++ with some +support for C++11. + +It is maintained by Hubert Figuiere + +Contributors: + Frankie Dintino + + +Homepage: http://libopenraw.freedesktop.org/wiki/Exempi diff -Nru exempi-2.5.2/samples/Makefile.in exempi-2.6.1/samples/Makefile.in --- exempi-2.5.2/samples/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/samples/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -355,6 +355,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/samples/source/common/DumpFile.cpp exempi-2.6.1/samples/source/common/DumpFile.cpp --- exempi-2.5.2/samples/source/common/DumpFile.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/samples/source/common/DumpFile.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -36,65 +36,65 @@ #include "samples/source/common/globals.h" #include "samples/source/common/DumpFile.h" #include "samples/source/common/LargeFileAccess.hpp" -static const XMP_Uns32 CONST_INFINITE=(XMP_Uns32)(-1); +static const XMP_Uns32 CONST_INFINITE = (XMP_Uns32)(-1); // converts a (supposed) 8Bit-encoded String to Buginese // - suitable for UTF-8 or any other encoding // - stopOnNull does just that, exceeding length is declared as |R:1234 at the end of string // - len is the max parsing size, defaults to unlimited // - having set neither stopOnNull nor max parsing size is a bad idea (checked and yields error) -std::string convert8Bit( void* str, bool stopOnNull, XMP_Uns32 byteLen ) +std::string convert8Bit(void* str, bool stopOnNull, XMP_Uns32 byteLen) { std::string r; //result r.clear(); // ...I have become cautious... :-) - if ( byteLen == 0 ) + if (byteLen == 0) return r; //nothing to do - //provoke access violation: - //if invalid length leads to access violation, I want it here and now... - if ( byteLen!=CONST_INFINITE ) { //if not "CONST_INFINITE" - char tmp=((char*)str)[byteLen-1]; - tmp=tmp; + //provoke access violation: + //if invalid length leads to access violation, I want it here and now... + if (byteLen != CONST_INFINITE) { //if not "CONST_INFINITE" + char tmp = ((char*)str)[byteLen - 1]; } - if( !stopOnNull && (byteLen==CONST_INFINITE ) ) + if (!stopOnNull && (byteLen == CONST_INFINITE)) Log::error("must set either stopOnNULL or specify length of string"); bool outside = false; // toggle-flag: outside ASCII ? XMP_Uns32 remainder = 0; char buffer[200]; //changed from 20 to 200 (whatever reason there was to have it so small) - for ( XMP_Uns32 i = 0; - i0) { - sprintf(buffer, "|R:%d", remainder ); - r+=buffer; + sprintf(buffer, "|R:%d", remainder); + r += buffer; } return r; } @@ -102,17 +102,16 @@ //same story, but for (UTF-)16BE characters //note: length still to be specified in byte, thus must be even (verified) -std::string convert16Bit( bool bigEndian, XMP_Uns8* str, bool stopOnNull, XMP_Uns32 byteLen ) +std::string convert16Bit(bool bigEndian, XMP_Uns8* str, bool stopOnNull, XMP_Uns32 byteLen) { //if invalid length leads to access violation, I want it here and now... - if ( byteLen!=CONST_INFINITE ) { - char tmp=str[byteLen-1]; - tmp=tmp; + if (byteLen != CONST_INFINITE) { + char tmp = str[byteLen - 1]; } - if( !stopOnNull && (byteLen==CONST_INFINITE ) ) + if (!stopOnNull && (byteLen == CONST_INFINITE)) Log::error("must set either stopOnNULL or specify length of string"); - if ( (byteLen!=CONST_INFINITE) && (byteLen % 2 != 0) ) //if neither CONST_INFINITE or even...# + if ((byteLen != CONST_INFINITE) && (byteLen % 2 != 0)) //if neither CONST_INFINITE or even...# Log::error("convert16BitToBuginese: byteLen must be even"); @@ -123,39 +122,40 @@ std::string r; //result r.clear(); // ...I have become cautious... :-) - for ( XMP_Uns32 i = 0; - i0) { - sprintf(buffer, "|R:%d", remainder ); - r+=buffer; + sprintf(buffer, "|R:%d", remainder); + r += buffer; } return r; } @@ -171,7 +171,7 @@ char buffer[4096]; //should be big enough but no guarantees.. va_list args; va_start(args, format); - vsprintf(buffer, format, args); + vsprintf(buffer, format, args); va_end(args); return std::string(buffer); @@ -181,16 +181,16 @@ #include //fpr va_list et al DumpFileException::DumpFileException(const char *format, ...) : std::runtime_error("dumpfile exception") -{ +{ va_list args; va_start(args, format); - vsnprintf( buffer, XMPQE_MAX_ERROR_LENGTH, format, args); + vsnprintf(buffer, XMPQE_MAX_ERROR_LENGTH, format, args); va_end(args); } // overriding, since the buffer needs to be constructed first... const char* DumpFileException::what_dumpfile_reason() { - return buffer; + return buffer; } // REMOVED ON PURPOSE: #include @@ -240,9 +240,9 @@ #include "samples/source/common/Log.h" //disabled warning (take-over) #if XMP_WinBuild - #pragma warning (disable : 4996) // '...' was declared deprecated - #pragma warning (disable : 4244) // conversion from '__w64 int' to 'XMP_Uns32', possible loss of data - #pragma warning (disable : 4267) // conversion from 'size_t' to 'int', possible loss of data +#pragma warning (disable : 4996) // '...' was declared deprecated +#pragma warning (disable : 4244) // conversion from '__w64 int' to 'XMP_Uns32', possible loss of data +#pragma warning (disable : 4267) // conversion from 'size_t' to 'int', possible loss of data #endif #pragma pack (1) @@ -278,16 +278,16 @@ static XMP_Uns32 sXMPLen = 0; static XMP_Int64 sXMPPos = 0; -typedef XMP_Uns16 (*GetUns16_Proc) ( const void * addr ); -typedef XMP_Uns32 (*GetUns32_Proc) ( const void * addr ); -typedef XMP_Uns64 (*GetUns64_Proc) ( const void * addr ); - -static XMP_Uns16 GetUns16BE ( const void * addr ); -static XMP_Uns16 GetUns16LE ( const void * addr ); -static XMP_Uns32 GetUns32BE ( const void * addr ); -static XMP_Uns32 GetUns32LE ( const void * addr ); -static XMP_Uns64 GetUns64BE ( const void * addr ); -static XMP_Uns64 GetUns64LE ( const void * addr ); +typedef XMP_Uns16(*GetUns16_Proc) (const void * addr); +typedef XMP_Uns32(*GetUns32_Proc) (const void * addr); +typedef XMP_Uns64(*GetUns64_Proc) (const void * addr); + +static XMP_Uns16 GetUns16BE(const void * addr); +static XMP_Uns16 GetUns16LE(const void * addr); +static XMP_Uns32 GetUns32BE(const void * addr); +static XMP_Uns32 GetUns32LE(const void * addr); +static XMP_Uns64 GetUns64BE(const void * addr); +static XMP_Uns64 GetUns64LE(const void * addr); #define High32(u64) ((XMP_Uns32)((u64) >> 32)) #define Low32(u64) ((XMP_Uns32)((u64) & 0xFFFFFFFFUL)) @@ -301,12 +301,12 @@ }; typedef std::vector JpegMarkers; -static void DumpTIFF ( XMP_Uns8 * tiffContent, XMP_Uns32 tiffLen, XMP_Uns32 fileOffset, const char * label, std::string path, bool isHeaderAbsent = false ); -static void DumpTIFF ( const JpegMarkers& psirMarkers, XMP_Uns8 * dataStart, const char * label, std::string path ); -static void DumpIPTC ( XMP_Uns8 * iptcOrigin, XMP_Uns32 iptcLen, XMP_Uns32 fileOffset, const char * label ); -static void DumpImageResources ( XMP_Uns8 * psirOrigin, XMP_Uns32 psirLen, XMP_Uns32 fileOffset, const char * label ); -static void DumpImageResources ( const JpegMarkers& psirMarkers, XMP_Uns8 * dataStart, const char * label ); -static void DumpIFDChain ( XMP_Uns8 * startPtr, XMP_Uns8 * endPtr, XMP_Uns8 * tiffContent, XMP_Uns32 fileOffset, const char * label, std::string path, bool isHeaderAbsent = false ); +static void DumpTIFF(XMP_Uns8 * tiffContent, XMP_Uns32 tiffLen, XMP_Uns32 fileOffset, const char * label, std::string path, bool isHeaderAbsent = false); +static void DumpTIFF(const JpegMarkers& psirMarkers, XMP_Uns8 * dataStart, const char * label, std::string path); +static void DumpIPTC(XMP_Uns8 * iptcOrigin, XMP_Uns32 iptcLen, XMP_Uns32 fileOffset, const char * label); +static void DumpImageResources(XMP_Uns8 * psirOrigin, XMP_Uns32 psirLen, XMP_Uns32 fileOffset, const char * label); +static void DumpImageResources(const JpegMarkers& psirMarkers, XMP_Uns8 * dataStart, const char * label); +static void DumpIFDChain(XMP_Uns8 * startPtr, XMP_Uns8 * endPtr, XMP_Uns8 * tiffContent, XMP_Uns32 fileOffset, const char * label, std::string path, bool isHeaderAbsent = false); // ================================================================================================= @@ -315,25 +315,25 @@ static GetUns64_Proc TIFF_GetUns64 = 0; enum { // Special TIFF tags - kTIFF_XMP = 700, - kTIFF_IPTC = 33723, - kTIFF_PSIR = 34377, - kTIFF_Exif = 34665, - kTIFF_GPS = 34853, + kTIFF_XMP = 700, + kTIFF_IPTC = 33723, + kTIFF_PSIR = 34377, + kTIFF_Exif = 34665, + kTIFF_GPS = 34853, kTIFF_MakerNote = 37500, - kTIFF_Interop = 40965 + kTIFF_Interop = 40965 }; enum { // Special Photoshop image resource IDs - kPSIR_OldCaption = 1008, - kPSIR_PrintCaption = 1020, - kPSIR_IPTC = 1028, - kPSIR_CopyrightFlag = 1034, - kPSIR_CopyrightURL = 1035, - kPSIR_Exif_1 = 1058, - kPSIR_Exif_3 = 1059, - kPSIR_XMP = 1060, - kPSIR_IPTC_Digest = 1061 + kPSIR_OldCaption = 1008, + kPSIR_PrintCaption = 1020, + kPSIR_IPTC = 1028, + kPSIR_CopyrightFlag = 1034, + kPSIR_CopyrightURL = 1035, + kPSIR_Exif_1 = 1058, + kPSIR_Exif_3 = 1059, + kPSIR_XMP = 1060, + kPSIR_IPTC_Digest = 1061 }; struct IPTC_DataSet { // The 5 byte header of an IPTC DataSet. @@ -345,32 +345,32 @@ }; enum { // IPTC DataSet IDs - kIPTC_IntellectualGenre = 4, - kIPTC_Title = 5, - kIPTC_Urgency = 10, - kIPTC_SubjectCode = 12, - kIPTC_Category = 15, - kIPTC_SuppCategory = 20, - kIPTC_Keyword = 25, - kIPTC_Instructions = 40, - kIPTC_DateCreated = 55, - kIPTC_TimeCreated = 60, - kIPTC_DigitalCreationDate = 62 , - kIPTC_DigitalCreationTime = 63, - kIPTC_Creator = 80, - kIPTC_CreatorJobtitle = 85, - kIPTC_City = 90, - kIPTC_Location = 92, - kIPTC_State = 95, - kIPTC_CountryCode = 100, - kIPTC_Country = 101, - kIPTC_JobID = 103, - kIPTC_Headline = 105, - kIPTC_Provider = 110, - kIPTC_Source = 115, - kIPTC_CopyrightNotice = 116, - kIPTC_Description = 120, - kIPTC_DescriptionWriter = 122 + kIPTC_IntellectualGenre = 4, + kIPTC_Title = 5, + kIPTC_Urgency = 10, + kIPTC_SubjectCode = 12, + kIPTC_Category = 15, + kIPTC_SuppCategory = 20, + kIPTC_Keyword = 25, + kIPTC_Instructions = 40, + kIPTC_DateCreated = 55, + kIPTC_TimeCreated = 60, + kIPTC_DigitalCreationDate = 62, + kIPTC_DigitalCreationTime = 63, + kIPTC_Creator = 80, + kIPTC_CreatorJobtitle = 85, + kIPTC_City = 90, + kIPTC_Location = 92, + kIPTC_State = 95, + kIPTC_CountryCode = 100, + kIPTC_Country = 101, + kIPTC_JobID = 103, + kIPTC_Headline = 105, + kIPTC_Provider = 110, + kIPTC_Source = 115, + kIPTC_CopyrightNotice = 116, + kIPTC_Description = 120, + kIPTC_DescriptionWriter = 122 }; struct DataSetInfo { @@ -408,19 +408,19 @@ { 0, 0 } }; enum { - kTIFF_Uns8 = 1, - kTIFF_ASCII = 2, - kTIFF_Uns16 = 3, - kTIFF_Uns32 = 4, - kTIFF_URational = 5, - kTIFF_Int8 = 6, - kTIFF_Undef8 = 7, - kTIFF_Int16 = 8, - kTIFF_Int32 = 9, - kTIFF_SRational = 10, - kTIFF_Float = 11, - kTIFF_Double = 12, - kTIFF_IFD = 13, + kTIFF_Uns8 = 1, + kTIFF_ASCII = 2, + kTIFF_Uns16 = 3, + kTIFF_Uns32 = 4, + kTIFF_URational = 5, + kTIFF_Int8 = 6, + kTIFF_Undef8 = 7, + kTIFF_Int16 = 8, + kTIFF_Int32 = 9, + kTIFF_SRational = 10, + kTIFF_Float = 11, + kTIFF_Double = 12, + kTIFF_IFD = 13, kTIFF_TypeEnd = kTIFF_IFD }; @@ -531,13 +531,13 @@ XMP_Uns8 part5[6]; // Written in order. ASF_GUID() {}; - ASF_GUID ( XMP_Uns32 p1, XMP_Uns16 p2, XMP_Uns16 p3, XMP_Uns16 p4, const void* p5 ) + ASF_GUID(XMP_Uns32 p1, XMP_Uns16 p2, XMP_Uns16 p3, XMP_Uns16 p4, const void* p5) { - part1 = GetUns32LE (&p1); - part2 = GetUns16LE (&p2); - part3 = GetUns16LE (&p3); - part4 = GetUns16BE (&p4); - memcpy (&part5, p5, 6); + part1 = GetUns32LE(&p1); + part2 = GetUns16LE(&p2); + part3 = GetUns16LE(&p3); + part4 = GetUns16BE(&p4); + memcpy(&part5, p5, 6); }; }; @@ -556,7 +556,7 @@ }; -static const ASF_GUID kASF_HeaderGUID ( 0x75B22630, 0x668E, 0x11CF, 0xA6D9, "\x00\xAA\x00\x62\xCE\x6C" ); +static const ASF_GUID kASF_HeaderGUID(0x75B22630, 0x668E, 0x11CF, 0xA6D9, "\x00\xAA\x00\x62\xCE\x6C"); struct ASF_ObjectInfo { ASF_GUID guid; @@ -566,47 +566,47 @@ static const ASF_ObjectInfo kASF_KnownObjects[] = { - { ASF_GUID (0x75B22630, 0x668E, 0x11CF, 0xA6D9, "\x00\xAA\x00\x62\xCE\x6C"), "Header", kASFObj_Header }, - { ASF_GUID (0x75B22636, 0x668E, 0x11CF, 0xA6D9, "\x00\xAA\x00\x62\xCE\x6C"), "Data", kASFObj_Data }, - { ASF_GUID (0xBE7ACFCB, 0x97A9, 0x42E8, 0x9C71, "\x99\x94\x91\xE3\xAF\xAC"), "XMP", kASFObj_XMP }, - - { ASF_GUID (0x33000890, 0xE5B1, 0x11CF, 0x89F4, "\x00\xA0\xC9\x03\x49\xCB"), "Simple_Index", 0 }, - { ASF_GUID (0xD6E229D3, 0x35DA, 0x11D1, 0x9034, "\x00\xA0\xC9\x03\x49\xBE"), "Index", 0 }, - { ASF_GUID (0xFEB103F8, 0x12AD, 0x4C64, 0x840F, "\x2A\x1D\x2F\x7A\xD4\x8C"), "Media_Object_Index", 0 }, - { ASF_GUID (0x3CB73FD0, 0x0C4A, 0x4803, 0x953D, "\xED\xF7\xB6\x22\x8F\x0C"), "Timecode_Index", 0 }, - - { ASF_GUID (0x8CABDCA1, 0xA947, 0x11CF, 0x8EE4, "\x00\xC0\x0C\x20\x53\x65"), "File_Properties", kASFObj_FileProperties }, - { ASF_GUID (0xB7DC0791, 0xA9B7, 0x11CF, 0x8EE6, "\x00\xC0\x0C\x20\x53\x65"), "Stream_Properties", 0 }, - { ASF_GUID (0x5FBF03B5, 0xA92E, 0x11CF, 0x8EE3, "\x00\xC0\x0C\x20\x53\x65"), "Header_Extension", kASFObj_HeaderExtension }, - { ASF_GUID (0x86D15240, 0x311D, 0x11D0, 0xA3A4, "\x00\xA0\xC9\x03\x48\xF6"), "Codec_List", 0 }, - { ASF_GUID (0x1EFB1A30, 0x0B62, 0x11D0, 0xA39B, "\x00\xA0\xC9\x03\x48\xF6"), "Script_Command", 0 }, - { ASF_GUID (0xF487CD01, 0xA951, 0x11CF, 0x8EE6, "\x00\xC0\x0C\x20\x53\x65"), "Marker", 0 }, - { ASF_GUID (0xD6E229DC, 0x35DA, 0x11D1, 0x9034, "\x00\xA0\xC9\x03\x49\xBE"), "Bitrate_Mutual_Exclusion", 0 }, - { ASF_GUID (0x75B22635, 0x668E, 0x11CF, 0xA6D9, "\x00\xAA\x00\x62\xCE\x6C"), "Error_Correction", 0 }, - { ASF_GUID (0x75B22633, 0x668E, 0x11CF, 0xA6D9, "\x00\xAA\x00\x62\xCE\x6C"), "Content_Description", kASFObj_ContentDesc }, - { ASF_GUID (0xD2D0A440, 0xE307, 0x11D2, 0x97F0, "\x00\xA0\xC9\x5E\xA8\x50"), "Extended_Content_Description", 0 }, - { ASF_GUID (0x2211B3FA, 0xBD23, 0x11D2, 0xB4B7, "\x00\xA0\xC9\x55\xFC\x6E"), "Content_Branding", kASFObj_ContentBrand }, - { ASF_GUID (0x7BF875CE, 0x468D, 0x11D1, 0x8D82, "\x00\x60\x97\xC9\xA2\xB2"), "Stream_Bitrate_Properties", 0 }, - { ASF_GUID (0x2211B3FB, 0xBD23, 0x11D2, 0xB4B7, "\x00\xA0\xC9\x55\xFC\x6E"), "Content_Encryption", kASFObj_ContentEncrypt }, - { ASF_GUID (0x298AE614, 0x2622, 0x4C17, 0xB935, "\xDA\xE0\x7E\xE9\x28\x9C"), "Extended_Content_Encryption", 0 }, - { ASF_GUID (0x2211B3FC, 0xBD23, 0x11D2, 0xB4B7, "\x00\xA0\xC9\x55\xFC\x6E"), "Digital_Signature", 0 }, - { ASF_GUID (0x1806D474, 0xCADF, 0x4509, 0xA4BA, "\x9A\xAB\xCB\x96\xAA\xE8"), "Padding", kASFObj_Padding }, - - { ASF_GUID (0x14E6A5CB, 0xC672, 0x4332, 0x8399, "\xA9\x69\x52\x06\x5B\x5A"), "Extended_Stream_Properties", 0 }, - { ASF_GUID (0xA08649CF, 0x4775, 0x4670, 0x8A16, "\x6E\x35\x35\x75\x66\xCD"), "Advanced_Mutual_Exclusion", 0 }, - { ASF_GUID (0xD1465A40, 0x5A79, 0x4338, 0xB71B, "\xE3\x6B\x8F\xD6\xC2\x49"), "Group_Mutual_Exclusion", 0 }, - { ASF_GUID (0xD4FED15B, 0x88D3, 0x454F, 0x81F0, "\xED\x5C\x45\x99\x9E\x24"), "Stream_Prioritization", 0 }, - { ASF_GUID (0xA69609E6, 0x517B, 0x11D2, 0xB6AF, "\x00\xC0\x4F\xD9\x08\xE9"), "Bandwidth_Sharing", 0 }, - { ASF_GUID (0x7C4346A9, 0xEFE0, 0x4BFC, 0xB229, "\x39\x3E\xDE\x41\x5C\x85"), "Language_List", 0 }, - { ASF_GUID (0xC5F8CBEA, 0x5BAF, 0x4877, 0x8467, "\xAA\x8C\x44\xFA\x4C\xCA"), "Metadata", 0 }, - { ASF_GUID (0x44231C94, 0x9498, 0x49D1, 0xA141, "\x1D\x13\x4E\x45\x70\x54"), "Metadata_Library", 0 }, - { ASF_GUID (0xD6E229DF, 0x35DA, 0x11D1, 0x9034, "\x00\xA0\xC9\x03\x49\xBE"), "Index_Parameters", 0 }, - { ASF_GUID (0x6B203BAD, 0x3F11, 0x48E4, 0xACA8, "\xD7\x61\x3D\xE2\xCF\xA7"), "Media_Object_Index_Parameters", 0 }, - { ASF_GUID (0xF55E496D, 0x9797, 0x4B5D, 0x8C8B, "\x60\x4D\xFE\x9B\xFB\x24"), "Timecode_Index_Parameters", 0 }, - { ASF_GUID (0x75B22630, 0x668E, 0x11CF, 0xA6D9, "\x00\xAA\x00\x62\xCE\x6C"), "Compatibility", 0 }, - { ASF_GUID (0x43058533, 0x6981, 0x49E6, 0x9B74, "\xAD\x12\xCB\x86\xD5\x8C"), "Advanced_Content_Encryption", 0 }, + { ASF_GUID(0x75B22630, 0x668E, 0x11CF, 0xA6D9, "\x00\xAA\x00\x62\xCE\x6C"), "Header", kASFObj_Header }, +{ ASF_GUID(0x75B22636, 0x668E, 0x11CF, 0xA6D9, "\x00\xAA\x00\x62\xCE\x6C"), "Data", kASFObj_Data }, +{ ASF_GUID(0xBE7ACFCB, 0x97A9, 0x42E8, 0x9C71, "\x99\x94\x91\xE3\xAF\xAC"), "XMP", kASFObj_XMP }, + +{ ASF_GUID(0x33000890, 0xE5B1, 0x11CF, 0x89F4, "\x00\xA0\xC9\x03\x49\xCB"), "Simple_Index", 0 }, +{ ASF_GUID(0xD6E229D3, 0x35DA, 0x11D1, 0x9034, "\x00\xA0\xC9\x03\x49\xBE"), "Index", 0 }, +{ ASF_GUID(0xFEB103F8, 0x12AD, 0x4C64, 0x840F, "\x2A\x1D\x2F\x7A\xD4\x8C"), "Media_Object_Index", 0 }, +{ ASF_GUID(0x3CB73FD0, 0x0C4A, 0x4803, 0x953D, "\xED\xF7\xB6\x22\x8F\x0C"), "Timecode_Index", 0 }, + +{ ASF_GUID(0x8CABDCA1, 0xA947, 0x11CF, 0x8EE4, "\x00\xC0\x0C\x20\x53\x65"), "File_Properties", kASFObj_FileProperties }, +{ ASF_GUID(0xB7DC0791, 0xA9B7, 0x11CF, 0x8EE6, "\x00\xC0\x0C\x20\x53\x65"), "Stream_Properties", 0 }, +{ ASF_GUID(0x5FBF03B5, 0xA92E, 0x11CF, 0x8EE3, "\x00\xC0\x0C\x20\x53\x65"), "Header_Extension", kASFObj_HeaderExtension }, +{ ASF_GUID(0x86D15240, 0x311D, 0x11D0, 0xA3A4, "\x00\xA0\xC9\x03\x48\xF6"), "Codec_List", 0 }, +{ ASF_GUID(0x1EFB1A30, 0x0B62, 0x11D0, 0xA39B, "\x00\xA0\xC9\x03\x48\xF6"), "Script_Command", 0 }, +{ ASF_GUID(0xF487CD01, 0xA951, 0x11CF, 0x8EE6, "\x00\xC0\x0C\x20\x53\x65"), "Marker", 0 }, +{ ASF_GUID(0xD6E229DC, 0x35DA, 0x11D1, 0x9034, "\x00\xA0\xC9\x03\x49\xBE"), "Bitrate_Mutual_Exclusion", 0 }, +{ ASF_GUID(0x75B22635, 0x668E, 0x11CF, 0xA6D9, "\x00\xAA\x00\x62\xCE\x6C"), "Error_Correction", 0 }, +{ ASF_GUID(0x75B22633, 0x668E, 0x11CF, 0xA6D9, "\x00\xAA\x00\x62\xCE\x6C"), "Content_Description", kASFObj_ContentDesc }, +{ ASF_GUID(0xD2D0A440, 0xE307, 0x11D2, 0x97F0, "\x00\xA0\xC9\x5E\xA8\x50"), "Extended_Content_Description", 0 }, +{ ASF_GUID(0x2211B3FA, 0xBD23, 0x11D2, 0xB4B7, "\x00\xA0\xC9\x55\xFC\x6E"), "Content_Branding", kASFObj_ContentBrand }, +{ ASF_GUID(0x7BF875CE, 0x468D, 0x11D1, 0x8D82, "\x00\x60\x97\xC9\xA2\xB2"), "Stream_Bitrate_Properties", 0 }, +{ ASF_GUID(0x2211B3FB, 0xBD23, 0x11D2, 0xB4B7, "\x00\xA0\xC9\x55\xFC\x6E"), "Content_Encryption", kASFObj_ContentEncrypt }, +{ ASF_GUID(0x298AE614, 0x2622, 0x4C17, 0xB935, "\xDA\xE0\x7E\xE9\x28\x9C"), "Extended_Content_Encryption", 0 }, +{ ASF_GUID(0x2211B3FC, 0xBD23, 0x11D2, 0xB4B7, "\x00\xA0\xC9\x55\xFC\x6E"), "Digital_Signature", 0 }, +{ ASF_GUID(0x1806D474, 0xCADF, 0x4509, 0xA4BA, "\x9A\xAB\xCB\x96\xAA\xE8"), "Padding", kASFObj_Padding }, + +{ ASF_GUID(0x14E6A5CB, 0xC672, 0x4332, 0x8399, "\xA9\x69\x52\x06\x5B\x5A"), "Extended_Stream_Properties", 0 }, +{ ASF_GUID(0xA08649CF, 0x4775, 0x4670, 0x8A16, "\x6E\x35\x35\x75\x66\xCD"), "Advanced_Mutual_Exclusion", 0 }, +{ ASF_GUID(0xD1465A40, 0x5A79, 0x4338, 0xB71B, "\xE3\x6B\x8F\xD6\xC2\x49"), "Group_Mutual_Exclusion", 0 }, +{ ASF_GUID(0xD4FED15B, 0x88D3, 0x454F, 0x81F0, "\xED\x5C\x45\x99\x9E\x24"), "Stream_Prioritization", 0 }, +{ ASF_GUID(0xA69609E6, 0x517B, 0x11D2, 0xB6AF, "\x00\xC0\x4F\xD9\x08\xE9"), "Bandwidth_Sharing", 0 }, +{ ASF_GUID(0x7C4346A9, 0xEFE0, 0x4BFC, 0xB229, "\x39\x3E\xDE\x41\x5C\x85"), "Language_List", 0 }, +{ ASF_GUID(0xC5F8CBEA, 0x5BAF, 0x4877, 0x8467, "\xAA\x8C\x44\xFA\x4C\xCA"), "Metadata", 0 }, +{ ASF_GUID(0x44231C94, 0x9498, 0x49D1, 0xA141, "\x1D\x13\x4E\x45\x70\x54"), "Metadata_Library", 0 }, +{ ASF_GUID(0xD6E229DF, 0x35DA, 0x11D1, 0x9034, "\x00\xA0\xC9\x03\x49\xBE"), "Index_Parameters", 0 }, +{ ASF_GUID(0x6B203BAD, 0x3F11, 0x48E4, 0xACA8, "\xD7\x61\x3D\xE2\xCF\xA7"), "Media_Object_Index_Parameters", 0 }, +{ ASF_GUID(0xF55E496D, 0x9797, 0x4B5D, 0x8C8B, "\x60\x4D\xFE\x9B\xFB\x24"), "Timecode_Index_Parameters", 0 }, +{ ASF_GUID(0x75B22630, 0x668E, 0x11CF, 0xA6D9, "\x00\xAA\x00\x62\xCE\x6C"), "Compatibility", 0 }, +{ ASF_GUID(0x43058533, 0x6981, 0x49E6, 0x9B74, "\xAD\x12\xCB\x86\xD5\x8C"), "Advanced_Content_Encryption", 0 }, - { ASF_GUID (0x00000000, 0x0000, 0x0000, 0x0000, "\x00\x00\x00\x00\x00\x00"), 0, 0 } +{ ASF_GUID(0x00000000, 0x0000, 0x0000, 0x0000, "\x00\x00\x00\x00\x00\x00"), 0, 0 } }; struct ASF_ObjHeader { @@ -685,35 +685,35 @@ // ================================================================================================= enum { - kINDD_PageSize = 4096, + kINDD_PageSize = 4096, kINDD_LittleEndian = 1, - kINDD_BigEndian = 2, - kInDesignGUIDSize = 16 + kINDD_BigEndian = 2, + kInDesignGUIDSize = 16 }; struct InDesignMasterPage { - XMP_Uns8 fGUID [kInDesignGUIDSize]; - XMP_Uns8 fMagicBytes [8]; + XMP_Uns8 fGUID[kInDesignGUIDSize]; + XMP_Uns8 fMagicBytes[8]; XMP_Uns8 fObjectStreamEndian; - XMP_Uns8 fIrrelevant1 [239]; + XMP_Uns8 fIrrelevant1[239]; XMP_Uns64 fSequenceNumber; - XMP_Uns8 fIrrelevant2 [8]; + XMP_Uns8 fIrrelevant2[8]; XMP_Uns32 fFilePages; - XMP_Uns8 fIrrelevant3 [3812]; + XMP_Uns8 fIrrelevant3[3812]; }; -static const XMP_Uns8 kInDesign_MasterPageGUID [kInDesignGUIDSize] = +static const XMP_Uns8 kInDesign_MasterPageGUID[kInDesignGUIDSize] = { 0x06, 0x06, 0xED, 0xF5, 0xD8, 0x1D, 0x46, 0xE5, 0xBD, 0x31, 0xEF, 0xE7, 0xFE, 0x74, 0xB7, 0x1D }; struct InDesignContigObjMarker { - XMP_Uns8 fGUID [kInDesignGUIDSize]; + XMP_Uns8 fGUID[kInDesignGUIDSize]; XMP_Uns32 fObjectUID; XMP_Uns32 fObjectClassID; XMP_Uns32 fStreamLength; XMP_Uns32 fChecksum; }; -static const XMP_Uns8 kINDDContigObjHeaderGUID [kInDesignGUIDSize] = +static const XMP_Uns8 kINDDContigObjHeaderGUID[kInDesignGUIDSize] = { 0xDE, 0x39, 0x39, 0x79, 0x51, 0x88, 0x4B, 0x6C, 0x8E, 0x63, 0xEE, 0xF8, 0xAE, 0xE0, 0xDD, 0x38 }; // ================================================================================================= @@ -786,6 +786,19 @@ { 0, kXMP_UnknownFile } }; // ! Must be last as a sentinel. + // Vector of keys in quicktime file in the order in which they appear +vector ISOMetaKeys; + +XMP_Int32 entryCount_dref; +XMP_Uns16 exif_item_id; +XMP_Uns16 mime_item_id; +std::string item_name; +XMP_Uns32 item_type; +std::string content_type; +std::string url_location; +std::string content_encoding; + + // File convenience wrappers (now LFA-based) ==================================== // skip forward by bytes and verify not beyond EOF @@ -800,21 +813,21 @@ // (yes redundant to above but "makes a better read") void static Rewind(LFA_FileRef file, XMP_Int64 size) { - assertMsg("use positive values",size > 0); - LFA_Seek (file, -size, SEEK_CUR); // ditto to above + assertMsg("use positive values", size > 0); + LFA_Seek(file, -size, SEEK_CUR); // ditto to above } #if 0 // overload, no size parameter, rewinds to start void static Rewind(LFA_FileRef file) { - LFA_Seek (file, 0, SEEK_SET); + LFA_Seek(file, 0, SEEK_SET); } #endif -XMP_Uns32 static Peek32u(LFA_FileRef file, bool bigEndian = false ) +XMP_Uns32 static Peek32u(LFA_FileRef file, bool bigEndian = false) { - XMP_Uns32 value = tree->digest32u(file, "", bigEndian ); + XMP_Uns32 value = tree->digest32u(file, "", bigEndian); Rewind(file, 4); return value; } @@ -823,94 +836,94 @@ // ================================================================================================= static XMP_FileFormat -LookupFileExtMapping ( const char * filePath ) +LookupFileExtMapping(const char * filePath) { std::string fileExt; - size_t extPos = strlen (filePath); - for ( --extPos; extPos > 0; --extPos ) if ( filePath[extPos] == '.' ) break; + size_t extPos = strlen(filePath); + for (--extPos; extPos > 0; --extPos) if (filePath[extPos] == '.') break; - if ( filePath[extPos] != '.' ) return kXMP_UnknownFile; + if (filePath[extPos] != '.') return kXMP_UnknownFile; ++extPos; - fileExt.assign ( &filePath[extPos] ); - for ( size_t i = 0; i < fileExt.size(); ++i ) { - if ( ('A' <= fileExt[i]) && (fileExt[i] <= 'Z') ) fileExt[i] += 0x20; + fileExt.assign(&filePath[extPos]); + for (size_t i = 0; i < fileExt.size(); ++i) { + if (('A' <= fileExt[i]) && (fileExt[i] <= 'Z')) fileExt[i] += 0x20; } size_t mapPos; - for ( mapPos = 0; kFileExtMap[mapPos].ext != 0; ++mapPos ) { - if ( fileExt == kFileExtMap[mapPos].ext ) break; + for (mapPos = 0; kFileExtMap[mapPos].ext != 0; ++mapPos) { + if (fileExt == kFileExtMap[mapPos].ext) break; } return kFileExtMap[mapPos].format; } // LookupFileExtMapping -// ================================================================================================= + // ================================================================================================= -//*** used by in-RAM code? needs replacement? + //*** used by in-RAM code? needs replacement? static void -CaptureFileData ( LFA_FileRef file, XMP_Int64 offset, XMP_Uns32 length ) +CaptureFileData(LFA_FileRef file, XMP_Int64 offset, XMP_Uns32 length) { - if ( length > sDataMax ) { - if ( sDataPtr != 0 ) free (sDataPtr); - sDataPtr = (XMP_Uns8*) malloc (length); + if (length > sDataMax) { + if (sDataPtr != 0) free(sDataPtr); + sDataPtr = (XMP_Uns8*)malloc(length); sDataMax = length; } - if ( offset != 0 ) LFA_Seek ( file, (long)offset, SEEK_SET ); - LFA_Read ( file, sDataPtr, length, true); + if (offset != 0) LFA_Seek(file, (long)offset, SEEK_SET); + LFA_Read(file, sDataPtr, length, true); sDataLen = length; } // CaptureFileData -// ------------------------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------------------------- -//*** used by in-RAM code? needs replacement !!! + //*** used by in-RAM code? needs replacement !!! static void -CaptureXMPF ( LFA_FileRef file, XMP_Int64 offset, XMP_Uns32 length ) +CaptureXMPF(LFA_FileRef file, XMP_Int64 offset, XMP_Uns32 length) { - if ( length > sXMPMax ) { - if ( sXMPPtr != 0 ) free (sXMPPtr); - sXMPPtr = (XMP_Uns8*) malloc (length); + if (length > sXMPMax) { + if (sXMPPtr != 0) free(sXMPPtr); + sXMPPtr = (XMP_Uns8*)malloc(length); sXMPMax = length; } - if ( offset != 0 ) LFA_Seek ( file, (long)offset, SEEK_SET ); - LFA_Read ( file, sXMPPtr, length, true); + if (offset != 0) LFA_Seek(file, (long)offset, SEEK_SET); + LFA_Read(file, sXMPPtr, length, true); sXMPLen = length; sXMPPos = offset; } // CaptureXMPF -// ------------------------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------------------------- static void -CaptureXMP ( const XMP_Uns8 * xmpPtr, const XMP_Uns32 xmpLen, XMP_Int64 fileOffset ) +CaptureXMP(const XMP_Uns8 * xmpPtr, const XMP_Uns32 xmpLen, XMP_Int64 fileOffset) { - if ( xmpLen > sXMPMax ) { - if (sXMPPtr != 0) free (sXMPPtr); - sXMPPtr = (XMP_Uns8*) malloc (xmpLen); + if (xmpLen > sXMPMax) { + if (sXMPPtr != 0) free(sXMPPtr); + sXMPPtr = (XMP_Uns8*)malloc(xmpLen); sXMPMax = xmpLen; } - memcpy ( sXMPPtr, xmpPtr, xmpLen ); + memcpy(sXMPPtr, xmpPtr, xmpLen); sXMPLen = xmpLen; sXMPPos = fileOffset; } // CaptureXMP -// ------------------------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------------------------- -static void PrintOnlyASCII_8 ( XMP_Uns8 * strPtr, XMP_Uns32 strLen, bool stopOnNUL = true ) +static void PrintOnlyASCII_8(XMP_Uns8 * strPtr, XMP_Uns32 strLen, bool stopOnNUL = true) { //wrapping to QEBuginese // - NB: remainder (zero termination earlier then length) is catered for... - tree->addComment ( convert8Bit ( strPtr, stopOnNUL, strLen ) ); + tree->addComment(convert8Bit(strPtr, stopOnNUL, strLen)); } // ------------------------------------------------------------------------------------------------- @@ -919,36 +932,36 @@ // its always added as a comment, even if value was more appropriate. // ==> callers should make use of convert16Bit directly. #if 0 -static void PrintOnlyASCII_16BE ( XMP_Uns16 * u16Ptr, XMP_Uns32 u16Bytes, bool stopOnNUL = true ) +static void PrintOnlyASCII_16BE(XMP_Uns16 * u16Ptr, XMP_Uns32 u16Bytes, bool stopOnNUL = true) { - tree->addComment ( convert16Bit( true, (XMP_Uns8*) u16Ptr, stopOnNUL, u16Bytes ) ); + tree->addComment(convert16Bit(true, (XMP_Uns8*)u16Ptr, stopOnNUL, u16Bytes)); } // PrintOnlyASCII_16BE -// ------------------------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------------------------- -static void PrintOnlyASCII_16LE ( XMP_Uns16 * u16Ptr, XMP_Uns32 u16Bytes, bool stopOnNUL = true ) +static void PrintOnlyASCII_16LE(XMP_Uns16 * u16Ptr, XMP_Uns32 u16Bytes, bool stopOnNUL = true) { - tree->addComment ( convert16Bit( false, (XMP_Uns8*) u16Ptr, stopOnNUL, u16Bytes ) ); + tree->addComment(convert16Bit(false, (XMP_Uns8*)u16Ptr, stopOnNUL, u16Bytes)); } // PrintOnlyASCII_16LE #endif -// ================================================================================================= + // ================================================================================================= static const XMP_Int64 kJPEGMinSize = 4; // At least the SOI and EOI markers. static const XMP_Uns8 kJPEGStart[] = { 0xFF, 0xD8, 0xFF }; // 0xFFD8 is SOI, plus 0xFF for next marker. -static const XMP_Int64 kPhotoshopMinSize = 26 + 4*4; // At least the file header and 4 section lengths. +static const XMP_Int64 kPhotoshopMinSize = 26 + 4 * 4; // At least the file header and 4 section lengths. static const XMP_Uns8 kPhotoshopV1Start[] = { 0x38, 0x42, 0x50, 0x53, 0x00, 0x01 }; // 0x38425053 is "8BPS". static const XMP_Uns8 kPhotoshopV2Start[] = { 0x38, 0x42, 0x50, 0x53, 0x00, 0x02 }; -static const XMP_Int64 kTIFFMinSize = 8+2+12+4; // At least the header plus 1 minimal IFD. -static const XMP_Uns8 kTIFFBigStart[] = { 0x4D, 0x4D, 0x00, 0x2A }; // 0x4D is 'M', 0x2A is 42. +static const XMP_Int64 kTIFFMinSize = 8 + 2 + 12 + 4; // At least the header plus 1 minimal IFD. +static const XMP_Uns8 kTIFFBigStart[] = { 0x4D, 0x4D, 0x00, 0x2A }; // 0x4D is 'M', 0x2A is 42. static const XMP_Uns8 kTIFFLittleStart[] = { 0x49, 0x49, 0x2A, 0x00 }; // 0x49 is 'I'. -static const XMP_Int64 kJPEG2KMinSize = 12+16; // At least the signature and minimal file type boxes. +static const XMP_Int64 kJPEG2KMinSize = 12 + 16; // At least the signature and minimal file type boxes. static const XMP_Uns8 kJPEG2KStart[] = { 0x00, 0x00, 0x00, 0x0C, 0x6A, 0x50, 0x20, 0x20, 0x0D, 0x0A, 0x87, 0x0A }; -static const XMP_Int64 kPNGMinSize = 8 + (12+13) + 12; // At least the file header plus IHDR and IEND chunks. +static const XMP_Int64 kPNGMinSize = 8 + (12 + 13) + 12; // At least the file header plus IHDR and IEND chunks. static const XMP_Uns8 kPNGStart[] = { 137, 80, 78, 71, 13, 10, 26, 10 }; static const XMP_Int64 kASFMinSize = 16; // ! Not really accurate, but covers the header GUID. @@ -961,104 +974,105 @@ static const XMP_Int64 kInDesignMinSize = 2 * kINDD_PageSize; // Two master pages. static const XMP_Int64 kISOMediaMinSize = 16; // At least a minimal file type box. -static const XMP_Uns8 kISOMediaFTyp[] = { 0x66, 0x74, 0x79, 0x70 }; // "ftyp" -static const XMP_Uns32 kISOTag_ftyp = 0x66747970UL; +static const XMP_Uns8 kISOMediaFTyp[] = { 0x66, 0x74, 0x79, 0x70 }; // "ftyp" +static const XMP_Uns32 kISOTag_ftyp = 0x66747970UL; static const XMP_Uns32 kISOBrand_mp41 = 0x6D703431UL; static const XMP_Uns32 kISOBrand_mp42 = 0x6D703432UL; static const XMP_Uns32 kISOBrand_avc1 = 0x61766331UL; -static const XMP_Uns32 kISOBrand_f4v = 0x66347620UL; +static const XMP_Uns32 kISOBrand_f4v = 0x66347620UL; static const XMP_Uns32 kISOBrand_isom = 0x69736F6DUL; static const XMP_Uns32 kISOBrand_3gp4 = 0x33677034UL; static const XMP_Uns32 kISOBrand_3g2a = 0x33673261UL; static const XMP_Uns32 kISOBrand_3g2b = 0x33673262UL; static const XMP_Uns32 kISOBrand_3g2c = 0x33673263UL; +static const XMP_Uns32 kISOBrand_mif1 = 0x6D696631UL; -static const XMP_Uns32 kQTTag_XMP_ = 0x584D505FUL; +static const XMP_Uns32 kQTTag_XMP_ = 0x584D505FUL; -static const XMP_Int64 kSWFMinSize = (8+2+4 + 2); // Header with minimal rectangle and an End tag. +static const XMP_Int64 kSWFMinSize = (8 + 2 + 4 + 2); // Header with minimal rectangle and an End tag. static const XMP_Int64 kFLVMinSize = 9; // Header with zero length data. static const XMP_Uns8 kPostScriptStart[] = { 0xC5, 0xD0, 0xD3, 0xC6 }; static XMP_FileFormat -CheckFileFormat ( const char * filePath, XMP_Uns8 * fileContent, XMP_Int64 fileSize ) +CheckFileFormat(const char * filePath, XMP_Uns8 * fileContent, XMP_Int64 fileSize) { // ! The buffer passed to CheckFileFormat is just the first 4K bytes of the file. - if ( (fileSize >= kJPEGMinSize) && CheckBytes (fileContent, kJPEGStart, 3) ) { + if ((fileSize >= kJPEGMinSize) && CheckBytes(fileContent, kJPEGStart, 3)) { return kXMP_JPEGFile; } - if ( (fileSize >= kPhotoshopMinSize) && - (CheckBytes ( fileContent, kPhotoshopV1Start, 6 ) || CheckBytes ( fileContent, kPhotoshopV2Start, 6 )) ) { - return kXMP_PhotoshopFile; + if ((fileSize >= kPhotoshopMinSize) && + (CheckBytes(fileContent, kPhotoshopV1Start, 6) || CheckBytes(fileContent, kPhotoshopV2Start, 6))) { + return kXMP_PhotoshopFile; } - if ( (fileSize >= kTIFFMinSize ) && - (CheckBytes ( fileContent, kTIFFBigStart , 4 ) || CheckBytes ( fileContent, kTIFFLittleStart, 4 )) ) { - return kXMP_TIFFFile; + if ((fileSize >= kTIFFMinSize) && + (CheckBytes(fileContent, kTIFFBigStart, 4) || CheckBytes(fileContent, kTIFFLittleStart, 4))) { + return kXMP_TIFFFile; } - if ( (fileSize >= kJPEG2KMinSize) && CheckBytes ( fileContent, kJPEG2KStart, 12 ) ) { + if ((fileSize >= kJPEG2KMinSize) && CheckBytes(fileContent, kJPEG2KStart, 12)) { return kXMP_JPEG2KFile; } - if ( (fileSize >= kASFMinSize) && CheckBytes ( fileContent, &kASF_HeaderGUID, 16 ) ) { + if ((fileSize >= kASFMinSize) && CheckBytes(fileContent, &kASF_HeaderGUID, 16)) { return kXMP_WMAVFile; } - if ( (fileSize >= kPNGMinSize) && CheckBytes ( fileContent, kPNGStart, 8 ) ) { + if ((fileSize >= kPNGMinSize) && CheckBytes(fileContent, kPNGStart, 8)) { return kXMP_PNGFile; } - if ( (fileSize >= kRIFFMinSize) && CheckBytes ( fileContent, "RIFF", 4 ) ) { - if ( CheckBytes ( fileContent+8, "AVI ", 4 ) ) return kXMP_AVIFile; - if ( CheckBytes ( fileContent+8, "WAVE", 4 ) ) return kXMP_WAVFile; + if ((fileSize >= kRIFFMinSize) && CheckBytes(fileContent, "RIFF", 4)) { + if (CheckBytes(fileContent + 8, "AVI ", 4)) return kXMP_AVIFile; + if (CheckBytes(fileContent + 8, "WAVE", 4)) return kXMP_WAVFile; } - if ( (fileSize >= kRIFFMinSize) && CheckBytes ( fileContent, "RF64", 4 ) ) { - if ( CheckBytes ( fileContent+8, "WAVE", 4 ) ) return kXMP_WAVFile; + if ((fileSize >= kRIFFMinSize) && CheckBytes(fileContent, "RF64", 4)) { + if (CheckBytes(fileContent + 8, "WAVE", 4)) return kXMP_WAVFile; } - if ( (fileSize >= kRIFFMinSize) && CheckBytes ( fileContent, "FORM", 4 ) ) { - if ( CheckBytes ( fileContent+8, "AIFF ", 4 ) ) return kXMP_AIFFFile; - if ( CheckBytes ( fileContent+8, "AIFC", 4 ) ) return kXMP_AIFFFile; + if ((fileSize >= kRIFFMinSize) && CheckBytes(fileContent, "FORM", 4)) { + if (CheckBytes(fileContent + 8, "AIFF ", 4)) return kXMP_AIFFFile; + if (CheckBytes(fileContent + 8, "AIFC", 4)) return kXMP_AIFFFile; } - if ( (fileSize >= kPostScriptMinSize) && CheckBytes (fileContent, kPostScriptStart, 4) ) { + if ((fileSize >= kPostScriptMinSize) && CheckBytes(fileContent, kPostScriptStart, 4)) { return kXMP_PostScriptFile; } - if ( (fileSize >= kInDesignMinSize) && CheckBytes ( fileContent, kInDesign_MasterPageGUID, kInDesignGUIDSize ) ) { + if ((fileSize >= kInDesignMinSize) && CheckBytes(fileContent, kInDesign_MasterPageGUID, kInDesignGUIDSize)) { return kXMP_InDesignFile; } - if ( (fileSize >= kSWFMinSize) && - (CheckBytes ( fileContent, "FWS", 3 ) || CheckBytes ( fileContent, "CWS", 3 )) && - (fileContent[3] <= 10 /* 2007 latest is 8 */) ) { + if ((fileSize >= kSWFMinSize) && + (CheckBytes(fileContent, "FWS", 3) || CheckBytes(fileContent, "CWS", 3)) && + (fileContent[3] <= 10 /* 2007 latest is 8 */)) { return kXMP_SWFFile; } - - if ( (fileSize >= kFLVMinSize) && - CheckBytes ( fileContent, "FLV", 3 ) && - (fileContent[3] <= 10 /* 2007 latest is 1 */) ) { + + if ((fileSize >= kFLVMinSize) && + CheckBytes(fileContent, "FLV", 3) && + (fileContent[3] <= 10 /* 2007 latest is 1 */)) { return kXMP_FLVFile; } - if ( (fileSize >= kISOMediaMinSize) && CheckBytes ( fileContent+4, kISOMediaFTyp, 4 ) ) { + if ((fileSize >= kISOMediaMinSize) && CheckBytes(fileContent + 4, kISOMediaFTyp, 4)) { - XMP_Uns32 ftypLen = GetUns32BE (fileContent); - if ( ftypLen == 0 ) ftypLen = fileSize; - if ( (ftypLen < kISOMediaMinSize) || (ftypLen > fileSize) || (ftypLen > 4096) ) return kXMP_UnknownFile; + XMP_Uns32 ftypLen = GetUns32BE(fileContent); + if (ftypLen == 0) ftypLen = fileSize; + if ((ftypLen < kISOMediaMinSize) || (ftypLen > fileSize) || (ftypLen > 4096)) return kXMP_UnknownFile; XMP_Uns8 * compatPtr = fileContent + 16; XMP_Uns8 * compatEnd = fileContent + ftypLen; - for ( ; compatPtr < compatEnd; compatPtr += 4 ) { - XMP_Uns32 compatBrand = GetUns32BE (compatPtr); - switch ( compatBrand ) { + for (; compatPtr < compatEnd; compatPtr += 4) { + XMP_Uns32 compatBrand = GetUns32BE(compatPtr); + switch (compatBrand) { case kISOBrand_mp41: case kISOBrand_mp42: case kISOBrand_avc1: @@ -1069,7 +1083,9 @@ case kISOBrand_3g2c: return kXMP_MPEG4File; break; - + case kISOBrand_mif1: + return kXMP_HEIFFile; + break; default: break; @@ -1079,20 +1095,20 @@ } - if ( (fileSize > 30) && CheckBytes ( fileContent, "\x50\x4B\x03\x04", 4 ) ) { // "PK 03 04" + if ((fileSize > 30) && CheckBytes(fileContent, "\x50\x4B\x03\x04", 4)) { // "PK 03 04" return kXMP_UCFFile; } // ! Do MP3 next to last. It uses the file extension if there is no ID3. - if ( CheckBytes ( fileContent, "ID3", 3 ) || - (LookupFileExtMapping (filePath) == kXMP_MP3File) ) return kXMP_MP3File; + if (CheckBytes(fileContent, "ID3", 3) || + (LookupFileExtMapping(filePath) == kXMP_MP3File)) return kXMP_MP3File; // ! Do MPEG (MP2) and MOV last. They use just the file extension, not content. - if ( LookupFileExtMapping (filePath) == kXMP_MPEGFile ) return kXMP_MPEGFile; - if ( LookupFileExtMapping (filePath) == kXMP_MOVFile ) return kXMP_MOVFile; + if (LookupFileExtMapping(filePath) == kXMP_MPEGFile) return kXMP_MPEGFile; + if (LookupFileExtMapping(filePath) == kXMP_MOVFile) return kXMP_MOVFile; std::string fileData = (char*)fileContent; - if ( (fileSize > 30) && (int)fileData.find ( "= 0 ) { + if ((fileSize > 30) && (int)fileData.find("= 0) { return kXMP_SVGFile; } @@ -1100,25 +1116,26 @@ } // CheckFileFormat -// ================================================================================================= -// DumpXMP -// ======= + // ================================================================================================= + // DumpXMP + // ======= static void -DumpXMP (XMP_Uns8 * xmpPtr, XMP_Uns32 xmpLen, XMP_Int64 xmpOffset, const char * label) +DumpXMP(XMP_Uns8 * xmpPtr, XMP_Uns32 xmpLen, XMP_Int64 xmpOffset, const char * label) { if (xmpOffset <= 0xFFFFFFFFL) { tree->pushNode("XMP"); - tree->addComment("from %s, offset %u (0x%X), size %d", + tree->addComment("from %s, offset %u (0x%X), size %d", label, (XMP_Uns32)xmpOffset, (XMP_Uns32)xmpOffset, xmpLen); - } else { + } + else { tree->pushNode("XMP"); tree->addComment("from %s, offset %ll (0x%X-%.8X), size %d", label, High32(xmpOffset), Low32(xmpOffset), xmpLen); } //bool atStart = true; - SXMPMeta xmp ((XMP_StringPtr)xmpPtr, xmpLen); + SXMPMeta xmp((XMP_StringPtr)xmpPtr, xmpLen); xmp.Sort(); //FNO: could be reactived, but makes the dump naturally very long - harder to read for dev work @@ -1132,24 +1149,24 @@ // an (old) wrapper for above function relying on static, "global" variables static void -DumpXMP (const char * label) +DumpXMP(const char * label) { - DumpXMP (sXMPPtr, sXMPLen, sXMPPos, label); + DumpXMP(sXMPPtr, sXMPLen, sXMPPos, label); } // DumpXMP -// ================================================================================================= -// DumpIPTC -// ======== -// -// The IPTC (IIM, NAA) values are in a sequence of "data sets". Each has a 5 byte header followed -// by the value. There is no overall length in the sequence itself. Photoshop writes this in TIFF -// as LONGs (4 byte chunks), so there might be padding at the end. + // ================================================================================================= + // DumpIPTC + // ======== + // + // The IPTC (IIM, NAA) values are in a sequence of "data sets". Each has a 5 byte header followed + // by the value. There is no overall length in the sequence itself. Photoshop writes this in TIFF + // as LONGs (4 byte chunks), so there might be padding at the end. static void -DumpIPTC (XMP_Uns8 * iptcOrigin, XMP_Uns32 iptcLen, XMP_Uns32 fileOffset, const char * label) +DumpIPTC(XMP_Uns8 * iptcOrigin, XMP_Uns32 iptcLen, XMP_Uns32 fileOffset, const char * label) { tree->pushNode("IPTC data"); - tree->addComment("from %s, offset %d (0x%X), size %d", + tree->addComment("from %s, offset %d (0x%X), size %d", label, fileOffset, fileOffset, iptcLen); // ** Compute and print the MD5 digest. @@ -1178,7 +1195,7 @@ //key come here =================== tree->setKeyValue( - fromArgs("IPTC:%d:%d", currDS->recordNumber, currDS->dataSetNumber),""); + fromArgs("IPTC:%d:%d", currDS->recordNumber, currDS->dataSetNumber), ""); tree->addComment("offset %d (0x%X), size %d", dsOffset, dsOffset, valueLen); @@ -1186,31 +1203,34 @@ //LF only 1:** and 2:** bother us - } else if (currDS->recordNumber == 1) { + } + else if (currDS->recordNumber == 1) { switch (currDS->dataSetNumber) { - case 0 : - { - XMP_Uns16 version = GetUns16BE (valuePtr); - tree->addComment("version = 0x%.4X", version); - break; - } - case 90 : - if (valueLen == 3) { - tree->addComment("encoding = 0x%.2X%.2X%.2X", valuePtr[0], valuePtr[1], valuePtr[2]); - if (memcmp (valuePtr, "\x1B\x25\x47", 3) == 0) tree->addComment(" (UTF-8)"); - } - break; - default : - break; + case 0: + { + XMP_Uns16 version = GetUns16BE(valuePtr); + tree->addComment("version = 0x%.4X", version); + break; + } + case 90: + if (valueLen == 3) { + tree->addComment("encoding = 0x%.2X%.2X%.2X", valuePtr[0], valuePtr[1], valuePtr[2]); + if (memcmp(valuePtr, "\x1B\x25\x47", 3) == 0) tree->addComment(" (UTF-8)"); + } + break; + default: + break; } - } else if (currDS->dataSetNumber == 0) { + } + else if (currDS->dataSetNumber == 0) { - XMP_Uns16 version = GetUns16BE (valuePtr); + XMP_Uns16 version = GetUns16BE(valuePtr); tree->addComment(",Version = 0x%.4X", version); - } else { + } + else { int ds; for (ds = 0; kDataSetNames[ds].name != 0; ++ds) { @@ -1218,9 +1238,10 @@ } if (kDataSetNames[ds].name == 0) { //LF - } else { + } + else { tree->addComment("%s", kDataSetNames[ds].name); - tree->changeValue(convert8Bit(valuePtr,false,valueLen)); + tree->changeValue(convert8Bit(valuePtr, false, valueLen)); } } @@ -1232,7 +1253,8 @@ //LF if (iptcPtr > iptcEnd) { tree->comment("** Too much IPTC data, delta %d", (long)(iptcEnd - iptcPtr)); - } else { + } + else { while ((iptcPtr < iptcEnd) && (*iptcPtr == 0)) ++iptcPtr; if (iptcPtr != iptcEnd) tree->comment("** Too little IPTC data, delta %d", (long)(iptcPtr - iptcEnd)); } @@ -1240,22 +1262,22 @@ tree->popNode(); } // DumpIPTC -// ================================================================================================= + // ================================================================================================= static void -DumpImageResources ( const JpegMarkers& psirMarkers, XMP_Uns8 * dataStart, const char * label ) +DumpImageResources(const JpegMarkers& psirMarkers, XMP_Uns8 * dataStart, const char * label) { - + XMP_Uns32 i = 0, size = psirMarkers.size(); std::string combinedPSIRData; - for ( i = 0; i < size; i++ ) { - combinedPSIRData.append( (const char *) psirMarkers[i].jpegMarkerPtr, psirMarkers[i].jpegMarkerLen ); + for (i = 0; i < size; i++) { + combinedPSIRData.append((const char *)psirMarkers[i].jpegMarkerPtr, psirMarkers[i].jpegMarkerLen); } - XMP_Uns8 * psirPtr = (XMP_Uns8 *) combinedPSIRData.data(); + XMP_Uns8 * psirPtr = (XMP_Uns8 *)combinedPSIRData.data(); XMP_Uns8 * psirEnd = psirPtr + combinedPSIRData.size(); - + XMP_Uns8 * irPtr; XMP_Uns32 irLen, irOffset; //irType replaced by irTypeStr below @@ -1267,97 +1289,108 @@ XMP_Int64 lastIndexUsed = -1; while (psirPtr < psirEnd) { // calculate fileOffset and psirOrigin - size_t currentOffset = (const char *) psirPtr - combinedPSIRData.data(); + size_t currentOffset = (const char *)psirPtr - combinedPSIRData.data(); XMP_Uns32 length = 0; - for (i = 0; i < size; i++ ) { + for (i = 0; i < size; i++) { length += psirMarkers[i].jpegMarkerLen; - if ( currentOffset <= length ) + if (currentOffset <= length) break; } - if ( lastIndexUsed != (XMP_Int64)i ) { - if ( lastIndexUsed != -1 ) + if (lastIndexUsed != (XMP_Int32)i) { + if (lastIndexUsed != -1) tree->popNode(); // time to push a new node - tree->pushNode("Photoshop Image Resources %d", i + 1 ); + tree->pushNode("Photoshop Image Resources %d", i + 1); XMP_Uns32 fileOffset = psirMarkers[i].jpegMarkerPtr - dataStart; tree->addComment("from %s, offset %d (0x%X), size %d", label, fileOffset, fileOffset, psirMarkers[i].jpegMarkerLen); lastIndexUsed = i; } XMP_Uns32 fileOffset = psirMarkers[i].jpegMarkerPtr - dataStart; - /* XMP_Uns8 * psirOrigin = psirMarkers[i].jpegMarkerPtr;*/ + XMP_Uns8 * psirOrigin = psirMarkers[i].jpegMarkerPtr; - std::string irTypeStr = convert8Bit(psirPtr,false,4); //get in an endian neutral way - XMP_Uns16 irID = GetUns16BE ( psirPtr+4 ); // The image resource ID. + std::string irTypeStr = convert8Bit(psirPtr, false, 4); //get in an endian neutral way + XMP_Uns16 irID = GetUns16BE(psirPtr + 4); // The image resource ID. - const char* irName = (XMP_StringPtr)psirPtr+6; // A Pascal string. + const char* irName = (XMP_StringPtr)psirPtr + 6; // A Pascal string. irOffset = 6 + ((*irName + 2) & 0xFFFFFFFE); // Offset to the image resource data length. - irLen = GetUns32BE (psirPtr+irOffset); + irLen = GetUns32BE(psirPtr + irOffset); irPtr = psirPtr + irOffset + 4; - irOffset = fileOffset + ((psirPtr - (XMP_Uns8 *) combinedPSIRData.data()) - ( length - psirMarkers[i].jpegMarkerLen ) ); + irOffset = fileOffset + ((psirPtr - (XMP_Uns8 *)combinedPSIRData.data()) - (length - psirMarkers[i].jpegMarkerLen)); - if ( irTypeStr != "8BIM" ) { - tree->setKeyValue( fromArgs("PSIR:%s:#%u",irTypeStr.c_str(),irID),"" ); + if (irTypeStr != "8BIM") { + tree->setKeyValue(fromArgs("PSIR:%s:#%u", irTypeStr.c_str(), irID), ""); tree->comment("(non-8BIM encountered and tolerated, see bug 1454756)"); - } else if ( irID == kPSIR_IPTC ) { //**************** - tree->setKeyValue("PSIR:IPTC",""); + } + else if (irID == kPSIR_IPTC) { //**************** + tree->setKeyValue("PSIR:IPTC", ""); iptcPtr = irPtr; iptcLen = irLen; - if (iptcPtr != 0) { - XMP_Uns32 offset = fileOffset + ((iptcPtr - (XMP_Uns8 *) combinedPSIRData.data()) - ( length - psirMarkers[i].jpegMarkerLen ) ); - DumpIPTC (iptcPtr, iptcLen, offset, "PSIR #1028"); + if (iptcPtr != 0) { + XMP_Uns32 offset = fileOffset + ((iptcPtr - (XMP_Uns8 *)combinedPSIRData.data()) - (length - psirMarkers[i].jpegMarkerLen)); + DumpIPTC(iptcPtr, iptcLen, offset, "PSIR #1028"); } - } else if (irID == kPSIR_XMP) { //**************** - tree->setKeyValue("PSIR:XMP",""); + } + else if (irID == kPSIR_XMP) { //**************** + tree->setKeyValue("PSIR:XMP", ""); xmpPtr = irPtr; xmpLen = irLen; if (xmpPtr != 0) { - XMP_Uns32 offset = fileOffset + ((xmpPtr - (XMP_Uns8 *) combinedPSIRData.data()) - ( length - psirMarkers[i].jpegMarkerLen ) ); - DumpXMP (xmpPtr, xmpLen, offset, "PSIR #1060"); + XMP_Uns32 offset = fileOffset + ((xmpPtr - (XMP_Uns8 *)combinedPSIRData.data()) - (length - psirMarkers[i].jpegMarkerLen)); + DumpXMP(xmpPtr, xmpLen, offset, "PSIR #1060"); } - } else if (irID == kPSIR_Exif_1) { //**************** - tree->setKeyValue("PSIR:Exif-1",""); + } + else if (irID == kPSIR_Exif_1) { //**************** + tree->setKeyValue("PSIR:Exif-1", ""); exif1Ptr = irPtr; exif1Len = irLen; - XMP_Uns32 offset = fileOffset + ((exif1Ptr - (XMP_Uns8 *) combinedPSIRData.data()) - ( length - psirMarkers[i].jpegMarkerLen ) ); - DumpTIFF (exif1Ptr, exif1Len, offset, "PSIR #1058 (Exif 1)", "PSIR:Exif-1"); - } else if (irID == kPSIR_Exif_3) { //**************** - tree->setKeyValue("PSIR:Exif-3",""); + XMP_Uns32 offset = fileOffset + ((exif1Ptr - (XMP_Uns8 *)combinedPSIRData.data()) - (length - psirMarkers[i].jpegMarkerLen)); + DumpTIFF(exif1Ptr, exif1Len, offset, "PSIR #1058 (Exif 1)", "PSIR:Exif-1"); + } + else if (irID == kPSIR_Exif_3) { //**************** + tree->setKeyValue("PSIR:Exif-3", ""); exif3Ptr = irPtr; exif3Len = irLen; - XMP_Uns32 offset = fileOffset + ((exif3Ptr - (XMP_Uns8 *) combinedPSIRData.data()) - ( length - psirMarkers[i].jpegMarkerLen ) ); - if (exif3Ptr != 0) DumpTIFF (exif3Ptr, exif3Len, offset, "PSIR #1059 (Exif 3)", "PSIR:Exif-3"); - } else if (irID == kPSIR_IPTC_Digest) { + XMP_Uns32 offset = fileOffset + ((exif3Ptr - (XMP_Uns8 *)combinedPSIRData.data()) - (length - psirMarkers[i].jpegMarkerLen)); + if (exif3Ptr != 0) DumpTIFF(exif3Ptr, exif3Len, offset, "PSIR #1059 (Exif 3)", "PSIR:Exif-3"); + } + else if (irID == kPSIR_IPTC_Digest) { tree->setKeyValue("PSIR:IPTC digest", fromArgs("%.8X-%.8X-%.8X-%.8X", - GetUns32BE(irPtr), - GetUns32BE(irPtr+4), - GetUns32BE(irPtr+8), - GetUns32BE(irPtr+12) ) - ); - } else if (irID == kPSIR_CopyrightFlag) { + GetUns32BE(irPtr), + GetUns32BE(irPtr + 4), + GetUns32BE(irPtr + 8), + GetUns32BE(irPtr + 12)) + ); + } + else if (irID == kPSIR_CopyrightFlag) { bool copyrighted = (*irPtr != 0); - tree->setKeyValue("PSIR:copyrighted",(copyrighted ? "yes" : "no")); - } else if (irID == kPSIR_CopyrightURL) { - tree->setKeyValue("PSIR:copyright URL",convert8Bit(irPtr,true,irLen)); - } else if (irID == kPSIR_OldCaption) { - tree->setKeyValue("PSIR:old caption",convert8Bit(irPtr,true,irLen)); - } else if (irID == kPSIR_PrintCaption) { + tree->setKeyValue("PSIR:copyrighted", (copyrighted ? "yes" : "no")); + } + else if (irID == kPSIR_CopyrightURL) { + tree->setKeyValue("PSIR:copyright URL", convert8Bit(irPtr, true, irLen)); + } + else if (irID == kPSIR_OldCaption) { + tree->setKeyValue("PSIR:old caption", convert8Bit(irPtr, true, irLen)); + } + else if (irID == kPSIR_PrintCaption) { tree->comment("** obsolete print caption **"); - } else { + } + else { tree->setKeyValue( - fromArgs("PSIR:%s:#%d",irTypeStr.c_str(),irID), + fromArgs("PSIR:%s:#%d", irTypeStr.c_str(), irID), "" - ); + ); } - if ( irOffset + irLen > (psirMarkers[i].jpegMarkerPtr - dataStart) + psirMarkers[i].jpegMarkerLen ) { + if (irOffset + irLen > (psirMarkers[i].jpegMarkerPtr - dataStart) + psirMarkers[i].jpegMarkerLen) { //merged from two markers - tree->addComment("offset %d (0x%X), size %d - split in multiple markers", irOffset, irOffset, irLen); - } else { - tree->addComment("offset %d (0x%X), size %d", irOffset, irOffset, irLen); + tree->addComment("offset %d (0x%X), size %d - split in multiple markers", irOffset, irOffset, irLen); + } + else { + tree->addComment("offset %d (0x%X), size %d", irOffset, irOffset, irLen); } - if (*irName != 0) tree->addComment("\"%.*s\"", (int)(*irName), (irName+1)); + if (*irName != 0) tree->addComment("\"%.*s\"", (int)(*irName), (irName + 1)); psirPtr = irPtr + ((irLen + 1) & 0xFFFFFFFE); // Round the length to be even. } //while-loop @@ -1369,10 +1402,10 @@ tree->popNode(); } // DumpImageResources -// ================================================================================================= + // ================================================================================================= static void -DumpImageResources (XMP_Uns8 * psirOrigin, XMP_Uns32 psirLen, XMP_Uns32 fileOffset, const char * label) +DumpImageResources(XMP_Uns8 * psirOrigin, XMP_Uns32 psirLen, XMP_Uns32 fileOffset, const char * label) { tree->pushNode("Photoshop Image Resources"); tree->addComment("from %s, offset %d (0x%X), size %d", @@ -1390,64 +1423,74 @@ XMP_Uns32 iptcLen, xmpLen, exif1Len, exif3Len; while (psirPtr < psirEnd) { - std::string irTypeStr = convert8Bit(psirPtr,false,4); //get in an endian neutral way - XMP_Uns16 irID = GetUns16BE ( psirPtr+4 ); // The image resource ID. + std::string irTypeStr = convert8Bit(psirPtr, false, 4); //get in an endian neutral way + XMP_Uns16 irID = GetUns16BE(psirPtr + 4); // The image resource ID. - const char* irName = (XMP_StringPtr)psirPtr+6; // A Pascal string. + const char* irName = (XMP_StringPtr)psirPtr + 6; // A Pascal string. irOffset = 6 + ((*irName + 2) & 0xFFFFFFFE); // Offset to the image resource data length. - irLen = GetUns32BE (psirPtr+irOffset); + irLen = GetUns32BE(psirPtr + irOffset); irPtr = psirPtr + irOffset + 4; irOffset = fileOffset + (psirPtr - psirOrigin); - if ( irTypeStr != "8BIM" ) { - tree->setKeyValue( fromArgs("PSIR:%s:#%u",irTypeStr.c_str(),irID),"" ); + if (irTypeStr != "8BIM") { + tree->setKeyValue(fromArgs("PSIR:%s:#%u", irTypeStr.c_str(), irID), ""); tree->comment("(non-8BIM encountered and tolerated, see bug 1454756)"); - } else if ( irID == kPSIR_IPTC ) { //**************** - tree->setKeyValue("PSIR:IPTC",""); + } + else if (irID == kPSIR_IPTC) { //**************** + tree->setKeyValue("PSIR:IPTC", ""); iptcPtr = irPtr; iptcLen = irLen; - if (iptcPtr != 0) DumpIPTC (iptcPtr, iptcLen, (fileOffset + (iptcPtr - psirOrigin)), "PSIR #1028"); - } else if (irID == kPSIR_XMP) { //**************** - tree->setKeyValue("PSIR:XMP",""); + if (iptcPtr != 0) DumpIPTC(iptcPtr, iptcLen, (fileOffset + (iptcPtr - psirOrigin)), "PSIR #1028"); + } + else if (irID == kPSIR_XMP) { //**************** + tree->setKeyValue("PSIR:XMP", ""); xmpPtr = irPtr; xmpLen = irLen; - if (xmpPtr != 0) DumpXMP (xmpPtr, xmpLen, (fileOffset + (xmpPtr - psirOrigin)), "PSIR #1060"); - } else if (irID == kPSIR_Exif_1) { //**************** - tree->setKeyValue("PSIR:Exif-1",""); + if (xmpPtr != 0) DumpXMP(xmpPtr, xmpLen, (fileOffset + (xmpPtr - psirOrigin)), "PSIR #1060"); + } + else if (irID == kPSIR_Exif_1) { //**************** + tree->setKeyValue("PSIR:Exif-1", ""); exif1Ptr = irPtr; exif1Len = irLen; - DumpTIFF (exif1Ptr, exif1Len, (fileOffset + (exif1Ptr - psirOrigin)), "PSIR #1058 (Exif 1)", "PSIR:Exif-1"); - } else if (irID == kPSIR_Exif_3) { //**************** - tree->setKeyValue("PSIR:Exif-3",""); + DumpTIFF(exif1Ptr, exif1Len, (fileOffset + (exif1Ptr - psirOrigin)), "PSIR #1058 (Exif 1)", "PSIR:Exif-1"); + } + else if (irID == kPSIR_Exif_3) { //**************** + tree->setKeyValue("PSIR:Exif-3", ""); exif3Ptr = irPtr; exif3Len = irLen; - if (exif3Ptr != 0) DumpTIFF (exif3Ptr, exif3Len, (fileOffset + (exif3Ptr - psirOrigin)), "PSIR #1059 (Exif 3)", "PSIR:Exif-3"); - } else if (irID == kPSIR_IPTC_Digest) { + if (exif3Ptr != 0) DumpTIFF(exif3Ptr, exif3Len, (fileOffset + (exif3Ptr - psirOrigin)), "PSIR #1059 (Exif 3)", "PSIR:Exif-3"); + } + else if (irID == kPSIR_IPTC_Digest) { tree->setKeyValue("PSIR:IPTC digest", fromArgs("%.8X-%.8X-%.8X-%.8X", - GetUns32BE(irPtr), - GetUns32BE(irPtr+4), - GetUns32BE(irPtr+8), - GetUns32BE(irPtr+12) ) - ); - } else if (irID == kPSIR_CopyrightFlag) { + GetUns32BE(irPtr), + GetUns32BE(irPtr + 4), + GetUns32BE(irPtr + 8), + GetUns32BE(irPtr + 12)) + ); + } + else if (irID == kPSIR_CopyrightFlag) { bool copyrighted = (*irPtr != 0); - tree->setKeyValue("PSIR:copyrighted",(copyrighted ? "yes" : "no")); - } else if (irID == kPSIR_CopyrightURL) { - tree->setKeyValue("PSIR:copyright URL",convert8Bit(irPtr,true,irLen)); - } else if (irID == kPSIR_OldCaption) { - tree->setKeyValue("PSIR:old caption",convert8Bit(irPtr,true,irLen)); - } else if (irID == kPSIR_PrintCaption) { + tree->setKeyValue("PSIR:copyrighted", (copyrighted ? "yes" : "no")); + } + else if (irID == kPSIR_CopyrightURL) { + tree->setKeyValue("PSIR:copyright URL", convert8Bit(irPtr, true, irLen)); + } + else if (irID == kPSIR_OldCaption) { + tree->setKeyValue("PSIR:old caption", convert8Bit(irPtr, true, irLen)); + } + else if (irID == kPSIR_PrintCaption) { tree->comment("** obsolete print caption **"); - } else { + } + else { tree->setKeyValue( - fromArgs("PSIR:%s:#%d",irTypeStr.c_str(),irID), + fromArgs("PSIR:%s:#%d", irTypeStr.c_str(), irID), "" - ); + ); } - tree->addComment("offset %d (0x%X), size %d", irOffset, irOffset, irLen); - if (*irName != 0) tree->addComment("\"%.*s\"", (int)(*irName), (irName+1)); + tree->addComment("offset %d (0x%X), size %d", irOffset, irOffset, irLen); + if (*irName != 0) tree->addComment("\"%.*s\"", (int)(*irName), (irName + 1)); psirPtr = irPtr + ((irLen + 1) & 0xFFFFFFFE); // Round the length to be even. } //while-loop @@ -1460,11 +1503,11 @@ tree->popNode(); } // DumpImageResources -// ================================================================================================= + // ================================================================================================= static void -DumpOneIFD (int ifdIndex, XMP_Uns8 * ifdPtr, XMP_Uns8 * endPtr, - XMP_Uns8 * tiffContent, XMP_Uns32 fileOffset, const char * label, std::string path) +DumpOneIFD(int ifdIndex, XMP_Uns8 * ifdPtr, XMP_Uns8 * endPtr, + XMP_Uns8 * tiffContent, XMP_Uns32 fileOffset, const char * label, std::string path) { XMP_Uns8 * exifPtr = 0; XMP_Uns8 * gpsPtr = 0; @@ -1478,34 +1521,35 @@ XMP_Uns32 xmpLen = 0; XMP_Uns32 ifdOffset = ifdPtr - tiffContent; - XMP_Uns16 fieldCount = TIFF_GetUns16 (ifdPtr); + XMP_Uns16 fieldCount = TIFF_GetUns16(ifdPtr); XMP_Uns32 ifdLen = 2 + (12 * fieldCount) + 4; - XMP_Uns32 nextIFD = TIFF_GetUns32 (ifdPtr+ifdLen-4); + XMP_Uns32 nextIFD = TIFF_GetUns32(ifdPtr + ifdLen - 4); - tree->pushNode("TIFF IFD #%d from %s",ifdIndex,label); + tree->pushNode("TIFF IFD #%d from %s", ifdIndex, label); tree->addComment("offset %d (0x%X), tag count %d", (ifdOffset + fileOffset), (ifdOffset + fileOffset), fieldCount); if (nextIFD == 0) { tree->comment("end of IFD chain"); - } else { + } + else { tree->comment("next IFD offset %d (0x%X)", (nextIFD + fileOffset), (nextIFD + fileOffset)); } XMP_Uns16 prevTag = 0; - XMP_Uns8 * fieldPtr = tiffContent+ifdOffset+2; - - if (!path.empty()) + XMP_Uns8 * fieldPtr = tiffContent + ifdOffset + 2; + + if (!path.empty()) path.append("/"); - - path.append(fromArgs("IFD%d", ifdIndex)); + + path.append(fromArgs("IFD%d", ifdIndex)); for (int i = 0; i < fieldCount; ++i, fieldPtr += 12) { - XMP_Uns16 fieldTag = TIFF_GetUns16 (fieldPtr); - XMP_Uns16 fieldType = TIFF_GetUns16 (fieldPtr+2); - XMP_Uns32 valueCount = TIFF_GetUns32 (fieldPtr+4); - XMP_Uns32 valueOffset = TIFF_GetUns32 (fieldPtr+8); + XMP_Uns16 fieldTag = TIFF_GetUns16(fieldPtr); + XMP_Uns16 fieldType = TIFF_GetUns16(fieldPtr + 2); + XMP_Uns32 valueCount = TIFF_GetUns32(fieldPtr + 4); + XMP_Uns32 valueOffset = TIFF_GetUns32(fieldPtr + 8); XMP_Uns8 * valuePtr = ifdPtr - ifdOffset + valueOffset; XMP_Uns32 valueLen = 0; @@ -1513,11 +1557,12 @@ if (valueLen <= 4) valuePtr = fieldPtr + 8; //===================== adding key here - tree->setKeyValue( fromArgs("%s/TIFF:%d",path.c_str(), fieldTag) ); + tree->setKeyValue(fromArgs("%s/TIFF:%d", path.c_str(), fieldTag)); - if ((fieldType < 1) || (fieldType >= kTIFF_TypeEnd)) { + if ((fieldType < 1) || (fieldType >= kTIFF_TypeEnd)) { tree->addComment("type %d", fieldType); - } else { + } + else { tree->addComment("%s", sTIFF_TypeNames[fieldType]); } @@ -1525,42 +1570,50 @@ if (valueLen > 4) { tree->addComment("value offset %d (0x%X)", (valueOffset + fileOffset), (valueOffset + fileOffset)); - } else { - XMP_Uns32 rawValue = GetUns32BE (fieldPtr+8); + } + else { + XMP_Uns32 rawValue = GetUns32BE(fieldPtr + 8); tree->addComment("value in IFD (0x%.8X)", rawValue); } if (fieldTag == kTIFF_Exif) { tree->addComment("Exif IFD offset"); - exifPtr = tiffContent + TIFF_GetUns32 (valuePtr); // Value is Exif IFD offset. - } else if (fieldTag == kTIFF_GPS) { + exifPtr = tiffContent + TIFF_GetUns32(valuePtr); // Value is Exif IFD offset. + } + else if (fieldTag == kTIFF_GPS) { tree->addComment("GPS IFD offset"); - gpsPtr = tiffContent + TIFF_GetUns32 (valuePtr); // Value is GPS IFD offset. - } else if (fieldTag == kTIFF_Interop) { + gpsPtr = tiffContent + TIFF_GetUns32(valuePtr); // Value is GPS IFD offset. + } + else if (fieldTag == kTIFF_Interop) { tree->addComment("Interoperability IFD offset"); - interopPtr = tiffContent + TIFF_GetUns32 (valuePtr); // Value is Interoperability IFD offset. - } else if (fieldTag == kTIFF_MakerNote) { // Decide if the Maker Note might be formatted as an IFD. + interopPtr = tiffContent + TIFF_GetUns32(valuePtr); // Value is Interoperability IFD offset. + } + else if (fieldTag == kTIFF_MakerNote) { // Decide if the Maker Note might be formatted as an IFD. tree->addComment("Maker Note"); XMP_Uns32 itemCount = (valueLen - 6) / 12; - if ((valueLen >= 18) && (valueLen == (6 + itemCount*12)) && - (itemCount == TIFF_GetUns16 (valuePtr)) && - (TIFF_GetUns32 (valuePtr+2+(12*itemCount)) == 0)) { - makerNotePtr = valuePtr; + if ((valueLen >= 18) && (valueLen == (6 + itemCount * 12)) && + (itemCount == TIFF_GetUns16(valuePtr)) && + (TIFF_GetUns32(valuePtr + 2 + (12 * itemCount)) == 0)) { + makerNotePtr = valuePtr; } - } else if (fieldTag == kTIFF_PSIR) { + } + else if (fieldTag == kTIFF_PSIR) { tree->addComment("PSIR"); psirPtr = valuePtr; psirLen = valueLen; - } else if (fieldTag == kTIFF_IPTC) { + } + else if (fieldTag == kTIFF_IPTC) { tree->addComment("IPTC"); iptcPtr = valuePtr; iptcLen = valueLen; - } else if (fieldTag == kTIFF_XMP) { + } + else if (fieldTag == kTIFF_XMP) { tree->addComment("XMP"); if (fieldType == kTIFF_ASCII) fieldType = kTIFF_Uns8; // Avoid displaying the raw packet for mis-typed XMP. xmpPtr = valuePtr; xmpLen = valueLen; - } else { + } + else { for (int j = 0; sTIFF_TagNames[j].tag != 0; ++j) { if (sTIFF_TagNames[j].tag == fieldTag) { tree->addComment("%s", sTIFF_TagNames[j].name); @@ -1575,149 +1628,154 @@ XMP_Uns32 denom; std::string tempStr; char cs[31]; - + switch (fieldType) { - case kTIFF_Uns8 : - if (valueCount == 1) { - value8 = *valuePtr; - tree->addComment("hex value = 0x%.2X", value8); - tree->changeValue("%u",value8); - } - break; + case kTIFF_Uns8: + if (valueCount == 1) { + value8 = *valuePtr; + tree->addComment("hex value = 0x%.2X", value8); + tree->changeValue("%u", value8); + } + break; - case kTIFF_ASCII : - tree->changeValue(convert8Bit(valuePtr,false /* internal NULs OK*/,valueLen)); - break; + case kTIFF_ASCII: + tree->changeValue(convert8Bit(valuePtr, false /* internal NULs OK*/, valueLen)); + break; - case kTIFF_Uns16 : - if (valueCount == 1) { - value16 = TIFF_GetUns16 (valuePtr); - tree->addComment("hex value = 0x%.4X", value16); - tree->changeValue("%u",value16); - } - break; + case kTIFF_Uns16: + if (valueCount == 1) { + value16 = TIFF_GetUns16(valuePtr); + tree->addComment("hex value = 0x%.4X", value16); + tree->changeValue("%u", value16); + } + break; - case kTIFF_Uns32 : - if (valueCount == 1) { - value32 = TIFF_GetUns32 (valuePtr); - tree->addComment("hex value = 0x%.8X", value32); - tree->changeValue( "%u" , value32); - } - break; + case kTIFF_Uns32: + if (valueCount == 1) { + value32 = TIFF_GetUns32(valuePtr); + tree->addComment("hex value = 0x%.8X", value32); + tree->changeValue("%u", value32); + } + break; - case kTIFF_URational : - for( unsigned int j = 0; j < valueCount ; j++) { - value32 = TIFF_GetUns32 (valuePtr+(j*8)); - denom = TIFF_GetUns32 (valuePtr+(j*8)+4); - snprintf(cs,30,"%u",value32); - tempStr += cs; - tempStr += "/"; - snprintf(cs,30,"%u",denom); - tempStr += cs; - if(j < valueCount-1) - tempStr += ";"; - } - if(tempStr.length() > 0) - tree->changeValue( tempStr ); - break; + case kTIFF_URational: + for (unsigned int j = 0; j < valueCount; j++) { + value32 = TIFF_GetUns32(valuePtr + (j * 8)); + denom = TIFF_GetUns32(valuePtr + (j * 8) + 4); + snprintf(cs, 30, "%u", value32); + tempStr += cs; + tempStr += "/"; + snprintf(cs, 30, "%u", denom); + tempStr += cs; + if (j < valueCount - 1) + tempStr += ";"; + } + if (tempStr.length() > 0) + tree->changeValue(tempStr); + break; - case kTIFF_Int8 : - if (valueCount == 1) { - value8 = *valuePtr; - //fno: show the hex value unsigned (memory representation) and the decimal signed - tree->addComment("hex value 0x%.2X", value8); - tree->changeValue( "%d" , *((XMP_Int8*)&value8)); - } - break; + case kTIFF_Int8: + if (valueCount == 1) { + value8 = *valuePtr; + //fno: show the hex value unsigned (memory representation) and the decimal signed + tree->addComment("hex value 0x%.2X", value8); + tree->changeValue("%d", *((XMP_Int8*)&value8)); + } + break; - case kTIFF_Undef8 : - if ( valueCount == 1 ) { - value8 = *valuePtr; - tree->changeValue( "0x%.2X", value8 ); - } else if ( fieldTag == 36864 ) { // ExifVersion - tree->changeValue( "%.*s", valueCount, valuePtr ); - } else if ( fieldTag == 37510 ) { // UserComment - XMP_Uns8 * encPtr = valuePtr; - valuePtr += 8; - valueCount -= 8; - sprintf(cs,"encoding = %.8s", encPtr ); - tempStr += cs; - if ( ! CheckBytes ( encPtr, "UNICODE\0", 8 ) ) { - tree->changeValue( convert8Bit ( valuePtr, false, valueCount ) ); - } else { - bool doBE = beTIFF; - if ( CheckBytes ( valuePtr, "\xFE\xFF", 2 ) ) { - doBE = true; - valuePtr += 2; - valueCount -= 2; - tempStr += ", BE BOM"; - } - if ( CheckBytes ( valuePtr, "\xFF\xFE", 2 ) ) { - doBE = false; - valuePtr += 2; - valueCount -= 2; - tempStr += ", LE BOM"; - } - if ( doBE ) { - tree->changeValue( convert16Bit( true, (XMP_Uns8*) valuePtr, false, valueCount ) ); - //PrintOnlyASCII_16BE ( (XMP_Uns16*)valuePtr, valueCount, ", value =", false /* ! stopOnNUL */ ); - } else { - tree->changeValue( convert16Bit( false, (XMP_Uns8*) valuePtr, false, valueCount ) ); - //PrintOnlyASCII_16LE ( (XMP_Uns16*)valuePtr, valueCount, ", value =", false /* ! stopOnNUL */ ); - } - } + case kTIFF_Undef8: + if (valueCount == 1) { + value8 = *valuePtr; + tree->changeValue("0x%.2X", value8); + } + else if (fieldTag == 36864) { // ExifVersion + tree->changeValue("%.*s", valueCount, valuePtr); + } + else if (fieldTag == 37510) { // UserComment + XMP_Uns8 * encPtr = valuePtr; + valuePtr += 8; + valueCount -= 8; + sprintf(cs, "encoding = %.8s", encPtr); + tempStr += cs; + if (!CheckBytes(encPtr, "UNICODE\0", 8)) { + tree->changeValue(convert8Bit(valuePtr, false, valueCount)); } - - if(tempStr.length() > 0) - tree->addComment( tempStr ); - break; - - case kTIFF_Int16 : - if (valueCount == 1) { - value16 = TIFF_GetUns16 (valuePtr); - tree->changeValue("%d (0x%.4X)", *((XMP_Int16*)&value16), value16); + else { + bool doBE = beTIFF; + if (CheckBytes(valuePtr, "\xFE\xFF", 2)) { + doBE = true; + valuePtr += 2; + valueCount -= 2; + tempStr += ", BE BOM"; + } + if (CheckBytes(valuePtr, "\xFF\xFE", 2)) { + doBE = false; + valuePtr += 2; + valueCount -= 2; + tempStr += ", LE BOM"; + } + if (doBE) { + tree->changeValue(convert16Bit(true, (XMP_Uns8*)valuePtr, false, valueCount)); + //PrintOnlyASCII_16BE ( (XMP_Uns16*)valuePtr, valueCount, ", value =", false /* ! stopOnNUL */ ); + } + else { + tree->changeValue(convert16Bit(false, (XMP_Uns8*)valuePtr, false, valueCount)); + //PrintOnlyASCII_16LE ( (XMP_Uns16*)valuePtr, valueCount, ", value =", false /* ! stopOnNUL */ ); + } } - break; + } - case kTIFF_Int32 : - if (valueCount == 1) { - value32 = TIFF_GetUns32 (valuePtr); - tree->changeValue("%d (0x%.8X)", *((XMP_Int32*)&value32), value32); - } - break; + if (tempStr.length() > 0) + tree->addComment(tempStr); + break; - case kTIFF_SRational : - if (valueCount == 1) { - value32 = TIFF_GetUns32 (valuePtr); - denom = TIFF_GetUns32 (valuePtr+4); - tree->changeValue("%d/%d", *((XMP_Int32*)&value32), *((XMP_Int32*)&denom)); - } - break; + case kTIFF_Int16: + if (valueCount == 1) { + value16 = TIFF_GetUns16(valuePtr); + tree->changeValue("%d (0x%.4X)", *((XMP_Int16*)&value16), value16); + } + break; - case kTIFF_Float : - break; + case kTIFF_Int32: + if (valueCount == 1) { + value32 = TIFF_GetUns32(valuePtr); + tree->changeValue("%d (0x%.8X)", *((XMP_Int32*)&value32), value32); + } + break; - case kTIFF_Double : - break; + case kTIFF_SRational: + if (valueCount == 1) { + value32 = TIFF_GetUns32(valuePtr); + denom = TIFF_GetUns32(valuePtr + 4); + tree->changeValue("%d/%d", *((XMP_Int32*)&value32), *((XMP_Int32*)&denom)); + } + break; - case kTIFF_IFD: - if ( valueCount == 1 ) { - value32 = TIFF_GetUns32 ( valuePtr ); - tree->addComment ( "hex value = 0x%.8X", value32 ); - tree->changeValue ( "%u", value32 ); - } - break; + case kTIFF_Float: + break; - default : - tree->addComment("** unknown type **"); - break; + case kTIFF_Double: + break; + + case kTIFF_IFD: + if (valueCount == 1) { + value32 = TIFF_GetUns32(valuePtr); + tree->addComment("hex value = 0x%.8X", value32); + tree->changeValue("%u", value32); + } + break; + + default: + tree->addComment("** unknown type **"); + break; } if (fieldTag == prevTag) { tree->addComment("** Repeated tag **"); - } else if (fieldTag < prevTag) { + } + else if (fieldTag < prevTag) { tree->addComment("** Out of order tag **"); } @@ -1726,46 +1784,46 @@ } if (exifPtr != 0) { - DumpIFDChain (exifPtr, endPtr, tiffContent, - (fileOffset + (exifPtr - tiffContent)), "TIFF tag #34665 (Exif IFD)", path+"/TIFF:34665"); + DumpIFDChain(exifPtr, endPtr, tiffContent, + (fileOffset + (exifPtr - tiffContent)), "TIFF tag #34665 (Exif IFD)", path + "/TIFF:34665"); } if (gpsPtr != 0) { - DumpIFDChain (gpsPtr, endPtr, tiffContent, - (fileOffset + (gpsPtr - tiffContent)), "TIFF tag #34853 (GPS Info IFD)", path+"/TIFF:34853"); + DumpIFDChain(gpsPtr, endPtr, tiffContent, + (fileOffset + (gpsPtr - tiffContent)), "TIFF tag #34853 (GPS Info IFD)", path + "/TIFF:34853"); } if (interopPtr != 0) { - DumpIFDChain (interopPtr, endPtr, tiffContent, - (fileOffset + (interopPtr - tiffContent)), "TIFF tag #40965 (Interoperability IFD)", path+"/TIFF:40965"); + DumpIFDChain(interopPtr, endPtr, tiffContent, + (fileOffset + (interopPtr - tiffContent)), "TIFF tag #40965 (Interoperability IFD)", path + "/TIFF:40965"); } if (makerNotePtr != 0) { - DumpIFDChain (makerNotePtr, endPtr, tiffContent, - (fileOffset + (makerNotePtr - tiffContent)), "TIFF tag #37500 (Maker Note)", path+"/TIFF:37500"); + DumpIFDChain(makerNotePtr, endPtr, tiffContent, + (fileOffset + (makerNotePtr - tiffContent)), "TIFF tag #37500 (Maker Note)", path + "/TIFF:37500"); } if (iptcPtr != 0) { - DumpIPTC (iptcPtr, iptcLen, (fileOffset + (iptcPtr - tiffContent)), "TIFF tag #33723"); + DumpIPTC(iptcPtr, iptcLen, (fileOffset + (iptcPtr - tiffContent)), "TIFF tag #33723"); } if (psirPtr != 0) { - DumpImageResources (psirPtr, psirLen, (fileOffset + (psirPtr - tiffContent)), "TIFF tag #34377"); + DumpImageResources(psirPtr, psirLen, (fileOffset + (psirPtr - tiffContent)), "TIFF tag #34377"); } if (xmpPtr != 0) { - DumpXMP (xmpPtr, xmpLen, (fileOffset + (xmpPtr - tiffContent)), "TIFF tag #700"); + DumpXMP(xmpPtr, xmpLen, (fileOffset + (xmpPtr - tiffContent)), "TIFF tag #700"); } tree->popNode(); } // DumpOneIFD -// ================================================================================================= + // ================================================================================================= static void -DumpIFDChain (XMP_Uns8 * startPtr, XMP_Uns8 * endPtr, - XMP_Uns8 * tiffContent, XMP_Uns32 fileOrigin, const char * label, std::string path, bool isHeaderAbsent ) +DumpIFDChain(XMP_Uns8 * startPtr, XMP_Uns8 * endPtr, + XMP_Uns8 * tiffContent, XMP_Uns32 fileOrigin, const char * label, std::string path, bool isHeaderAbsent) { XMP_Uns8 * ifdPtr = startPtr; XMP_Uns32 ifdOffset = startPtr - tiffContent; @@ -1781,19 +1839,19 @@ return; } - XMP_Uns16 fieldCount = TIFF_GetUns16 (ifdPtr); - DumpOneIFD (ifdIndex, ifdPtr, endPtr, tiffContent, fileOrigin, label, path); - ifdOffset = TIFF_GetUns32 (ifdPtr+2+(12*fieldCount)); + XMP_Uns16 fieldCount = TIFF_GetUns16(ifdPtr); + DumpOneIFD(ifdIndex, ifdPtr, endPtr, tiffContent, fileOrigin, label, path); + ifdOffset = TIFF_GetUns32(ifdPtr + 2 + (12 * fieldCount)); ifdPtr = tiffContent + ifdOffset; } } // DumpIFDChain -// ================================================================================================= + // ================================================================================================= static void -DumpTIFF (XMP_Uns8 * tiffContent, XMP_Uns32 tiffLen, XMP_Uns32 fileOffset, const char * label, std::string path, bool isHeaderAbsent) +DumpTIFF(XMP_Uns8 * tiffContent, XMP_Uns32 tiffLen, XMP_Uns32 fileOffset, const char * label, std::string path, bool isHeaderAbsent) { tree->pushNode("TIFF content from %s", label); // ! TIFF can be nested because of the Photoshop 6 weiredness. Save and restore the procs. @@ -1847,46 +1905,46 @@ } // DumpTIFF -// ================================================================================================= + // ================================================================================================= -static void DumpTIFF ( const JpegMarkers& exifMarkers, XMP_Uns8 * dataStart, const char * label, std::string path ) +static void DumpTIFF(const JpegMarkers& exifMarkers, XMP_Uns8 * dataStart, const char * label, std::string path) { XMP_Uns32 i = 0, size = exifMarkers.size(); std::string combinedExifData; - tree->pushNode( "Combined EXIF Markers from %s", path.c_str() ); - for ( i = 0; i < size; i++ ) { - tree->pushNode( "EXIF Marker %d", i + 1 ); + tree->pushNode("Combined EXIF Markers from %s", path.c_str()); + for (i = 0; i < size; i++) { + tree->pushNode("EXIF Marker %d", i + 1); tree->addComment("offset %d (0x%X), size %d", exifMarkers[i].jpegMarkerPtr - dataStart, - exifMarkers[i].jpegMarkerPtr - dataStart, exifMarkers[i].jpegMarkerLen ); - combinedExifData.append( (const char *) exifMarkers[i].jpegMarkerPtr, exifMarkers[i].jpegMarkerLen ); + exifMarkers[i].jpegMarkerPtr - dataStart, exifMarkers[i].jpegMarkerLen); + combinedExifData.append((const char *)exifMarkers[i].jpegMarkerPtr, exifMarkers[i].jpegMarkerLen); tree->popNode(); } - DumpTIFF( (XMP_Uns8 *) combinedExifData.data(), combinedExifData.length(), exifMarkers[0].jpegMarkerPtr - dataStart, label, path ); + DumpTIFF((XMP_Uns8 *)combinedExifData.data(), combinedExifData.length(), exifMarkers[0].jpegMarkerPtr - dataStart, label, path); tree->popNode(); } // DumpTIFF -// ================================================================================================= + // ================================================================================================= static void -DumpPhotoshop (XMP_Uns8 * psdContent, XMP_Uns32 psdLen) +DumpPhotoshop(XMP_Uns8 * psdContent, XMP_Uns32 psdLen) { - psdLen=psdLen; // Avoid unused parameter warning. + psdLen = psdLen; // Avoid unused parameter warning. - XMP_Uns32 psirOffset = 26 + 4 + GetUns32BE (psdContent+26); + XMP_Uns32 psirOffset = 26 + 4 + GetUns32BE(psdContent + 26); XMP_Uns8 * psirSect = psdContent + psirOffset; - XMP_Uns8 * psirPtr = psirSect + 4; - XMP_Uns32 psirLen = GetUns32BE (psirSect); + XMP_Uns8 * psirPtr = psirSect + 4; + XMP_Uns32 psirLen = GetUns32BE(psirSect); - DumpImageResources (psirPtr, psirLen, (psirPtr - psdContent), "Photoshop file"); + DumpImageResources(psirPtr, psirLen, (psirPtr - psdContent), "Photoshop file"); } // DumpPhotoshop -// ================================================================================================= + // ================================================================================================= static void -DumpJPEG (XMP_Uns8 * jpegContent, XMP_Uns32 jpegLen) +DumpJPEG(XMP_Uns8 * jpegContent, XMP_Uns32 jpegLen) { XMP_Uns8 * endPtr = jpegContent + jpegLen; XMP_Uns8 * segPtr = jpegContent; @@ -1899,7 +1957,7 @@ while (segPtr < endPtr) { // ---------------------------------------------------------------- - XMP_Uns16 segMark = GetUns16BE (segPtr); + XMP_Uns16 segMark = GetUns16BE(segPtr); if (segMark == 0xFFFF) { segPtr += 1; // Skip leading 0xFF pad byte. continue; @@ -1908,7 +1966,7 @@ XMP_Uns16 minorKind = segMark & 0x000F; segOffset = segPtr - jpegContent; - tree->pushNode("JPEG:%.4X",segMark); + tree->pushNode("JPEG:%.4X", segMark); tree->addComment("offset %d (0x%X)", segOffset, segOffset); if (((segMark >> 8) != 0xFF) || (segMark == 0xFF00)) { @@ -1924,71 +1982,79 @@ segPtr += 2; // A standalone marker. tree->popNode(); continue; - } else if ((0xFFD0 <= segMark) && (segMark <= 0xFFD7)) { + } + else if ((0xFFD0 <= segMark) && (segMark <= 0xFFD7)) { tree->addComment(fromArgs("RST%d ** unexpected **", minorKind)); segPtr += 2; // A standalone marker. tree->popNode(); continue; - } else if (segMark == 0xFFD8) { + } + else if (segMark == 0xFFD8) { tree->addComment("SOI"); segPtr += 2; // A standalone marker. tree->popNode(); continue; - } else if (segMark == 0xFFD9) { + } + else if (segMark == 0xFFD9) { tree->addComment("EOI"); segPtr += 2; // A standalone marker. tree->popNode(); break; // Exit on EOI. } - XMP_Uns16 segLen = GetUns16BE (segPtr+2); + XMP_Uns16 segLen = GetUns16BE(segPtr + 2); // figure out Exif vs PSIR vs XMP if ((0xFFE0 <= segMark) && (segMark <= 0xFFEF)) { - const char* segName = (const char *)(segPtr+4); + const char* segName = (const char *)(segPtr + 4); tree->addComment(fromArgs("size %d, APP%d, \"%s\"", segLen, minorKind, segName)); if ((minorKind == 1) && - ((memcmp(segName,"Exif\0\0",6) == 0) || (memcmp(segName,"Exif\0\xFF",6) == 0))) { - tree->addComment("EXIF"); - tree->changeValue("EXIF"); - JpegMarker exifMarker; - exifMarker.jpegMarkerPtr = segPtr + 4 + 6; - exifMarker.jpegMarkerLen = segLen - 2 - 6; - exifMarkers.push_back(exifMarker); - } else if ((minorKind == 13) && (strcmp(segName,"Photoshop 3.0") == 0)) { + ((memcmp(segName, "Exif\0\0", 6) == 0) || (memcmp(segName, "Exif\0\xFF", 6) == 0))) { + tree->addComment("EXIF"); + tree->changeValue("EXIF"); + JpegMarker exifMarker; + exifMarker.jpegMarkerPtr = segPtr + 4 + 6; + exifMarker.jpegMarkerLen = segLen - 2 - 6; + exifMarkers.push_back(exifMarker); + } + else if ((minorKind == 13) && (strcmp(segName, "Photoshop 3.0") == 0)) { tree->addComment("PSIR"); tree->changeValue("PSIR"); JpegMarker psirMarker; psirMarker.jpegMarkerPtr = segPtr + 4 + strlen(segName) + 1; psirMarker.jpegMarkerLen = (XMP_Uns16)(segLen - 2 - strlen(segName) - 1); psirMarkers.push_back(psirMarker); - } else if ((minorKind == 1) && (strcmp(segName,"http://ns.adobe.com/xap/1.0/") == 0)) { + } + else if ((minorKind == 1) && (strcmp(segName, "http://ns.adobe.com/xap/1.0/") == 0)) { tree->addComment("XMP"); tree->changeValue("XMP"); xmpPtr = segPtr + 4 + strlen(segName) + 1; xmpLen = (XMP_Uns16)(segLen - 2 - strlen(segName) - 1); } - segPtr += 2+segLen; + segPtr += 2 + segLen; tree->popNode(); continue; } if (segMark == 0xFFDA) { tree->addComment(fromArgs("size %d, SOS", segLen)); - segPtr += 2+segLen; // Skip the SOS marker segment itself + segPtr += 2 + segLen; // Skip the SOS marker segment itself long rstCount = 0; while (segPtr < endPtr) { // Skip the entropy-coded data and RSTn markers. if (*segPtr != 0xFF) { segPtr += 1; // General data byte. - } else { - segMark = GetUns16BE (segPtr); + } + else { + segMark = GetUns16BE(segPtr); if (segMark == 0xFF00) { segPtr += 2; // Padded 0xFF data byte. - } else if ((segMark < 0xFFD0) || (segMark > 0xFFD7)) { + } + else if ((segMark < 0xFFD0) || (segMark > 0xFFD7)) { segLen = 0; segPtr -= 2; // Prepare for the increment in the outer loop. break; // Exit, non-RSTn marker. - } else { + } + else { ++rstCount; segPtr += 2; } @@ -1996,7 +2062,7 @@ } tree->addComment(fromArgs("%d restart markers", rstCount)); - segPtr += 2+segLen; + segPtr += 2 + segLen; tree->popNode(); continue; } @@ -2004,39 +2070,54 @@ if ((0xFF02 <= segMark) && (segMark <= 0xFFBF)) { tree->addComment(fromArgs("size %d, ** RES **", segLen)); - } else if ((0xFFC0 <= segMark) && (segMark <= 0xFFC3)) { + } + else if ((0xFFC0 <= segMark) && (segMark <= 0xFFC3)) { tree->addComment(fromArgs("size %d, SOF%d", segLen, minorKind)); - } else if (segMark == 0xFFC4) { + } + else if (segMark == 0xFFC4) { tree->addComment(fromArgs("size %d, DHT", segLen)); - } else if ((0xFFC5 <= segMark) && (segMark <= 0xFFC7)) { + } + else if ((0xFFC5 <= segMark) && (segMark <= 0xFFC7)) { tree->addComment(fromArgs("size %d, SOF%d", segLen, minorKind)); - } else if (segMark == 0xFFC8) { + } + else if (segMark == 0xFFC8) { tree->addComment(fromArgs("size %d, JPG", segLen)); - } else if ((0xFFC9 <= segMark) && (segMark <= 0xFFCB)) { + } + else if ((0xFFC9 <= segMark) && (segMark <= 0xFFCB)) { tree->addComment(fromArgs("size %d, SOF%d", segLen, minorKind)); - } else if (segMark == 0xFFCC) { + } + else if (segMark == 0xFFCC) { tree->addComment(fromArgs("size %d, DAC", segLen)); - } else if ((0xFFCD <= segMark) && (segMark <= 0xFFCF)) { + } + else if ((0xFFCD <= segMark) && (segMark <= 0xFFCF)) { tree->addComment(fromArgs("size %d, SOF%d", segLen, minorKind)); - } else if (segMark == 0xFFDB) { + } + else if (segMark == 0xFFDB) { tree->addComment(fromArgs("size %d, DQT", segLen)); - } else if (segMark == 0xFFDC) { + } + else if (segMark == 0xFFDC) { tree->addComment(fromArgs("size %d, DNL", segLen)); - } else if (segMark == 0xFFDD) { + } + else if (segMark == 0xFFDD) { tree->addComment(fromArgs("size %d, DRI", segLen)); - } else if (segMark == 0xFFDE) { + } + else if (segMark == 0xFFDE) { tree->addComment(fromArgs("size %d, DHP", segLen)); - } else if (segMark == 0xFFDF) { + } + else if (segMark == 0xFFDF) { tree->addComment(fromArgs("size %d, EXP", segLen)); - } else if ((0xFFF0 <= segMark) && (segMark <= 0xFFFD)) { + } + else if ((0xFFF0 <= segMark) && (segMark <= 0xFFFD)) { tree->addComment(fromArgs("size %d, JPG%d", segLen, minorKind)); - } else if (segMark == 0xFFFE) { + } + else if (segMark == 0xFFFE) { tree->addComment(fromArgs("size %d, COM", segLen)); - } else { + } + else { tree->addComment("** UNRECOGNIZED MARKER **"); } - segPtr += 2+segLen; + segPtr += 2 + segLen; tree->popNode(); } // ------------------------------------------------------------------------------------ @@ -2045,19 +2126,19 @@ segOffset = segPtr - jpegContent; tree->addComment(fromArgs( "** Unexpected end of JPEG markers at offset %d (0x%X), delta %d tree.", - segOffset, segOffset, (long)(endPtr-segPtr) - )); + segOffset, segOffset, (long)(endPtr - segPtr) + )); } - if (exifMarkers.size() > 0) DumpTIFF (exifMarkers, jpegContent, "JPEG Exif APP1", "JPEG:APP1"); - if (psirMarkers.size() > 0) DumpImageResources (psirMarkers, jpegContent, "JPEG Photoshop APP13"); - if (xmpPtr != 0) DumpXMP (xmpPtr, xmpLen, (xmpPtr - jpegContent), "JPEG XMP APP1"); + if (exifMarkers.size() > 0) DumpTIFF(exifMarkers, jpegContent, "JPEG Exif APP1", "JPEG:APP1"); + if (psirMarkers.size() > 0) DumpImageResources(psirMarkers, jpegContent, "JPEG Photoshop APP13"); + if (xmpPtr != 0) DumpXMP(xmpPtr, xmpLen, (xmpPtr - jpegContent), "JPEG XMP APP1"); } // DumpJPEG -// ================================================================================================= -//#if !IOS_ENV -static const XMP_Uns8 kUUID_XMP[16] = + // ================================================================================================= + //#if !IOS_ENV +static const XMP_Uns8 kUUID_XMP[16] = { 0xBE, 0x7A, 0xCF, 0xCB, 0x97, 0xA9, 0x42, 0xE8, 0x9C, 0x71, 0x99, 0x94, 0x91, 0xE3, 0xAF, 0xAC }; /*#else static const XMP_Uns8 kUUID_XMP[16] = @@ -2072,31 +2153,31 @@ // ------------------------------------------------------------------------------------------------- /** - * helper routine to get past the version and flags field... - */ +* helper routine to get past the version and flags field... +*/ static void -digestISOFullBoxExtension ( LFA_FileRef file, std::string isoPath, XMP_Int64& remainingSize, XMP_Uns8& version, XMP_Uns32& flags ) +digestISOFullBoxExtension(LFA_FileRef file, std::string isoPath, XMP_Int64& remainingSize, XMP_Uns8& version, XMP_Uns32& flags) { - version = LFA_ReadUns8( file ); + version = LFA_ReadUns8(file); flags = 0; - LFA_Read( file, &flags, 3, true ); // read only 3 byte! + LFA_Read(file, &flags, 3, true); // read only 3 byte! flags = flags >> 8; // (move to bit 0-23) - remainingSize -= 4; + remainingSize -= 4; - tree->setKeyValue( isoPath + "version", fromArgs( "%d", version) ); - tree->setKeyValue( isoPath + "flags", fromArgs( "0x%.8X", flags) ); + tree->setKeyValue(isoPath + "version", fromArgs("%d", version)); + tree->setKeyValue(isoPath + "flags", fromArgs("0x%.8X", flags)); } static void -digestInternationalTextSequence ( LFA_FileRef file, std::string isoPath, XMP_Int64* remainingSize ) +digestInternationalTextSequence(LFA_FileRef file, std::string isoPath, XMP_Int64* remainingSize) { - XMP_Int64 miniBoxStringSize = tree->digest16u(file,isoPath+"size",true,true); - tree->digest16u(file,isoPath+"language code",true,true); + XMP_Int64 miniBoxStringSize = tree->digest16u(file, isoPath + "size", true, true); + tree->digest16u(file, isoPath + "language code", true, true); (*remainingSize) -= 4; - if ( (*remainingSize) != miniBoxStringSize ) + if ((*remainingSize) != miniBoxStringSize) tree->addComment("WARNING: boxSize and miniBoxSize differ!"); - tree->digestString( file, isoPath+"value", miniBoxStringSize, false ); + tree->digestString(file, isoPath + "value", miniBoxStringSize, false); } /** @@ -2104,20 +2185,20 @@ * * maxBoxLen is :== fileLen on top-level, otherwise available length of outer box (exluding header size naturally) * -* (NB: reading (and displaying) box types, compat brands and other 4-letter stuff +* (NB: reading (and displaying) box types, compat brands and other 4-letter stuff * as LE is somehow easier (might need adjustment for PPC though) * * practices: * compensate endianess using MakeUns32BE() prior to use as string, NOT for numeric compare */ static void -DumpISOBoxes ( LFA_FileRef file, XMP_Uns32 maxBoxLen, std::string _isoPath ) -{ +DumpISOBoxes(LFA_FileRef file, XMP_Uns32 maxBoxLen, std::string _isoPath) +{ XMP_Int64 endOfThisLevel = LFA_Tell(file) + maxBoxLen; - std::string origIsoPath( _isoPath ); - std::string isoPath( _isoPath ); - - while ( LFA_Tell(file) < endOfThisLevel ) + std::string origIsoPath(_isoPath); + std::string isoPath(_isoPath); + std::list keys; + while (LFA_Tell(file) < endOfThisLevel) { XMP_Int64 boxHeaderSize = 8; @@ -2126,31 +2207,31 @@ //// certainly not enough room for another box? // could be a 32bit zero trailing a udta // or, uhm, something garbage-ish... - if ( LFA_Tell(file) + boxHeaderSize > endOfThisLevel ) + if (LFA_Tell(file) + boxHeaderSize > endOfThisLevel) { XMP_Int64 numUnusedBytes = (endOfThisLevel - LFA_Tell(file)); - tree->digestString( file, isoPath+"unused", numUnusedBytes, false ); - tree->addComment( "'free' since too small for a box" ); + tree->digestString(file, isoPath + "unused", numUnusedBytes, false); + tree->addComment("'free' since too small for a box"); bool ok; - LFA_Seek( file, endOfThisLevel, SEEK_SET, &ok ); - assertMsg("skippind to-small space failed (truncated file?)", ok ); + LFA_Seek(file, endOfThisLevel, SEEK_SET, &ok); + assertMsg("skippind to-small space failed (truncated file?)", ok); continue; // could just as well: return } - XMP_Int64 boxPos= LFA_Tell( file ); // store here, output below - XMP_Int64 boxSize = tree->digest32u( file, "", true ); // NB: 32bit <- 64bit - XMP_Uns32 boxType = tree->digest32u( file, "", false ); + XMP_Int64 boxPos = LFA_Tell(file); // store here, output below + XMP_Int64 boxSize = tree->digest32u(file, "", true); // NB: 32bit <- 64bit + XMP_Uns32 boxType = tree->digest32u(file, "", false); switch (boxSize) { case 0: // A value of zero says that the box extends to the end of the file. - boxSize = ( maxBoxLen - boxPos ); // *** could be errorneous below top-level + boxSize = (maxBoxLen - boxPos); // *** could be errorneous below top-level break; case 1: // A value of 1 says that a 64-bit big endian size is written after the box type field, the data follows. - boxSize = LFA_ReadUns64_BE( file ); + boxSize = LFA_ReadUns64_BE(file); boxHeaderSize += 8; break; default: @@ -2158,15 +2239,17 @@ } XMP_Uns32 tempBoxType = GetUns32LE(&boxType); - std::string boxString( fromArgs( "%.4s" , &tempBoxType) ); + std::string boxString(fromArgs("%.4s", &tempBoxType)); - if(boxString.size() != 0) + if (boxString.size() != 0) { // substitute mac-copyright signs with an easier-to-handle "(c)" -#if !IOS_ENV - if ( boxString.at(0) == 0xa9 ) +#if WIN_UNIVERSAL_ENV + if (boxString.at(0) == 0xffffffffffffffa9) +#elif !IOS_ENV + if (boxString.at(0) == 0xa9) #else - if ( boxString.at(0) == 0xffffffa9 ) + if (boxString.at(0) == 0xffffffa9) #endif boxString = std::string("(c)") + boxString.substr(1); } @@ -2178,8 +2261,13 @@ // TEMP // Log::info("pushing %s, endOfThisLevel: 0x%X", isoPath.c_str(), endOfThisLevel ); // printf ("%s \n", isoPath.c_str()); - tree->pushNode( isoPath ); - tree->addComment("offset 0x%I64X, size 0x%I64X", boxPos , boxSize); + tree->pushNode(isoPath); +#if ANDROID + tree->addComment("offset 0x%llX, size 0x%llX", boxPos, boxSize); +#else + tree->addComment("offset 0x%I64X, size 0x%I64X", boxPos, boxSize); +#endif + // endOfBoxPos saves the hassle of keeping the remainingSize up-to-date // (which is only needed and only done, if usefull for the specific box) @@ -2191,314 +2279,812 @@ XMP_Uns8 version = 255; XMP_Uns32 flags = 0xFFFFFF; - switch ( boxType ) + switch (boxType) { // container boxes (FULL), that contain (relevant) boxes: - case 0x6174656D: // meta, FULLBOX - if ( isoPath != "moov/udta/meta/" ) - break; //no area of interest (and navigate around some malformed files) - - digestISOFullBoxExtension( file, isoPath, remainingSize, version, flags ); - // intentionally: no break. - // fallthrough - - // container boxes (all non-FULL), that contain (relevant) boxes: - case 0x666E696D: // minf - "simple container, no direct content" - if ( boxString == "minf" && isoPath != "moov/trak/mdia/minf/" ) - break; - // fallthrough - case 0x6C627473: // stbl is a simple container, no direct content + case 0x6174656D: // meta, FULLBOX + if (isoPath == "moov/udta/meta/") + { + digestISOFullBoxExtension(file, isoPath, remainingSize, version, flags); + DumpISOBoxes(file, remainingSize, isoPath); + break; + } + else if (isoPath == "moov/meta/") + { + DumpISOBoxes(file, remainingSize, isoPath); + break; + } + else if (isoPath == "meta/") // for HEIF + { + digestISOFullBoxExtension(file, isoPath, remainingSize, version, flags); + DumpISOBoxes(file, remainingSize, isoPath); + break; + } + else + break; //no area of interest (and navigate around some malformed files) + + // container boxes (all non-FULL), that contain (relevant) boxes: + case 0x666E6964: //dinf + if (isoPath == "meta/dinf/") + { + bool ok; + XMP_Int64 keep = LFA_Tell(file); + DumpISOBoxes(file, remainingSize, isoPath); + LFA_Seek(file, keep, SEEK_SET, &ok); + assertMsg("seek failed", ok); + } + break; + case 0x66657264: // dref + digestISOFullBoxExtension(file, isoPath, remainingSize, version, flags); + tree->digest32u(file, isoPath + "entry_count", true, true); + DumpISOBoxes(file, remainingSize, isoPath); + break; + case 0x206C7275: // for 'url' field, for 'urn' support to be added later + digestISOFullBoxExtension(file, isoPath, remainingSize, version, flags); + if (remainingSize > 0) + { + tree->digestString(file, isoPath + "location", 0); + } + break; + case 0x6D746970: //pitm + digestISOFullBoxExtension(file, isoPath, remainingSize, version, flags); + tree->digest16u(file, isoPath + "item_ID", true, true); + break; + case 0x666E6969: //iinf + digestISOFullBoxExtension(file, isoPath, remainingSize, version, flags); + if (version == 0) + { + tree->digest16u(file, isoPath + "entry_count", true, true); + } + else + { + tree->digest32u(file, isoPath + "entry_count", true, true); + } + + DumpISOBoxes(file, remainingSize, isoPath); + break; + case 0x65666E69: //infe + XMP_Uns16 item_id; + digestISOFullBoxExtension(file, isoPath, remainingSize, version, flags); + if ((version == 0) || (version == 1)) + { + item_id = tree->digest16u(file, isoPath + "item_id", true, false); + remainingSize -= 2; + tree->digest16u(file, isoPath + "item_protection_index", true, true); + remainingSize -= 2; + item_name = tree->digestString(file, isoPath + "item_name", 0); + if (0 == item_name.compare(0, 4, "Exif")) { - TimeCodeTrack = false; // assume until we known better by a relevant - // moov/trak/mdia/minf/stbl/stsd/ of format tmcd - if ( boxString == "stbl" && isoPath != "moov/trak/mdia/minf/stbl/") - break; + exif_item_id = item_id; } - // fallthrough - case 0x766F6F6D: // moov - case 0x6169646D: // mdia - case 0x61746475: // udta - user data - case 0x6B617274: // trak - track - case 0x74736C69: // ilst (contains cprt box) + if (0 == item_name.compare(0, 4, "mime")) { - // store and restore current position to not depend - // on sub-level mischief... - bool ok; - XMP_Int64 keep = LFA_Tell( file ); - DumpISOBoxes( file, remainingSize, isoPath ); - LFA_Seek( file, keep, SEEK_SET, &ok ); - assertMsg( "seek failed", ok ); + mime_item_id = item_id; } - break; - - // known boxes, that need content extraction - case 0x70797466: // ftyp - file type + remainingSize -= (item_name.size() + 1); + if (remainingSize == 0) { - XMP_Uns32 majorBrand = LFA_ReadUns32_LE( file ); - XMP_Uns32 minorVersion = LFA_ReadUns32_LE( file ); - - //data has been read in LE make it in BE - majorBrand = GetUns32LE(&majorBrand); - minorVersion = GetUns32LE(&minorVersion); - - //Log::info( fromArgs( "major Brand: '%.4s' (0x%.8X)" , &majorBrand, MakeUns32BE(majorBrand) )); - //Log::info( fromArgs( "minor Version: 0x%.8X" , MakeUns32BE(minorVersion) ) ); - tree->setKeyValue( isoPath + "majorBrand", - fromArgs( "%.4s", &majorBrand ), - fromArgs( "0x%.8X" , MakeUns32BE(majorBrand) ) ); - tree->setKeyValue( isoPath + "minorVersion", - fromArgs( "0x%.8X", MakeUns32BE(minorVersion) ) ); - - remainingSize -= 4 + 4; - //Log::info( fromArgs( "remaining Size: %d" , remainingSize ) ); - - while ( remainingSize >= 4 ) - { - LFA_ReadUns32_LE( file ); - // TODO: Concatenate for KeyValue... - //XMP_Uns32 compatVersion = LFA_ReadUns32_LE( file ); - //Log::info( fromArgs( "compatible brand: '%.4s' (0x%.8X)" , &compatVersion, MakeUns32BE(compatVersion) )); - remainingSize -= 4; - } - - // odd bytes left? - if ( remainingSize > 0 ) - tree->addComment( "WARNING: %d bytes left, considering FREE", remainingSize ); - + //there are no fields to process further } - break; - case 0x61746164: // data (within itunes Metadata) - // all data atoms start with two common fields: a type indicator, and a locale indicator. - // each of these fields is four bytes long: - tree->digest32u(file, isoPath+ "type", true, true); - tree->digest32u(file, isoPath+ "locale", true, true); - remainingSize -= 8; - // rest is actual contents: - tree->digestString( file, isoPath + "value", remainingSize, false ); - break; - case 0x64697575: // uuid - XMP_Uns8 uid[16]; - tree->digest( file, isoPath + "uuidValue" , uid , 16 ); - if ( ! strncmp( (const char*) kUUID_XMP, (const char*) uid, 16 )) - tree->addComment(" - the XMP UUID !"); - - break; - - case 0x65657266: // free - tree->addComment( "free space" ); - break; - - // FULL BOXES (w/o container boxes, above) ********************************** - case 0x6468766D: // mvhd, FULLBOX, movie-header-box + else if (remainingSize > 0) { - digestISOFullBoxExtension( file, isoPath, remainingSize, version, flags ); - if ( version == 1 ) + //check for other fields here. If control reaches here, it means we have content_type field also + content_type = tree->digestString(file, isoPath + "content_type", 0); + remainingSize -= (content_type.size() + 1); + if (remainingSize == 0) { - tree->digest64u(file,isoPath+ "creation_time",true,true); - tree->digest64u(file,isoPath+ "modification_time",true,true); - tree->digest32u(file,isoPath+ "timescale",true,true); - tree->digest64u(file,isoPath+ "duration",true,true); - } - else if ( version == 0 ) + //there are no fields to process further + } + else if (remainingSize > 0) { - tree->digest32u(file,isoPath+ "creation_time",true,true); - tree->digest32u(file,isoPath+ "modification_time",true,true); - tree->digest32u(file,isoPath+ "timescale",true,true); - tree->digest32u(file,isoPath+ "duration",true,true); - } else + // we have content_encoding present also + content_encoding = tree->digestString(file, isoPath + "content_encoding", 0); + } + else { - tree->addComment("WARNING: unknown mvhd version!"); + //cout << "Some probem occurred when parsing infe box (content_encoding).Please check." << endl; } - // COULDDO more fields, but not needed right now. - } - break; - case 0x726C6468: // hdlr - handler reference - { - if ( isoPath != "moov/trak/mdia/hdlr/") break; - if ( remainingSize < 4*4 ) - break; // box too small... - - digestISOFullBoxExtension( file, isoPath, remainingSize, version, flags ); - - tree->digestString( file, isoPath+"quickTimeType", 4, false ); // expecting: 'mhlr' - media handler - tree->digestString( file, isoPath+"subType", 4, false ); // expecting: 'tmcd' - timecode - tree->digestString( file, isoPath+"manufacturer", 4, false ); // e.g. 'appl' - break; // rest doesn't bother us... + } + else + { + //cout << "Some probem occurred when parsing infe box.Please check." << endl; + } } - case 0x64737473: // stsd - timecode sample description table + if (version >= 2) { - if ( isoPath != "moov/trak/mdia/minf/stbl/stsd/") - break; - - // version (1 byte), flags (3 byte) - must be 0 - assertMsg("stbl: version and flags must be zero", 0 == tree->digest32u( file, "", true ) ); - // entryCount - must be 0 - assertMsg("stbl: at least one entry needed", 1 <= tree->digest32u( file, "", true ) ); - remainingSize -= 8; - - // only dump first occurence - // ensure there's enough bytes for at least on stbl: - if ( remainingSize < 29 ) - break; // MPEG4/al_sbr_twi_22_1_fsaac22.mv4 has a box that is smaller than this... - // hence can only break, not throw - XMP_Int64 entrySize = (XMP_Int64) tree->digest32u( file, "", true, true ); - std::string format = tree->digestString( file, "", 4, false ); // must be 'tmcd' - tree->pushNode( isoPath + format + "/" ); - if ( format != "tmcd" ) + if (version == 2) { - tree->addComment("irrelevant node"); - tree->popNode(); - break; // different party... + item_id = tree->digest16u(file, isoPath + "item_id", true, false); + remainingSize -= 2; } - - TimeCodeTrack = true; // we're in the right track - - Skip( file, 6 ); // [6] reserved bytes - tree->digest16u( file, isoPath+"dataReferenceIndex", true, true ); // (ignored) - tree->addOffset( file ); - Skip( file, 4 ); // uint32 reserved - tree->digest32u( file, isoPath+"flags", true, true ); - tree->digest32u( file, isoPath+"timeScale", true, true ); - tree->digest32u( file, isoPath+"frameDuration", true, true ); - Skip( file, 2 ); // skip ignored frame count, reserved - - // ////////////////////////////// dig out 'trailing boxes' - // comparing "atom remains" vs. "entry" (probably must be '>=' - - // deduct the already digested... - entrySize -= 34; // ( 4+4+6+2+4+4+4+4+1+1 ) - remainingSize -= 34; // (the atom-level value) - - assertMsg( "entry Size must be 0 or positive", entrySize >= 0 ); - assertMsg( "must not overreach atom", entrySize <= remainingSize ); - - XMP_Int64 endOfTrailingBoxes = LFA_Tell(file) + remainingSize; - while ( LFA_Tell(file) < endOfTrailingBoxes ) + else if (version == 3) { - LFA_Tell(file); - DumpISOBoxes( file, entrySize, isoPath ); - LFA_Tell(file); + item_id = tree->digest32u(file, isoPath + "item_id", true, false); + remainingSize -= 4; } + tree->digest16u(file, isoPath + "item_protection_index", true, true); + remainingSize -= 2; + item_type=tree->digest32u(file, isoPath + "item_type", true, true); + remainingSize -= 4; + item_name = tree->digestString(file, isoPath + "item_name", 0); + remainingSize -= (item_name.size() + 1); - assertMsg( "did not boil down to zero", LFA_Tell(file) == endOfTrailingBoxes ); - - tree->popNode(); - break; + if (0x45786966 == item_type) + { + exif_item_id = item_id; + } + if (0x6D696D65 == item_type) + { + mime_item_id = item_id; + } + else if (0x75726900 == item_type) + { + string item_uri_type=tree->digestString(file, isoPath + "item_uri_type", 0); + remainingSize -= (item_uri_type.size() + 1); + } + + + if (remainingSize == 0) + { + //there are no fields to process further + } + else if (remainingSize > 0) + { + //check for other fields here. If control reaches here, it means we have content_type field also + content_type = tree->digestString(file, isoPath + "content_type", 0); + remainingSize -= (content_type.size() + 1); + if (remainingSize == 0) + { + //there are no fields to process further + } + else if (remainingSize > 0) + { + // we have content_encoding present also + content_encoding = tree->digestString(file, isoPath + "content_encoding", 0); + } + else + { + cout << "Some probem occurred when parsing infe box (content_encoding).Please check." << endl; + } + } } - case 0x63737473: // stsc - timecode sample description table + //Get the data for exif - using value from exif_item_id + // Dump the exif metadata here { - if ( isoPath != "moov/trak/mdia/minf/stbl/stsc/") - break; - if ( !TimeCodeTrack ) + if (exif_item_id != 0 && tree->hasNode("meta/iloc/item[" + to_string(exif_item_id) + "]/extent_offset")) { - tree->addComment("not tcmd -> not of interest"); - break; // not of interest + bool ok; + XMP_Int64 keep = LFA_Tell(file); + XMP_Uns32 offset = stoi(tree->getValue("meta/iloc/item[" + to_string(exif_item_id) + "]/extent_offset")); // Here tiff stream starts after 16476 ( 16388 + 84 + 4 ) bytes from starting of PANA atom's content + //XMP_Uns8 *ExifSize = (XMP_Uns8*)malloc(4); + //Now point file to offset value + LFA_Seek(file, offset, SEEK_SET, &ok); + XMP_Uns32 blocksize = LFA_ReadUns32_BE(file); + LFA_Seek(file, offset + 4 + blocksize, SEEK_SET, &ok); + XMP_Uns64 tiffLength1 = (stoi(tree->getValue("meta/iloc/item[" + to_string(exif_item_id) + "]/extent_length"))); + XMP_Uns64 tiffLength = (stoi(tree->getValue("meta/iloc/item[" + to_string(exif_item_id) + "]/extent_length")) - blocksize - 4); + XMP_Uns8 *tiffContent = (XMP_Uns8*)malloc(tiffLength); + LFA_Read(file, tiffContent, tiffLength, true); + DumpTIFF(tiffContent, tiffLength, offset, "HEIF Exif", "HEIF:Exif"); + LFA_Seek(file, keep, SEEK_SET, &ok); + assertMsg("seek failed", ok); + exif_item_id = NULL; } + } + //Get the data for xmp - using value from mime_item_id + // Dump the xmp metadata here + { + if (mime_item_id != 0 && tree->hasNode("meta/iloc/item[" + to_string(mime_item_id) + "]/extent_offset")) + { + bool ok; + XMP_Int64 keep = LFA_Tell(file); + XMP_Uns32 offset = stoi(tree->getValue("meta/iloc/item[" + to_string(mime_item_id) + "]/extent_offset")); + XMP_Uns64 xmpLength = stoi(tree->getValue("meta/iloc/item[" + to_string(mime_item_id) + "]/extent_length")); + LFA_Seek(file, offset, SEEK_SET, &ok); + XMP_Uns8 *xmpContent = (XMP_Uns8*)malloc(xmpLength); + LFA_Read(file, xmpContent, xmpLength, true); + DumpXMP(xmpContent, xmpLength, offset, "XMP"); + LFA_Seek(file, keep, SEEK_SET, &ok); + assertMsg("seek failed", ok); + mime_item_id = NULL; + } + } + break; + case 0x636F6C69: //iloc + XMP_Uns16 deriveValues, item_count, extent_count; + XMP_Uns8 offset_size, length_size, base_offset_size, index_size; + digestISOFullBoxExtension(file, isoPath, remainingSize, version, flags); + // Read the contents here, do not add them to tree, move the seek to 16bits forward + deriveValues = LFA_ReadInt16_BE(file); + //add these values in the tree + offset_size = (deriveValues & 0xF000) >> 12; + length_size = (deriveValues & 0x0F00) >> 8; + base_offset_size = (deriveValues & 0x00F0) >> 4; + tree->setKeyValue(isoPath + "offset_size", fromArgs("%d", offset_size)); + tree->setKeyValue(isoPath + "length_size", fromArgs("%d", length_size)); + tree->setKeyValue(isoPath + "base_offset_size", fromArgs("%d", base_offset_size)); + if (version == 1 || version == 2) + { + index_size = (deriveValues & 0x000F); + tree->setKeyValue(isoPath + "index_size", fromArgs("%d", index_size)); + } + else + index_size = 0; + - // version (1 byte), flags (3 byte) - must be 0 - assertMsg("stbl: version and flags must be zero", 0 == tree->digest32u( file, "", true ) ); - // entryCount - must be 0 - assertMsg("stbl: at least one entry needed", 1 <= tree->digest32u( file, "", true ) ); - remainingSize -= 8; - - LFA_Tell( file ); - - tree->digest32u( file, isoPath+"firstChunkNo", true, true ); - tree->digest32u( file, isoPath+"numSamplesPerChunk", true, true ); - tree->digest32u( file, isoPath+"sampleDescriptionID", true, true ); + if (version < 2) + { + item_count = tree->digest16u(file, isoPath + "item_count", true, true); + } + else if (version == 2) { + item_count = tree->digest32u(file, isoPath + "item_count", true, true); + } + for (int i = 0; i < item_count; i++) + { + XMP_Uns32 item_id; + bool ok; + XMP_Int64 keep = LFA_Tell(file); + if (version < 2) + { + item_id = LFA_ReadUns16_BE(file); + } + else if (version == 2) { + item_id = LFA_ReadUns32_BE(file); + } + LFA_Seek(file, keep, SEEK_SET, &ok); + assertMsg("seek failed", ok); + string modifiedisoPath = isoPath + "item[" + to_string(item_id) + "]/"; + if (version < 2) + { + item_id=tree->digest16u(file, modifiedisoPath + "item_ID", true, true); + } + else if (version == 2) { + item_id=tree->digest32u(file, modifiedisoPath + "item_ID", true, true); + } + + if (version == 1 || version == 2) + { + //construction method + XMP_Uns16 deriveConstructionMethod = LFA_ReadInt16_BE(file); + XMP_Uns8 constructionMethod; + constructionMethod = (deriveConstructionMethod & 0xF000) >> 12; + tree->setKeyValue(isoPath + "construction_method", fromArgs("%d", constructionMethod)); + } + tree->digest16u(file, modifiedisoPath + "data_reference_index", true, true); + if (base_offset_size != 0) + { + if (base_offset_size == 4) { + tree->digest32u(file, modifiedisoPath + "base_offset", true, true); + } + else if (base_offset_size == 8) + { + tree->digest64u(file, modifiedisoPath + "base_offset", true, true); + } + else + { + cout << "wrong value of base_offset received!! It should be either 0 or 4 or 8" << endl; + } + } + + extent_count = tree->digest16u(file, modifiedisoPath + "extent_count", true, false); + for (int j = 0; j < extent_count; j++) + { + if ((version == 1 || version == 2) && (index_size > 0)) + { + + if (index_size == 4) { + tree->digest32u(file, modifiedisoPath + "index_size", true, false); + } + else if (index_size == 8) + { + tree->digest64u(file, modifiedisoPath + "index_size", true, false); + } + else + { + cout << "wrong value of index_size received!! It should be either 0 or 4 or 8" << endl; + } + } + + if (offset_size > 0) + { + if (offset_size == 4) { + tree->digest32u(file, modifiedisoPath + "extent_offset", true, false); + } + else if (offset_size == 8) + { + tree->digest64u(file, modifiedisoPath + "extent_offset", true, false); + } + else + { + cout << "wrong value of offset_size received!! It should be either 0 or 4 or 8" << endl; + } + } + + if (length_size > 0) + { + if (length_size == 4) { + tree->digest32u(file, modifiedisoPath + "extent_length", true, false); + } + else if (length_size == 8) + { + tree->digest64u(file, modifiedisoPath + "extent_length", true, false); + } + else + { + cout << "wrong value of length_size received!! It should be either 0 or 4 or 8" << endl; + } + } + + } + } + //Get the data for exif - using value from exif_item_id + // Dump the exif metadata here + { + if (exif_item_id != 0 && tree->hasNode("meta/iloc/item[" + to_string(exif_item_id) + "]/extent_offset")) + { + bool ok; + XMP_Int64 keep = LFA_Tell(file); + XMP_Uns32 offset = stoi(tree->getValue("meta/iloc/item[" + to_string(exif_item_id) + "]/extent_offset")); // Here tiff stream starts after 16476 ( 16388 + 84 + 4 ) bytes from starting of PANA atom's content + //XMP_Uns8 *ExifSize = (XMP_Uns8*)malloc(4); + //Now point file to offset value + LFA_Seek(file, offset, SEEK_SET, &ok); + XMP_Uns32 blocksize = LFA_ReadUns32_BE(file); + LFA_Seek(file, offset + 4 + blocksize, SEEK_SET, &ok); + XMP_Uns64 tiffLength1 = (stoi(tree->getValue("meta/iloc/item[" + to_string(exif_item_id) + "]/extent_length"))); + XMP_Uns64 tiffLength = (stoi(tree->getValue("meta/iloc/item[" + to_string(exif_item_id) + "]/extent_length")) - blocksize - 4); + XMP_Uns8 *tiffContent = (XMP_Uns8*)malloc(tiffLength); + LFA_Read(file, tiffContent, tiffLength, true); + DumpTIFF(tiffContent, tiffLength, offset, "HEIF Exif", "HEIF:Exif"); + LFA_Seek(file, keep, SEEK_SET, &ok); + assertMsg("seek failed", ok); + exif_item_id = NULL; + } + } + //Get the data for xmp - using value from mime_item_id + // Dump the xmp metadata here + { + if (mime_item_id != 0 && tree->hasNode("meta/iloc/item[" + to_string(exif_item_id) + "]/extent_offset")) + { + bool ok; + XMP_Int64 keep = LFA_Tell(file); + XMP_Uns32 offset = stoi(tree->getValue("meta/iloc/item[" + to_string(mime_item_id) + "]/extent_offset")); + XMP_Uns64 xmpLength = stoi(tree->getValue("meta/iloc/item[" + to_string(mime_item_id) + "]/extent_length")); + LFA_Seek(file, offset, SEEK_SET, &ok); + XMP_Uns8 *xmpContent = (XMP_Uns8*)malloc(xmpLength); + LFA_Read(file, xmpContent, xmpLength, true); + DumpXMP(xmpContent, xmpLength, offset, "XMP"); + LFA_Seek(file, keep, SEEK_SET, &ok); + assertMsg("seek failed", ok); + mime_item_id = NULL; + } + } + + break; + case 0x66657269: //iref + digestISOFullBoxExtension(file, isoPath, remainingSize, version, flags); + DumpISOBoxes(file, remainingSize, isoPath); + break; + case 0x676D6964: //dimg + XMP_Uns16 refCount; + tree->digest16u(file, isoPath + "from_item_ID", true, true); + refCount = tree->digest16u(file, isoPath + "reference_count", true, true); + for (int i = 0; i < refCount; i++) + { + tree->digest16u(file, isoPath + "to_item_ID", true, true); + } + break; + case 0x626D6874: //thmb + XMP_Uns16 refCount_thmb; + tree->digest16u(file, isoPath + "from_item_ID", true, true); + refCount_thmb = tree->digest16u(file, isoPath + "reference_count", true, true); + for (int i = 0; i < refCount_thmb; i++) + { + tree->digest16u(file, isoPath + "to_item_ID", true, true); + } + break; + case 0x63736463: //cdsc + XMP_Uns16 refCount_cdsc; + tree->digest16u(file, isoPath + "from_item_ID", true, true); + refCount_cdsc = tree->digest16u(file, isoPath + "reference_count", true, true); + for (int i = 0; i < refCount_cdsc; i++) + { + tree->digest16u(file, isoPath + "to_item_ID", true, true); + } + DumpISOBoxes(file, remainingSize, isoPath); + break; + case 0x70727069: //iprp + DumpISOBoxes(file, remainingSize, isoPath); + break; + /*case 0x6F637069: //ipco + DumpISOBoxes(file, remainingSize, isoPath); + break; + case 0x726c6f63: //colr + XMP_Uns32 colour_type; + colour_type=tree->digest32u(file, isoPath + "colour_type", true, true); + if (colour_type == 'nclx') + { + tree->digest16u(file, isoPath + "colour_primaries", true, true); + tree->digest16u(file, isoPath + "transfer_characteristics", true, true); + tree->digest16u(file, isoPath + "matrix_coefficients", true, true); + XMP_Uns8 full_range_flag = LFA_ReadUns8(file); + full_range_flag = ((full_range_flag & 0xF) >> 7); + tree->setKeyValue(isoPath + "full_range_flag", fromArgs("%d", full_range_flag)); + } + else if (colour_type == 'rICC') + { + + } + else if (colour_type == 'prof') + { + //unrestricted icc profile handling + + } + + break;*/ + case 0x666E696D: // minf - "simple container, no direct content" + if (boxString == "minf" && isoPath != "moov/trak/mdia/minf/") break; + case 0x6C627473: // stbl is a simple container, no direct content + { + TimeCodeTrack = false; // assume until we known better by a relevant + // moov/trak/mdia/minf/stbl/stsd/ of format tmcd + if (boxString == "stbl" && isoPath != "moov/trak/mdia/minf/stbl/") + break; + } + case 0x766F6F6D: // moov + case 0x6169646D: // mdia + case 0x61746475: // udta - user data + case 0x6B617274: // trak - track + case 0x74736C69: // ilst (contains cprt box) + { + // store and restore current position to not depend + // on sub-level mischief... + if (isoPath == "moov/meta/ilst/") + { + while (remainingSize > 0) + { + XMP_Uns32 metaItemSize = tree->digest32u(file, "", true); + XMP_Uns32 keyIndex = tree->digest32u(file, "", true); + string key_name = ISOMetaKeys[keyIndex - 1]; + string temp_Path = isoPath + key_name + "/"; + metaItemSize -= 4 + 4; + DumpISOBoxes(file, metaItemSize, temp_Path); + remainingSize -= (metaItemSize + 8); + } } + else + { + bool ok; + XMP_Int64 keep = LFA_Tell(file); + DumpISOBoxes(file, remainingSize, isoPath); + LFA_Seek(file, keep, SEEK_SET, &ok); + assertMsg("seek failed", ok); + } + } + break; + + // known boxes, that need content extraction + case 0x70797466: // ftyp - file type + { + XMP_Uns32 majorBrand = LFA_ReadUns32_LE(file); + XMP_Uns32 minorVersion = LFA_ReadUns32_LE(file); + + //data has been read in LE make it in BE + majorBrand = GetUns32LE(&majorBrand); + minorVersion = GetUns32LE(&minorVersion); + + //Log::info( fromArgs( "major Brand: '%.4s' (0x%.8X)" , &majorBrand, MakeUns32BE(majorBrand) )); + //Log::info( fromArgs( "minor Version: 0x%.8X" , MakeUns32BE(minorVersion) ) ); + tree->setKeyValue(isoPath + "majorBrand", + fromArgs("%.4s", &majorBrand), + fromArgs("0x%.8X", MakeUns32BE(majorBrand))); + tree->setKeyValue(isoPath + "minorVersion", + fromArgs("0x%.8X", MakeUns32BE(minorVersion))); - case 0x6F637473: // stco - timecode sample description table + remainingSize -= 4 + 4; + //Log::info( fromArgs( "remaining Size: %d" , remainingSize ) ); + + while (remainingSize >= 4) { - if ( isoPath != "moov/trak/mdia/minf/stbl/stco/") - break; - if ( !TimeCodeTrack ) - break; // not of interest + LFA_ReadUns32_LE(file); + // TODO: Concatenate for KeyValue... + //XMP_Uns32 compatVersion = LFA_ReadUns32_LE( file ); + //Log::info( fromArgs( "compatible brand: '%.4s' (0x%.8X)" , &compatVersion, MakeUns32BE(compatVersion) )); + remainingSize -= 4; + } + + // odd bytes left? + if (remainingSize > 0) + tree->addComment("WARNING: %d bytes left, considering FREE", remainingSize); + + } + break; + case 0x61746164: // data (within itunes Metadata) + // all data atoms start with two common fields: a type indicator, and a locale indicator. + // each of these fields is four bytes long: + tree->digest32u(file, isoPath + "type", true, true); + tree->digest32u(file, isoPath + "locale", true, true); + remainingSize -= 8; + // rest is actual contents: + tree->digestString(file, isoPath + "value", remainingSize, false); + break; + case 0x64697575: // uuid + XMP_Uns8 uid[16]; + tree->digest(file, isoPath + "uuidValue", uid, 16); + if (!strncmp((const char*)kUUID_XMP, (const char*)uid, 16)) + tree->addComment(" - the XMP UUID !"); - // version (1 byte), flags (3 byte) - must be 0 - assertMsg("stbl: version and flags must be zero", 0 == tree->digest32u( file, "", true ) ); - // entryCount - must be 0 - assertMsg("stbl: at least one entry needed", 1 <= tree->digest32u( file, "", true ) ); - remainingSize -= 8; + break; - XMP_Int64 absOffset = tree->digest32u( file, isoPath+"absFileOffset32", true, true ); - - // recklessly navigate to that timecode media sample, grab value, return to old position... - XMP_Int64 oldPos = LFA_Tell( file ); - LFA_Seek( file, absOffset, SEEK_SET, 0 ); - tree->digest32u( file, isoPath+"timecodeMediaSample", true, true ); - LFA_Seek( file, oldPos, SEEK_SET, 0 ); + case 0x65657266: // free + tree->addComment("free space"); + break; + + // FULL BOXES (w/o container boxes, above) ********************************** + case 0x6468766D: // mvhd, FULLBOX, movie-header-box + { + digestISOFullBoxExtension(file, isoPath, remainingSize, version, flags); + if (version == 1) + { + tree->digest64u(file, isoPath + "creation_time", true, true); + tree->digest64u(file, isoPath + "modification_time", true, true); + tree->digest32u(file, isoPath + "timescale", true, true); + tree->digest64u(file, isoPath + "duration", true, true); + } + else if (version == 0) + { + tree->digest32u(file, isoPath + "creation_time", true, true); + tree->digest32u(file, isoPath + "modification_time", true, true); + tree->digest32u(file, isoPath + "timescale", true, true); + tree->digest32u(file, isoPath + "duration", true, true); } - // fallthrough - case 0x34366F63: // co64 - timecode sample description table -> 64 bit offset + else + { + tree->addComment("WARNING: unknown mvhd version!"); + } + // COULDDO more fields, but not needed right now. + } + break; + case 0x726C6468: // hdlr - handler reference + { + if (isoPath == "moov/trak/mdia/hdlr/") + { + if (remainingSize < 4 * 4) + break; // box too small... + + digestISOFullBoxExtension(file, isoPath, remainingSize, version, flags); + + tree->digestString(file, isoPath + "quickTimeType", 4, false); // expecting: 'mhlr' - media handler + tree->digestString(file, isoPath + "subType", 4, false); // expecting: 'tmcd' - timecode + tree->digestString(file, isoPath + "manufacturer", 4, false); // e.g. 'appl' + break; + } + else if (isoPath == "moov/meta/hdlr/") { - if ( isoPath != "moov/trak/mdia/minf/stbl/co64/") + assertMsg("hdlr: version and flags must be zero", 0 == tree->digest32u(file, "", true)); + LFA_Seek(file, 4, SEEK_CUR); + + XMP_Uns32 hndlrTyp = LFA_ReadUns32_BE(file); + if (hndlrTyp == 0x6D647461) + tree->addComment("Handler Type = mdta"); + else break; - tree->digest64u( file, isoPath+"absFileOffset64", true, true ); + remainingSize -= 12; + XMP_Uns32 pos = LFA_Tell(file); + LFA_Seek(file, pos + remainingSize, SEEK_SET); + break; + } + else if (isoPath == "meta/hdlr/") + { + digestISOFullBoxExtension(file, isoPath, remainingSize, version, flags); + LFA_Seek(file, 4, SEEK_CUR); + tree->digestString(file, isoPath + "handler_type", 4, false); + break; + } + // rest doesn't bother us... + } + case 0x64737473: // stsd - timecode sample description table + { + if (isoPath != "moov/trak/mdia/minf/stbl/stsd/") break; + + // version (1 byte), flags (3 byte) - must be 0 + assertMsg("stbl: version and flags must be zero", 0 == tree->digest32u(file, "", true)); + // entryCount - must be 0 + assertMsg("stbl: at least one entry needed", 1 <= tree->digest32u(file, "", true)); + remainingSize -= 8; + + // only dump first occurence + // ensure there's enough bytes for at least on stbl: + if (remainingSize < 29) + break; // MPEG4/al_sbr_twi_22_1_fsaac22.mv4 has a box that is smaller than this... + // hence can only break, not throw + XMP_Int64 entrySize = (XMP_Int64)tree->digest32u(file, "", true, true); + std::string format = tree->digestString(file, "", 4, false); // must be 'tmcd' + tree->pushNode(isoPath + format + "/"); + if (format != "tmcd") + { + tree->addComment("irrelevant node"); + tree->popNode(); + break; // different party... } - case 0x74727063: // cprt, FULLBOX - if ( isoPath == "moov/udta/cprt/" || isoPath == "moov/uuid/udta/cprt/" ) - { + TimeCodeTrack = true; // we're in the right track - digestISOFullBoxExtension( file, isoPath, remainingSize, version, flags ); + Skip(file, 6); // [6] reserved bytes + tree->digest16u(file, isoPath + "dataReferenceIndex", true, true); // (ignored) + tree->addOffset(file); + Skip(file, 4); // uint32 reserved + tree->digest32u(file, isoPath + "flags", true, true); + tree->digest32u(file, isoPath + "timeScale", true, true); + tree->digest32u(file, isoPath + "frameDuration", true, true); + Skip(file, 2); // skip ignored frame count, reserved - // 1/8 byte ISO language padding = 1-bit value set to 0 - // 1 7/8 bytes content language = 3 * 5-bits ISO 639-2 language code less 0x60 - // - example code for english = 0x15C7 - tree->digest16u(file,isoPath+"content language",true,true); - tree->addComment("(0x15C7 == english)"); - // zero-terminated, actual string: - tree->digestString( file, isoPath+"value", 0 ); - } else - { - // ISO - copyright (?) - // a container box, hunt for 'data' atom by recursion: - bool ok; - XMP_Int64 keep = LFA_Tell( file ); - DumpISOBoxes( file, remainingSize, isoPath ); - LFA_Seek( file, keep, SEEK_SET, &ok ); - assertMsg( "seek failed", ok ); - } + // ////////////////////////////// dig out 'trailing boxes' + // comparing "atom remains" vs. "entry" (probably must be '>=' + + // deduct the already digested... + entrySize -= 34; // ( 4+4+6+2+4+4+4+4+1+1 ) + remainingSize -= 34; // (the atom-level value) + + assertMsg("entry Size must be 0 or positive", entrySize >= 0); + assertMsg("must not overreach atom", entrySize <= remainingSize); + + XMP_Int64 endOfTrailingBoxes = LFA_Tell(file) + remainingSize; + while (LFA_Tell(file) < endOfTrailingBoxes) + { + LFA_Tell(file); + DumpISOBoxes(file, entrySize, isoPath); + LFA_Tell(file); + } + + assertMsg("did not boil down to zero", LFA_Tell(file) == endOfTrailingBoxes); + + tree->popNode(); + break; + } + + case 0x63737473: // stsc - timecode sample description table + { + if (isoPath != "moov/trak/mdia/minf/stbl/stsc/") break; - case 0x64686B74: // tkhd, FULLBOX - case 0x6E61656D: // mean, FULLBOX - case 0x656D616E: // name, FULLBOX - { - if ( isoPath == "moov/trak/mdia/minf/stbl/stsd/name/" ) // this regrettably is a diffrent animal (international text sequence) - digestInternationalTextSequence( file, isoPath, &remainingSize ); - else - digestISOFullBoxExtension( file, isoPath, remainingSize, version, flags ); - } + if (!TimeCodeTrack) + { + tree->addComment("not tcmd -> not of interest"); + break; // not of interest + } + + // version (1 byte), flags (3 byte) - must be 0 + assertMsg("stbl: version and flags must be zero", 0 == tree->digest32u(file, "", true)); + // entryCount - must be 0 + assertMsg("stbl: at least one entry needed", 1 <= tree->digest32u(file, "", true)); + remainingSize -= 8; + + LFA_Tell(file); + + tree->digest32u(file, isoPath + "firstChunkNo", true, true); + tree->digest32u(file, isoPath + "numSamplesPerChunk", true, true); + tree->digest32u(file, isoPath + "sampleDescriptionID", true, true); + + break; + } + + case 0x6F637473: // stco - timecode sample description table + { + if (isoPath != "moov/trak/mdia/minf/stbl/stco/") break; + if (!TimeCodeTrack) + break; // not of interest - // (c)-style quicktime boxes and boxes of no interest: - default: - if ( (boxType & 0xA9) == 0xA9) // (c)something + // version (1 byte), flags (3 byte) - must be 0 + assertMsg("stbl: version and flags must be zero", 0 == tree->digest32u(file, "", true)); + // entryCount - must be 0 + assertMsg("stbl: at least one entry needed", 1 <= tree->digest32u(file, "", true)); + remainingSize -= 8; + + XMP_Int64 absOffset = tree->digest32u(file, isoPath + "absFileOffset32", true, true); + + // recklessly navigate to that timecode media sample, grab value, return to old position... + XMP_Int64 oldPos = LFA_Tell(file); + LFA_Seek(file, absOffset, SEEK_SET, 0); + tree->digest32u(file, isoPath + "timecodeMediaSample", true, true); + LFA_Seek(file, oldPos, SEEK_SET, 0); + + } + case 0x34366F63: // co64 - timecode sample description table -> 64 bit offset + { + if (isoPath != "moov/trak/mdia/minf/stbl/co64/") + break; + + tree->digest64u(file, isoPath + "absFileOffset64", true, true); + break; + } + + case 0x74727063: // cprt, FULLBOX + if (isoPath == "moov/udta/cprt/" || isoPath == "moov/uuid/udta/cprt/") + { + + digestISOFullBoxExtension(file, isoPath, remainingSize, version, flags); + + // 1/8 byte ISO language padding = 1-bit value set to 0 + // 1 7/8 bytes content language = 3 * 5-bits ISO 639-2 language code less 0x60 + // - example code for english = 0x15C7 + tree->digest16u(file, isoPath + "content language", true, true); + tree->addComment("(0x15C7 == english)"); + // zero-terminated, actual string: + tree->digestString(file, isoPath + "value", 0); + } + else + { + // ISO - copyright (?) + // a container box, hunt for 'data' atom by recursion: + bool ok; + XMP_Int64 keep = LFA_Tell(file); + DumpISOBoxes(file, remainingSize, isoPath); + LFA_Seek(file, keep, SEEK_SET, &ok); + assertMsg("seek failed", ok); + } + break; + case 0x64686B74: // tkhd, FULLBOX + case 0x6E61656D: // mean, FULLBOX + case 0x656D616E: // name, FULLBOX + { + if (isoPath == "moov/trak/mdia/minf/stbl/stsd/name/") // this regrettably is a diffrent animal (international text sequence) + digestInternationalTextSequence(file, isoPath, &remainingSize); + else + digestISOFullBoxExtension(file, isoPath, remainingSize, version, flags); + } + break; + case 0x7379656B: //moov/meta/keys + { + LFA_Seek(file, 4, SEEK_CUR); + XMP_Uns32 keysCount = tree->digest32u(file, "", true); + tree->addComment("Number of Keys = %d", keysCount); + XMP_Uns32 index; + for (index = 1; index <= keysCount; index++) + { + XMP_Uns32 keySize = tree->digest32u(file, "", true); + keySize -= 4 + 4; // 4 bytes of key_size and key_namespace + string key_namespace = tree->digestString(file, "", 4); + if ((strcmp(key_namespace.c_str(), "mdta") == 0) || (strcmp(key_namespace.c_str(), "udta") == 0)) { - if ( 0 == isoPath.compare( 0 , 10, "moov/udta/" )) + string key_value = tree->digestString(file, "", keySize); + ISOMetaKeys.push_back(key_value); + tree->pushNode(isoPath + key_value); + tree->addComment("Key Namespace = %s", key_namespace.c_str()); + tree->popNode(); + } + else + LFA_Seek(file, keySize, SEEK_CUR); + } + } + break; + // (c)-style quicktime boxes and boxes of no interest: + default: + if ((boxType & 0xA9) == 0xA9) // (c)something + { + if (0 == isoPath.compare(0, 10, "moov/udta/")) { // => Quicktime metadata "international text sequence" ( size, language code, value ) - digestInternationalTextSequence( file, isoPath, &remainingSize ); - } else + digestInternationalTextSequence(file, isoPath, &remainingSize); + } + else { tree->addComment("WARNING: unknown flavor of (c)*** boxes, neither QT nor iTunes"); - } - break; - } - //boxes of no interest: + } break; + } + //boxes of no interest: + break; } bool ok; - LFA_Seek( file, endOfBoxPos, SEEK_SET, &ok ); - assertMsg("End-of-Box Seek failed (truncated file?)", ok ); + LFA_Seek(file, endOfBoxPos, SEEK_SET, &ok); + assertMsg("End-of-Box Seek failed (truncated file?)", ok); tree->popNode(); @@ -2506,25 +3092,25 @@ } // DumpISOBoxes() -// attempt to combine dumping of mpeg-4 and quicktime (mov) into one routine... + // attempt to combine dumping of mpeg-4 and quicktime (mov) into one routine... static void -DumpISO ( LFA_FileRef file, XMP_Uns32 fileLen ) +DumpISO(LFA_FileRef file, XMP_Uns32 fileLen) { TimeCodeTrack = false; // see specificition at https://zerowing.corp.adobe.com/display/XMP/Embedding+Spec+MPEG4 - DumpISOBoxes(file, fileLen, "" ); - assertMsg("truncated file/last box reached beyond end?", LFA_Tell(file) == fileLen ); + DumpISOBoxes(file, fileLen, ""); + assertMsg("truncated file/last box reached beyond end?", LFA_Tell(file) == fileLen); } // ================================================================================================= -static size_t GetASFObjectInfo (LFA_FileRef file, XMP_Uns32 objOffset, ASF_ObjHeader* objHeader, size_t nesting) +static size_t GetASFObjectInfo(LFA_FileRef file, XMP_Uns32 objOffset, ASF_ObjHeader* objHeader, size_t nesting) { - LFA_Seek (file, objOffset, SEEK_SET); - LFA_Read ( file, objHeader, 24, true); + LFA_Seek(file, objOffset, SEEK_SET); + LFA_Read(file, objHeader, 24, true); - objHeader->size = GetUns64LE (&objHeader->size); + objHeader->size = GetUns64LE(&objHeader->size); XMP_Uns32 size32 = (XMP_Uns32)objHeader->size; if (objHeader->size > 0xFFFFFFFF) { @@ -2534,23 +3120,24 @@ size_t infoIndex; for (infoIndex = 0; kASF_KnownObjects[infoIndex].name != 0; ++infoIndex) { - if (memcmp (&objHeader->guid, &kASF_KnownObjects[infoIndex].guid, 16) == 0) break; + if (memcmp(&objHeader->guid, &kASF_KnownObjects[infoIndex].guid, 16) == 0) break; } - std::string indent (3*nesting, ' '); + std::string indent(3 * nesting, ' '); if (kASF_KnownObjects[infoIndex].name != 0) { tree->addComment("%s %s Object, offset %u (0x%X), size %u", indent.c_str(), kASF_KnownObjects[infoIndex].name, objOffset, objOffset, size32); - } else { + } + else { tree->addComment("%s <>, offset %u (0x%X), size %u", indent.c_str(), objOffset, objOffset, size32); ASF_GUID guid; memset(&guid, 0, sizeof(ASF_GUID)); - guid.part1 = GetUns32LE (&objHeader->guid.part1); - guid.part2 = GetUns16LE (&objHeader->guid.part2); - guid.part3 = GetUns16LE (&objHeader->guid.part3); - guid.part4 = GetUns16LE (&objHeader->guid.part4); + guid.part1 = GetUns32LE(&objHeader->guid.part1); + guid.part2 = GetUns16LE(&objHeader->guid.part2); + guid.part3 = GetUns16LE(&objHeader->guid.part3); + guid.part4 = GetUns16LE(&objHeader->guid.part4); tree->addComment("GUID %.8X-%.4X-%.4X-%.4X-%.4X%.8X", guid.part1, guid.part2, guid.part3, guid.part4, *(XMP_Uns16*)(&guid.part5[0]), *(XMP_Uns32*)(&guid.part5[2])); @@ -2562,22 +3149,22 @@ } // GetASFObjectInfo -// ================================================================================================= + // ================================================================================================= -static void PrinfASF_UTF16 (LFA_FileRef file, XMP_Uns16 byteCount, const char * label) +static void PrinfASF_UTF16(LFA_FileRef file, XMP_Uns16 byteCount, const char * label) { - size_t filePos = LFA_Tell (file); + size_t filePos = LFA_Tell(file); //FNO: note: has sideeffect on sDataPtr - CaptureFileData (file, 0, byteCount); + CaptureFileData(file, 0, byteCount); tree->setKeyValue( label, - convert16Bit(false,sDataPtr,false,byteCount), - fromArgs("offset %d (0x%X), size %d",filePos, filePos, byteCount) - ); + convert16Bit(false, sDataPtr, false, byteCount), + fromArgs("offset %d (0x%X), size %d", filePos, filePos, byteCount) + ); } -static void DumpASFFileProperties (LFA_FileRef file, XMP_Uns32 objOffset, XMP_Uns32 objLen) +static void DumpASFFileProperties(LFA_FileRef file, XMP_Uns32 objOffset, XMP_Uns32 objLen) { ASF_FileProperties fileProps; @@ -2586,28 +3173,28 @@ return; } - LFA_Seek (file, objOffset, SEEK_SET); - LFA_Read ( file, &fileProps, kASF_FilePropertiesSize, true); + LFA_Seek(file, objOffset, SEEK_SET); + LFA_Read(file, &fileProps, kASF_FilePropertiesSize, true); - fileProps.flags = GetUns32LE (&fileProps.flags); // Only care about flags and create date. - fileProps.creationDate = GetUns64LE (&fileProps.creationDate); + fileProps.flags = GetUns32LE(&fileProps.flags); // Only care about flags and create date. + fileProps.creationDate = GetUns64LE(&fileProps.creationDate); bool bcast = (bool)(fileProps.flags & 1); tree->setKeyValue("ASF:broadcast", (bcast ? "set" : "not set") - ); + ); - XMP_Int64 totalSecs = fileProps.creationDate / (10*1000*1000); - XMP_Int32 nanoSec = ((XMP_Int32) (fileProps.creationDate - (totalSecs * 10*1000*1000))) * 100; - XMP_Int32 days = (XMP_Int32) (totalSecs / 86400); + XMP_Int64 totalSecs = fileProps.creationDate / (10 * 1000 * 1000); + XMP_Int32 nanoSec = ((XMP_Int32)(fileProps.creationDate - (totalSecs * 10 * 1000 * 1000))) * 100; + XMP_Int32 days = (XMP_Int32)(totalSecs / 86400); totalSecs -= ((XMP_Int64)days * 86400); - XMP_Int32 hour = (XMP_Int32) (totalSecs / 3600); + XMP_Int32 hour = (XMP_Int32)(totalSecs / 3600); totalSecs -= ((XMP_Int64)hour * 3600); - XMP_Int32 minute = (XMP_Int32) (totalSecs / 60); + XMP_Int32 minute = (XMP_Int32)(totalSecs / 60); totalSecs -= ((XMP_Int64)minute * 60); XMP_Int32 second = (XMP_Int32)totalSecs; XMP_DateTime binDate; - memset (&binDate, 0, sizeof(binDate)); + memset(&binDate, 0, sizeof(binDate)); binDate.year = 1601; binDate.month = 1; @@ -2619,19 +3206,19 @@ binDate.second = second; binDate.nanoSecond = nanoSec; - SXMPUtils::ConvertToUTCTime (&binDate); + SXMPUtils::ConvertToUTCTime(&binDate); std::string strDate; - SXMPUtils::ConvertFromDate (binDate, &strDate); + SXMPUtils::ConvertFromDate(binDate, &strDate); tree->setKeyValue("ASF:creation date", fromArgs("%s (0x%.8X-%.8X)", - strDate.c_str(), High32(fileProps.creationDate), Low32(fileProps.creationDate)) - ); + strDate.c_str(), High32(fileProps.creationDate), Low32(fileProps.creationDate)) + ); } // DumpASFFileProperties -// ================================================================================================= + // ================================================================================================= -static void DumpASFContentDescription (LFA_FileRef file, XMP_Uns32 objOffset, XMP_Uns32 objLen) +static void DumpASFContentDescription(LFA_FileRef file, XMP_Uns32 objOffset, XMP_Uns32 objLen) { ASF_ContentDescription contentDesc; // ! The lengths are in bytes. @@ -2640,108 +3227,108 @@ return; } - LFA_Seek (file, objOffset, SEEK_SET); - LFA_Read ( file, &contentDesc, kASF_ContentDescriptionSize, true); + LFA_Seek(file, objOffset, SEEK_SET); + LFA_Read(file, &contentDesc, kASF_ContentDescriptionSize, true); - contentDesc.titleLen = GetUns16LE (&contentDesc.titleLen); - contentDesc.authorLen = GetUns16LE (&contentDesc.authorLen); - contentDesc.copyrightLen = GetUns16LE (&contentDesc.copyrightLen); - contentDesc.descriptionLen = GetUns16LE (&contentDesc.descriptionLen); - contentDesc.ratingLen = GetUns16LE (&contentDesc.ratingLen); - - PrinfASF_UTF16 (file, contentDesc.titleLen, "ASF:title"); - PrinfASF_UTF16 (file, contentDesc.authorLen, "ASF:author"); - PrinfASF_UTF16 (file, contentDesc.copyrightLen, "ASF:copyright"); - PrinfASF_UTF16 (file, contentDesc.descriptionLen, "ASF:description"); - PrinfASF_UTF16 (file, contentDesc.ratingLen, "ASF:rating"); + contentDesc.titleLen = GetUns16LE(&contentDesc.titleLen); + contentDesc.authorLen = GetUns16LE(&contentDesc.authorLen); + contentDesc.copyrightLen = GetUns16LE(&contentDesc.copyrightLen); + contentDesc.descriptionLen = GetUns16LE(&contentDesc.descriptionLen); + contentDesc.ratingLen = GetUns16LE(&contentDesc.ratingLen); + + PrinfASF_UTF16(file, contentDesc.titleLen, "ASF:title"); + PrinfASF_UTF16(file, contentDesc.authorLen, "ASF:author"); + PrinfASF_UTF16(file, contentDesc.copyrightLen, "ASF:copyright"); + PrinfASF_UTF16(file, contentDesc.descriptionLen, "ASF:description"); + PrinfASF_UTF16(file, contentDesc.ratingLen, "ASF:rating"); } // DumpASFContentDescription -// ================================================================================================= + // ================================================================================================= -static void DumpASFContentBranding (LFA_FileRef file, XMP_Uns32 objOffset, XMP_Uns32 objLen) +static void DumpASFContentBranding(LFA_FileRef file, XMP_Uns32 objOffset, XMP_Uns32 objLen) { XMP_Uns32 fieldSize; - if (objLen < (16 + 8 + 4*4)) { + if (objLen < (16 + 8 + 4 * 4)) { tree->comment("** Content Branding Object is too short"); return; } XMP_Uns32 fieldOffset = objOffset + 16 + 8 + 4; - LFA_Seek (file, fieldOffset, SEEK_SET); + LFA_Seek(file, fieldOffset, SEEK_SET); - LFA_Read ( file, &fieldSize, 4, true); - fieldSize = GetUns32LE (&fieldSize); + LFA_Read(file, &fieldSize, 4, true); + fieldSize = GetUns32LE(&fieldSize); fieldOffset += fieldSize; - LFA_Seek (file, fieldSize, SEEK_CUR); // Skip the banner data. + LFA_Seek(file, fieldSize, SEEK_CUR); // Skip the banner data. - LFA_Read ( file, &fieldSize, 4, true); - fieldSize = GetUns32LE (&fieldSize); + LFA_Read(file, &fieldSize, 4, true); + fieldSize = GetUns32LE(&fieldSize); fieldOffset += fieldSize; tree->setKeyValue("ASF:banner URL", "", - fromArgs("offset %d (0x%X), size %d", fieldOffset, fieldOffset, fieldSize ) - ); + fromArgs("offset %d (0x%X), size %d", fieldOffset, fieldOffset, fieldSize) + ); if (fieldSize != 0) { - CaptureFileData (file, 0, fieldSize); + CaptureFileData(file, 0, fieldSize); //NB: not yet tested..., not sure if stopOnNull needed, thus using false - tree->changeValue(convert8Bit(sDataPtr,false,fieldSize)); + tree->changeValue(convert8Bit(sDataPtr, false, fieldSize)); } - LFA_Read ( file, &fieldSize, 4, true); - fieldSize = GetUns32LE (&fieldSize); + LFA_Read(file, &fieldSize, 4, true); + fieldSize = GetUns32LE(&fieldSize); fieldOffset += fieldSize; tree->setKeyValue("ASF:copyright URL", "", - fromArgs("offset %d (0x%X), size %d", fieldOffset, fieldOffset, fieldSize) - ); + fromArgs("offset %d (0x%X), size %d", fieldOffset, fieldOffset, fieldSize) + ); if (fieldSize != 0) { - CaptureFileData (file, 0, fieldSize); + CaptureFileData(file, 0, fieldSize); //NB: not yet tested..., not sure if stopOnNull needed, thus using false - tree->changeValue(convert8Bit(sDataPtr,false,fieldSize)); + tree->changeValue(convert8Bit(sDataPtr, false, fieldSize)); } } // DumpASFContentBranding -// ================================================================================================= + // ================================================================================================= -static void DumpASFContentEncryption (LFA_FileRef file, XMP_Uns32 objOffset, XMP_Uns32 objLen) +static void DumpASFContentEncryption(LFA_FileRef file, XMP_Uns32 objOffset, XMP_Uns32 objLen) { XMP_Uns32 fieldSize; - if (objLen < (16 + 8 + 4*4)) { + if (objLen < (16 + 8 + 4 * 4)) { tree->addComment("** Content Encryption Object is too short"); return; } - LFA_Seek (file, (objOffset+16+8), SEEK_SET); + LFA_Seek(file, (objOffset + 16 + 8), SEEK_SET); - LFA_Read ( file, &fieldSize, 4, true); - fieldSize = GetUns32LE (&fieldSize); - LFA_Seek (file, fieldSize, SEEK_CUR); // Skip the secret data. - - LFA_Read ( file, &fieldSize, 4, true); - fieldSize = GetUns32LE (&fieldSize); - LFA_Seek (file, fieldSize, SEEK_CUR); // Skip the protection type. - - LFA_Read ( file, &fieldSize, 4, true); - fieldSize = GetUns32LE (&fieldSize); - CaptureFileData (file, 0, fieldSize); - PrintOnlyASCII_8 (sDataPtr, fieldSize); - - LFA_Read ( file, &fieldSize, 4, true); - fieldSize = GetUns32LE (&fieldSize); - CaptureFileData (file, 0, fieldSize); - PrintOnlyASCII_8 (sDataPtr, fieldSize); + LFA_Read(file, &fieldSize, 4, true); + fieldSize = GetUns32LE(&fieldSize); + LFA_Seek(file, fieldSize, SEEK_CUR); // Skip the secret data. + + LFA_Read(file, &fieldSize, 4, true); + fieldSize = GetUns32LE(&fieldSize); + LFA_Seek(file, fieldSize, SEEK_CUR); // Skip the protection type. + + LFA_Read(file, &fieldSize, 4, true); + fieldSize = GetUns32LE(&fieldSize); + CaptureFileData(file, 0, fieldSize); + PrintOnlyASCII_8(sDataPtr, fieldSize); + + LFA_Read(file, &fieldSize, 4, true); + fieldSize = GetUns32LE(&fieldSize); + CaptureFileData(file, 0, fieldSize); + PrintOnlyASCII_8(sDataPtr, fieldSize); } // DumpASFContentEncryption -// ================================================================================================= + // ================================================================================================= -static void DumpASFHeaderExtension (LFA_FileRef file, XMP_Uns32 extOffset, XMP_Uns32 extLen) +static void DumpASFHeaderExtension(LFA_FileRef file, XMP_Uns32 extOffset, XMP_Uns32 extLen) { // The Header Extension Object is a child of the Header Object and the parent of nested objects. @@ -2753,7 +3340,7 @@ ASF_ObjHeader childHeader; for (childOffset = (extOffset + kASF_HeaderExtensionSize); childOffset < extEnd; childOffset += childLen) { - (void) GetASFObjectInfo (file, childOffset, &childHeader, 2); + (void)GetASFObjectInfo(file, childOffset, &childHeader, 2); childLen = (XMP_Uns32)childHeader.size; } @@ -2763,10 +3350,10 @@ } // DumpASFHeaderExtension -// ================================================================================================= + // ================================================================================================= static void -DumpASF (LFA_FileRef file, XMP_Uns32 asfLen) +DumpASF(LFA_FileRef file, XMP_Uns32 asfLen) { // An ASF file contains objects of the form: // A 16 byte GUID giving the object's type and use @@ -2786,7 +3373,7 @@ tree->comment("ASF file Object layout"); // Dump the Header Object's content, looking for legacy metadata. - infoIndex = GetASFObjectInfo (file, 0, &objHeader, 0); + infoIndex = GetASFObjectInfo(file, 0, &objHeader, 0); XMP_Uns32 headerLen = (XMP_Uns32)objHeader.size; if (kASF_KnownObjects[infoIndex].kind != kASFObj_Header) { @@ -2795,33 +3382,33 @@ } XMP_Uns32 nestedCount; - LFA_Seek (file, 24, SEEK_SET); - LFA_Read ( file, &nestedCount, 4, true); - nestedCount = GetUns32LE (&nestedCount); + LFA_Seek(file, 24, SEEK_SET); + LFA_Read(file, &nestedCount, 4, true); + nestedCount = GetUns32LE(&nestedCount); tree->addComment("%u nested objects", nestedCount); - for (objOffset = (16+8+4+2); objOffset < headerLen; objOffset += objLen, --nestedCount) { - infoIndex = GetASFObjectInfo (file, objOffset, &objHeader, 1); + for (objOffset = (16 + 8 + 4 + 2); objOffset < headerLen; objOffset += objLen, --nestedCount) { + infoIndex = GetASFObjectInfo(file, objOffset, &objHeader, 1); objLen = (XMP_Uns32)objHeader.size; switch (kASF_KnownObjects[infoIndex].kind) { - case kASFObj_FileProperties : - DumpASFFileProperties (file, objOffset, objLen); - break; - case kASFObj_ContentDesc : - DumpASFContentDescription (file, objOffset, objLen); - break; - case kASFObj_ContentBrand : - DumpASFContentBranding (file, objOffset, objLen); - break; - case kASFObj_ContentEncrypt : - DumpASFContentEncryption (file, objOffset, objLen); - break; - case kASFObj_HeaderExtension : - DumpASFHeaderExtension (file, objOffset, objLen); - break; - default : - break; + case kASFObj_FileProperties: + DumpASFFileProperties(file, objOffset, objLen); + break; + case kASFObj_ContentDesc: + DumpASFContentDescription(file, objOffset, objLen); + break; + case kASFObj_ContentBrand: + DumpASFContentBranding(file, objOffset, objLen); + break; + case kASFObj_ContentEncrypt: + DumpASFContentEncryption(file, objOffset, objLen); + break; + case kASFObj_HeaderExtension: + DumpASFHeaderExtension(file, objOffset, objLen); + break; + default: + break; } } @@ -2832,48 +3419,48 @@ } // Dump the basic info for the remaining objects, looking for the XMP along the way. - infoIndex = GetASFObjectInfo (file, objOffset, &objHeader, 0); + infoIndex = GetASFObjectInfo(file, objOffset, &objHeader, 0); objLen = (XMP_Uns32)objHeader.size; if (kASF_KnownObjects[infoIndex].kind != kASFObj_Data) { tree->addComment("** Second object is not the Data Object"); if (kASF_KnownObjects[infoIndex].kind == kASFObj_XMP) { if (sXMPPtr == 0) - CaptureXMPF (file, (objOffset + 24), (objLen - 24)); + CaptureXMPF(file, (objOffset + 24), (objLen - 24)); else tree->addComment("** Multiple XMP objects"); } } for (objOffset += objLen; objOffset < asfLen; objOffset += objLen) { - GetASFObjectInfo (file, objOffset, &objHeader, 0); + GetASFObjectInfo(file, objOffset, &objHeader, 0); objLen = (XMP_Uns32)objHeader.size; if (kASF_KnownObjects[infoIndex].kind == kASFObj_XMP) { if (sXMPPtr == 0) - CaptureXMPF (file, (objOffset + 24), (objLen - 24)); + CaptureXMPF(file, (objOffset + 24), (objLen - 24)); else tree->addComment("** Multiple XMP objects"); } } if (objOffset != asfLen) tree->addComment("** Invalid end to top level objects: %u", objOffset); - if (sXMPPtr != 0) DumpXMP ("ASF XMP object"); + if (sXMPPtr != 0) DumpXMP("ASF XMP object"); } // DumpASF -// ================================================================================================= + // ================================================================================================= static void DumpUCF(LFA_FileRef file, XMP_Int64 len) { ////////////////////////////////////////////////////////////////////// // constants - const static XMP_Uns32 UCF_HS_CONTENTFILE=0x04034b50; - const static XMP_Uns32 UCF_CD_FILE_HEADER=0x02014b50; //central directory - file header - const static XMP_Uns32 UCF_ZIP64_END_OF_CD_RECORD=0x06064b50; - const static XMP_Uns32 UCF_ZIP64_END_OF_CD_LOCATOR=0x07064b50; - const static XMP_Uns32 UCF_CD_END=0x06054b50; + const static XMP_Uns32 UCF_HS_CONTENTFILE = 0x04034b50; + const static XMP_Uns32 UCF_CD_FILE_HEADER = 0x02014b50; //central directory - file header + const static XMP_Uns32 UCF_ZIP64_END_OF_CD_RECORD = 0x06064b50; + const static XMP_Uns32 UCF_ZIP64_END_OF_CD_LOCATOR = 0x07064b50; + const static XMP_Uns32 UCF_CD_END = 0x06054b50; const static XMP_Int32 UCF_COMMENT_MAX = 0xFFFF; const static XMP_Int32 UCF_EOD_FIXED_SIZE = 22; @@ -2883,24 +3470,24 @@ ////////////////////////////////////////////////////////////////////// // variables: - XMP_Int64 curPos=0; + XMP_Int64 curPos = 0; bool isZip64; XMP_Uns32 numDirEntries; - - XMP_Uns64 size_CD; - XMP_Uns64 offset_Zip64_EndOfCD_Record=0; + + XMP_Uns64 size_CD; + XMP_Uns64 offset_Zip64_EndOfCD_Record = 0; XMP_Uns64 offset_CD; typedef std::list OffsetStack; OffsetStack contentFiles; contentFiles.clear(); //precaution for mac - ////////////////////////////////////////////////////////////////////// - // prolog: - tree->comment("len is 0x%I64X",len); + ////////////////////////////////////////////////////////////////////// + // prolog: + tree->comment("len is 0x%I64X", len); tree->comment("inherently parsing bottom-up"); - if( len > 0xFFFFFFFFl ) + if (len > 0xFFFFFFFFl) tree->comment("info: >4GB ==> most like zip64 !"); ////////////////////////////////////////////////////////////////////// @@ -2909,69 +3496,69 @@ ///////////////////////////////////////////////////////////////////// // zip comment: XMP_Int32 zipCommentLen = 0; - for ( ; zipCommentLen <= UCF_COMMENT_MAX; zipCommentLen++ ) + for (; zipCommentLen <= UCF_COMMENT_MAX; zipCommentLen++) { - LFA_Seek( file, -zipCommentLen -2, SEEK_END ); - if ( LFA_ReadUns16_LE( file ) == zipCommentLen ) //found it? + LFA_Seek(file, -zipCommentLen - 2, SEEK_END); + if (LFA_ReadUns16_LE(file) == zipCommentLen) //found it? { //double check, might just look like comment length (actually be 'evil' comment) - LFA_Seek( file , - UCF_EOD_FIXED_SIZE, SEEK_CUR ); - if ( LFA_ReadUns32_LE( file ) == UCF_CD_END ) break; //heureka, directory ID - // 'else': just go on + LFA_Seek(file, -UCF_EOD_FIXED_SIZE, SEEK_CUR); + if (LFA_ReadUns32_LE(file) == UCF_CD_END) break; //heureka, directory ID + // 'else': just go on } } - tree->comment( fromArgs("zip Comment length: %d",zipCommentLen )); + tree->comment(fromArgs("zip Comment length: %d", zipCommentLen)); //was it a break or just not found ? - assertMsg ( "zip broken near end or invalid comment", zipCommentLen < UCF_COMMENT_MAX ); + assertMsg("zip broken near end or invalid comment", zipCommentLen < UCF_COMMENT_MAX); ///////////////////////////////////////////////////////////////////// // End of CDR: - LFA_Seek( file , - UCF_EOD_FIXED_SIZE - zipCommentLen, SEEK_END); + LFA_Seek(file, -UCF_EOD_FIXED_SIZE - zipCommentLen, SEEK_END); curPos = LFA_Tell(file); tree->pushNode("End of Central Directory"); - tree->addOffset( file ); + tree->addOffset(file); { - assertMsg("expected 'end of central directory record'", UCF_CD_END == tree->digest32u(file) ); + assertMsg("expected 'end of central directory record'", UCF_CD_END == tree->digest32u(file)); assertMsg("UCF allow single-volume zips only", 0 == tree->digest16u(file)); //volume number (0,1,..) - assertMsg("UCF allow single-volume zips only(thus directory must be in 0)", 0 == tree->digest16u(file,"")); //volume number (0,1,..) - - numDirEntries=tree->digest16u(file,"number of directory entries"); - tree->digest16u(numDirEntries, file,"number of total directory entries"); + assertMsg("UCF allow single-volume zips only(thus directory must be in 0)", 0 == tree->digest16u(file, "")); //volume number (0,1,..) + + numDirEntries = tree->digest16u(file, "number of directory entries"); + tree->digest16u(numDirEntries, file, "number of total directory entries"); - size_CD = tree->digest32u(file,"size of central directory",false,true); - offset_CD = tree->digest32u(file,"offset of central directory",false,true); + size_CD = tree->digest32u(file, "size of central directory", false, true); + offset_CD = tree->digest32u(file, "offset of central directory", false, true); if (offset_CD == 0xFFFFFFFF) tree->addComment("apparently zip-64"); - XMP_Uns16 zipCommentLengReverify = tree->digest16u(file,"zip comment length"); - assertMsg( "zipCommentLengReverify failed", zipCommentLengReverify == zipCommentLen ); + XMP_Uns16 zipCommentLengReverify = tree->digest16u(file, "zip comment length"); + assertMsg("zipCommentLengReverify failed", zipCommentLengReverify == zipCommentLen); } tree->popNode(); ///////////////////////////////////////////////////////////////////// // Zip64 End Of CD Locator - LFA_Seek( file, curPos - UCF_ZIP64_LOCATOR_FIXED_SIZE ,SEEK_SET ); + LFA_Seek(file, curPos - UCF_ZIP64_LOCATOR_FIXED_SIZE, SEEK_SET); //tree->comment("offset is %X", LFA_Tell(file) ); //tree->comment("peek is %X", Peek32u(file) ); - if ( Peek32u(file) != UCF_ZIP64_END_OF_CD_LOCATOR ) + if (Peek32u(file) != UCF_ZIP64_END_OF_CD_LOCATOR) { tree->comment("no Zip64 CDL -> no Zip64"); - assertMsg("offset FFFF FFFF indicates zip-64, but no Zip64 CDL found", offset_CD != 0xFFFFFFFF ); - isZip64=false; + assertMsg("offset FFFF FFFF indicates zip-64, but no Zip64 CDL found", offset_CD != 0xFFFFFFFF); + isZip64 = false; } else { - isZip64=true; + isZip64 = true; tree->pushNode("Zip64 End-Of-CD Locator"); - tree->addOffset( file ); + tree->addOffset(file); - tree->digest32u(file,"sig",false,true); + tree->digest32u(file, "sig", false, true); assertMsg("'numOfDisk with central start dir' must be 0", - 0 == tree->digest32u(file,"disk with start dir")); - tree->digest64u(&offset_Zip64_EndOfCD_Record, file,"Zip64 End Of CD Offset",false,true); - - tree->digest32u( /* deactived while bug #1742179: 1,*/ file, "total num of disks", false, true); + 0 == tree->digest32u(file, "disk with start dir")); + tree->digest64u(&offset_Zip64_EndOfCD_Record, file, "Zip64 End Of CD Offset", false, true); + + tree->digest32u( /* deactived while bug #1742179: 1,*/ file, "total num of disks", false, true); tree->popNode(); } @@ -2981,114 +3568,114 @@ { XMP_Uns64 size_Zip64_EndOfCD_Record; tree->pushNode("Zip64 End of CD Record"); - LFA_Seek( file, offset_Zip64_EndOfCD_Record ,SEEK_SET ); - tree->addOffset( file ); + LFA_Seek(file, offset_Zip64_EndOfCD_Record, SEEK_SET); + tree->addOffset(file); - tree->digest32u( UCF_ZIP64_END_OF_CD_RECORD ,file, "sig", false, true ); - tree->digest64u( &size_Zip64_EndOfCD_Record, file, "size of zip64 CDR", false, true); - tree->digest16u( file, "made by", false, true ); - tree->digest16u( file, "needed to extract", false, true ); - tree->digest32u( (XMP_Uns32)0 , file, "number of this disk", false, true); - tree->digest32u( (XMP_Uns32)0 , file, "disk that contains start of CD", false, true); - tree->digest64u( (XMP_Uns64) numDirEntries, file, "total Num of Entries This Disk", false, false ); - tree->digest64u( (XMP_Uns64) numDirEntries, file, "total Num of Entries", false, false ); + tree->digest32u(UCF_ZIP64_END_OF_CD_RECORD, file, "sig", false, true); + tree->digest64u(&size_Zip64_EndOfCD_Record, file, "size of zip64 CDR", false, true); + tree->digest16u(file, "made by", false, true); + tree->digest16u(file, "needed to extract", false, true); + tree->digest32u((XMP_Uns32)0, file, "number of this disk", false, true); + tree->digest32u((XMP_Uns32)0, file, "disk that contains start of CD", false, true); + tree->digest64u((XMP_Uns64)numDirEntries, file, "total Num of Entries This Disk", false, false); + tree->digest64u((XMP_Uns64)numDirEntries, file, "total Num of Entries", false, false); //TODO assert agtainst each other and above - tree->digest64u( &size_CD, file, "size_CD", false, true ); - tree->digest64u( &offset_CD, file, "offset_CD", false, true ); + tree->digest64u(&size_CD, file, "size_CD", false, true); + tree->digest64u(&offset_CD, file, "offset_CD", false, true); XMP_Int64 lenExtensibleSector = UCF_ZIP64_RECORD_FIXED_SIZE - size_Zip64_EndOfCD_Record; - tree->comment("zip64 extensible data sector (%d bytes)", lenExtensibleSector ); + tree->comment("zip64 extensible data sector (%d bytes)", lenExtensibleSector); //sanity test: - Skip( file, lenExtensibleSector ); - assertMsg("numbers don't add up", Peek32u(file) != UCF_ZIP64_END_OF_CD_LOCATOR ); + Skip(file, lenExtensibleSector); + assertMsg("numbers don't add up", Peek32u(file) != UCF_ZIP64_END_OF_CD_LOCATOR); tree->popNode(); } - + ///////////////////////////////////////////////////////////////////// // parse Central directory structure: content file 1..n tree->pushNode("Central directory structure:"); - LFA_Seek( file, offset_CD ,SEEK_SET ); - tree->addOffset( file ); + LFA_Seek(file, offset_CD, SEEK_SET); + tree->addOffset(file); - for (XMP_Uns32 contentFileNo=1 ; contentFileNo <= numDirEntries; contentFileNo++ ) + for (XMP_Uns32 contentFileNo = 1; contentFileNo <= numDirEntries; contentFileNo++) { tree->pushNode("File Header No %d:", contentFileNo); - tree->addOffset( file ); + tree->addOffset(file); XMP_Uns16 version, flags, cmethod; - XMP_Uns32 crc,compressed_size,uncompressed_size32; + XMP_Uns32 crc, compressed_size, uncompressed_size32; XMP_Uns64 offsetLocalHeader = 0; bool usesDescriptionHeader; - tree->digest32u( UCF_CD_FILE_HEADER, file, "sig", false, true ); - - tree->digest16u(file,"version made by",false,true); - tree->digest16u(&version, file,"version needed to extract"); - assertMsg( fromArgs("illegal 'version needed to extract' (must be 10,20 or 45, was %u)",version), - ( version == 10 || version == 20 || version == 45)); - - tree->digest16u ( &flags, file, "general purpose bit flags", false, true ); - assertMsg("no zip encryption must be used", (flags&0x1)==0); - usesDescriptionHeader= ((flags&0x8) != 0); + tree->digest32u(UCF_CD_FILE_HEADER, file, "sig", false, true); + + tree->digest16u(file, "version made by", false, true); + tree->digest16u(&version, file, "version needed to extract"); + assertMsg(fromArgs("illegal 'version needed to extract' (must be 10,20 or 45, was %u)", version), + (version == 10 || version == 20 || version == 45)); + + tree->digest16u(&flags, file, "general purpose bit flags", false, true); + assertMsg("no zip encryption must be used", (flags & 0x1) == 0); + usesDescriptionHeader = ((flags & 0x8) != 0); if (usesDescriptionHeader) tree->addComment("uses description header"); - tree->digest16u(&cmethod, file,"compression method"); - assertMsg("illegal compression method (must be 0 or 8(flate))!",( cmethod == 0 || cmethod == 8 )); + tree->digest16u(&cmethod, file, "compression method"); + assertMsg("illegal compression method (must be 0 or 8(flate))!", (cmethod == 0 || cmethod == 8)); - tree->digest(file,"last mod file time",0,2); - tree->digest(file,"last mod file date",0,2); + tree->digest(file, "last mod file time", 0, 2); + tree->digest(file, "last mod file date", 0, 2); tree->digest32u(&crc, file); //crc-32 - tree->digest32u(&compressed_size, file,"compressed size"); - tree->digest32u(&uncompressed_size32, file,"uncompressed size"); + tree->digest32u(&compressed_size, file, "compressed size"); + tree->digest32u(&uncompressed_size32, file, "uncompressed size"); - XMP_Uns16 size_filename,size_extra,size_comment; + XMP_Uns16 size_filename, size_extra, size_comment; - tree->digest16u( &size_filename , file , "size filename"); - assertMsg("unusual name length length (broken file?)", size_filename>0 && size_filename < 500 ); //discover parsing nonsense... - tree->digest16u( &size_extra , file , "size extra field"); - tree->digest16u( &size_comment , file , "size file comment"); - tree->digest16u( (XMP_Uns16)0 , file , "disk start no"); + tree->digest16u(&size_filename, file, "size filename"); + assertMsg("unusual name length length (broken file?)", size_filename>0 && size_filename < 500); //discover parsing nonsense... + tree->digest16u(&size_extra, file, "size extra field"); + tree->digest16u(&size_comment, file, "size file comment"); + tree->digest16u((XMP_Uns16)0, file, "disk start no"); - tree->digest16u( file , "internal attribs"); - tree->digest32u( file , "external attribs"); + tree->digest16u(file, "internal attribs"); + tree->digest32u(file, "external attribs"); - offsetLocalHeader = tree->digest32u( file , "relative offset local header",false,true); // Int64 <== Uns32 + offsetLocalHeader = tree->digest32u(file, "relative offset local header", false, true); // Int64 <== Uns32 - // name of file, optional relative path, strictly forward slashes. + // name of file, optional relative path, strictly forward slashes. assert(size_filename != 0); - std::string filename = tree->digestString(file,"filename",size_filename); //NOT zero-terminated + std::string filename = tree->digestString(file, "filename", size_filename); //NOT zero-terminated if (contentFileNo == 1) { - assert( size_extra == 0); //spec guarantes mimetype content at 38 <=> extraFieldLen == 0 - assertMsg ( - fromArgs("first file in UCF must be called mimetype, was %s",filename.c_str()), - (size_filename == 8) && (filename == "mimetype")); + assert(size_extra == 0); //spec guarantes mimetype content at 38 <=> extraFieldLen == 0 + assertMsg( + fromArgs("first file in UCF must be called mimetype, was %s", filename.c_str()), + (size_filename == 8) && (filename == "mimetype")); } - - if(size_extra != 0) + + if (size_extra != 0) { tree->pushNode("extraField"); XMP_Int32 remaining = size_extra; while (remaining > 0) { - assertMsg( "need 4 bytes for next header ID+len", remaining >= 4); - XMP_Uns16 headerID = tree->digest16u(file,"headerID",false,true); - XMP_Uns16 dataSize = tree->digest16u(file,"data size",false,true); + assertMsg("need 4 bytes for next header ID+len", remaining >= 4); + XMP_Uns16 headerID = tree->digest16u(file, "headerID", false, true); + XMP_Uns16 dataSize = tree->digest16u(file, "data size", false, true); remaining -= 4; - assertMsg( "actual field lenght not given", remaining >= dataSize); - if ( headerID == 0x1 ) //we only care about "Zip64 extended information extra field" - { - tree->digest64u( &offsetLocalHeader, file, "64bit offset", false, true); + assertMsg("actual field lenght not given", remaining >= dataSize); + if (headerID == 0x1) //we only care about "Zip64 extended information extra field" + { + tree->digest64u(&offsetLocalHeader, file, "64bit offset", false, true); remaining -= 8; } else { - Skip(file, dataSize ); + Skip(file, dataSize); remaining -= dataSize; } - + } tree->popNode(); } @@ -3096,115 +3683,115 @@ //now that regular 32 bit and zip-64 is through... if (contentFileNo == 1) { - assertMsg( "first header offset (aka content file offset) must (naturally) be 0", offsetLocalHeader==0 ); + assertMsg("first header offset (aka content file offset) must (naturally) be 0", offsetLocalHeader == 0); } else { - assertMsg("local header offset (aka content file offset) must not be 0", offsetLocalHeader!=0 ); + assertMsg("local header offset (aka content file offset) must not be 0", offsetLocalHeader != 0); } contentFiles.push_back(offsetLocalHeader); - if(size_comment != 0) + if (size_comment != 0) { - tree->digest(file,"file comment",0,size_comment); + tree->digest(file, "file comment", 0, size_comment); } tree->popNode(); //file header } tree->popNode(); //central directory structure - - ///////////////////////////////////////////////////////////////////// - // Content Files (incl. Headers, etc) - for(XMP_Uns16 cfNo=1; cfNo <= numDirEntries; cfNo++) + + ///////////////////////////////////////////////////////////////////// + // Content Files (incl. Headers, etc) + for (XMP_Uns16 cfNo = 1; cfNo <= numDirEntries; cfNo++) { //vars - XMP_Uns32 compressed_size,uncompressed_size, crc32; - XMP_Uns16 version,nameLen,extraFieldLen; + XMP_Uns32 compressed_size, uncompressed_size, crc32; + XMP_Uns16 version, nameLen, extraFieldLen; tree->pushNode("Content File %d:", cfNo); - - assert( !contentFiles.empty()); + + assert(!contentFiles.empty()); XMP_Int64 fileHeaderOffset = contentFiles.front(); contentFiles.pop_front(); bool ok; - LFA_Seek( file, fileHeaderOffset, SEEK_SET, &ok ); - tree->addOffset( file ); + LFA_Seek(file, fileHeaderOffset, SEEK_SET, &ok); + tree->addOffset(file); assert(ok); //local file header - tree->digest32u( UCF_HS_CONTENTFILE, file, "sig", false, true ); - tree->digest16u(&version, file,"version"); + tree->digest32u(UCF_HS_CONTENTFILE, file, "sig", false, true); + tree->digest16u(&version, file, "version"); assertMsg("illegal 'version needed to extract' (must be 10,20 or 45, was %u)", - ( version == 10 || version == 20 || version == 45)); - Skip(file,8); - tree->digest32u( &crc32, file, "crc-32", false, true ); - tree->digest32u( &compressed_size, file, "compressed", false, false ); - tree->digest32u( &uncompressed_size, file, "uncompressed", false, false ); - tree->digest16u( &nameLen, file, "file name length", false, false ); - tree->digest16u( &extraFieldLen, file, "extra field length", false, false ); + (version == 10 || version == 20 || version == 45)); + Skip(file, 8); + tree->digest32u(&crc32, file, "crc-32", false, true); + tree->digest32u(&compressed_size, file, "compressed", false, false); + tree->digest32u(&uncompressed_size, file, "uncompressed", false, false); + tree->digest16u(&nameLen, file, "file name length", false, false); + tree->digest16u(&extraFieldLen, file, "extra field length", false, false); assert(nameLen != 0); - assertMsg("unusual name length length (broken file?)", nameLen>0 && nameLen < 500 ); //discover parsing nonsense... + assertMsg("unusual name length length (broken file?)", nameLen>0 && nameLen < 500); //discover parsing nonsense... - // name of file, optional relative path, strictly forward slashes. - std::string filename = tree->digestString(file,"filename",nameLen); //NOT zero-terminated + // name of file, optional relative path, strictly forward slashes. + std::string filename = tree->digestString(file, "filename", nameLen); //NOT zero-terminated if (cfNo == 1) { - assertMsg("first file in UCF muste be called mimetype", filename=="mimetype" ); - assert( extraFieldLen == 0); //spec guarantes mimetype content at 38 <=> extraFieldLen == 0 - assert( LFA_Tell(file)==38 ); - tree->digestString(file,"file data (mimetype)",compressed_size); + assertMsg("first file in UCF muste be called mimetype", filename == "mimetype"); + assert(extraFieldLen == 0); //spec guarantes mimetype content at 38 <=> extraFieldLen == 0 + assert(LFA_Tell(file) == 38); + tree->digestString(file, "file data (mimetype)", compressed_size); } else //not the first mimetype file thing { // FILE DATA ============================================================= if (extraFieldLen != 0) // may indeed not exist, and lenght=0 must not be passed into digestString() - tree->digestString(file,"extra field",extraFieldLen); //NOT zero-terminated - tree->setKeyValue("file data","",fromArgs("skipping %u bytes",compressed_size)); - Skip(file,compressed_size); + tree->digestString(file, "extra field", extraFieldLen); //NOT zero-terminated + tree->setKeyValue("file data", "", fromArgs("skipping %u bytes", compressed_size)); + Skip(file, compressed_size); } tree->popNode(); } - + tree->pushNode(""); tree->popNode(); } // DumpUCF -// ================================================================================================= + // ================================================================================================= -// AVI and WAV files are RIFF based. Although they have usage differences, we can have a common -// dumper. This might need changes for other RIFF-based files, e.g. for specific legacy -// metadata. RIFF is a chunky format. AVI and WAV have an outermost RIFF chunk. The XMP is in a -// top level "_PMX" chunk. Legacy metadata for WAV is in a top level LIST/INFO chunk. Legacy -// metadata for AVI is in a variety of places, don't have specs at present. Free space can be -// JUNK or JUNQ. -// -// A RIFF chunk contains: -// - A 4 byte chunk ID, typically ASCII letters -// - A little endian UInt32 size of the chunk data -// - The chunk data -// - Pad byte if the chunk data length is odd (added on 2007-03-22) - -// The ID is written in "reading order", e.g. the 'R' in "RIFF" is first in the file. Chunks -// must start on even offsets. A pad byte of 0 is written after the data if necessary. The size -// does not include the pad, nor the ID and size fields. Some chunks contain nested chunks, -// notably the RIFF and LIST chunks do. These have the layout: -// - A 4 byte chunk ID, typically ASCII letters -// - A little endian UInt32 size of the chunk data -// - A 4 byte usage ID, typically ASCII letters -// - The nested chunks - -// reads maxSize bytes from file (not "up to", exactly fullSize) -// puts it into a string, sets respective tree property -static void setFixedBEXTField ( LFA_FileRef file, std::string propName, XMP_Int64 fullSize ) -{ - char* descriptionBuffer = new char[ fullSize + 2 ]; - LFA_Read( file, descriptionBuffer, fullSize, true ); - descriptionBuffer[fullSize]='\0'; // tack on, in case not contained - // parse till first \0 - std::string description( descriptionBuffer ); - tree->setKeyValue( propName, description) ; - delete[] descriptionBuffer; + // AVI and WAV files are RIFF based. Although they have usage differences, we can have a common + // dumper. This might need changes for other RIFF-based files, e.g. for specific legacy + // metadata. RIFF is a chunky format. AVI and WAV have an outermost RIFF chunk. The XMP is in a + // top level "_PMX" chunk. Legacy metadata for WAV is in a top level LIST/INFO chunk. Legacy + // metadata for AVI is in a variety of places, don't have specs at present. Free space can be + // JUNK or JUNQ. + // + // A RIFF chunk contains: + // - A 4 byte chunk ID, typically ASCII letters + // - A little endian UInt32 size of the chunk data + // - The chunk data + // - Pad byte if the chunk data length is odd (added on 2007-03-22) + + // The ID is written in "reading order", e.g. the 'R' in "RIFF" is first in the file. Chunks + // must start on even offsets. A pad byte of 0 is written after the data if necessary. The size + // does not include the pad, nor the ID and size fields. Some chunks contain nested chunks, + // notably the RIFF and LIST chunks do. These have the layout: + // - A 4 byte chunk ID, typically ASCII letters + // - A little endian UInt32 size of the chunk data + // - A 4 byte usage ID, typically ASCII letters + // - The nested chunks + + // reads maxSize bytes from file (not "up to", exactly fullSize) + // puts it into a string, sets respective tree property +static void setFixedBEXTField(LFA_FileRef file, std::string propName, XMP_Int64 fullSize) +{ + char* descriptionBuffer = new char[fullSize + 2]; + LFA_Read(file, descriptionBuffer, fullSize, true); + descriptionBuffer[fullSize] = '\0'; // tack on, in case not contained + // parse till first \0 + std::string description(descriptionBuffer); + tree->setKeyValue(propName, description); + delete[] descriptionBuffer; } struct ChunkSize64 // declare ChunkSize64 structure @@ -3226,63 +3813,64 @@ -static XMP_Uns64 parseRF64( LFA_FileRef file, DataSize64Chunk* rf64Sizes ) +static XMP_Uns64 parseRF64(LFA_FileRef file, DataSize64Chunk* rf64Sizes) { - /*XMP_Int64 chunkPos= */ LFA_Tell( file ); - rf64Sizes->chunkId = tree->digest32u( file, "", false ); - std::string ds64ChunkID_ST( fromArgs( "%.4s" , &rf64Sizes->chunkId) ); + XMP_Int64 chunkPos = LFA_Tell(file); + rf64Sizes->chunkId = tree->digest32u(file, "", false); + std::string ds64ChunkID_ST(fromArgs("%.4s", &rf64Sizes->chunkId)); assertMsg("Not a valid RF64 file!", ds64ChunkID_ST == "ds64"); - rf64Sizes->chunkSize = tree->digest32u( file, "", false ); + rf64Sizes->chunkSize = tree->digest32u(file, "", false); XMP_Uns32 bitCnt = 0; - rf64Sizes->riffSize = tree->digest64u( file, "", false ); - rf64Sizes->dataSize = tree->digest64u( file, "", false ); - rf64Sizes->sampleCount = tree->digest64u( file, "", false ); + rf64Sizes->riffSize = tree->digest64u(file, "", false); + rf64Sizes->dataSize = tree->digest64u(file, "", false); + rf64Sizes->sampleCount = tree->digest64u(file, "", false); - rf64Sizes->tableLength = tree->digest32u( file, "", false ); + rf64Sizes->tableLength = tree->digest32u(file, "", false); bitCnt = 28; - - for ( XMP_Uns32 i = 0; i < rf64Sizes->tableLength ; i++ ) + + for (XMP_Uns32 i = 0; i < rf64Sizes->tableLength; i++) { ChunkSize64 tmp; - tmp.chunkId = tree->digest32u( file, "", false ); - tmp.chunkSize = tree->digest64u( file, "", false ); - rf64Sizes->table.push_back( tmp ); - + tmp.chunkId = tree->digest32u(file, "", false); + tmp.chunkSize = tree->digest64u(file, "", false); + rf64Sizes->table.push_back(tmp); + bitCnt += 12; } // is there a rest to skip? XMP_Uns32 rest = rf64Sizes->chunkSize - bitCnt; - if ( rest != 0 ) + if (rest != 0) { - Skip( file, rest ); + Skip(file, rest); } // return correct RIFF size return rf64Sizes->riffSize; } -static XMP_Uns64 getRealSize( bool isOutermost, std::string chunkID, LFA_FileRef file, DataSize64Chunk* sizeChunk) +static XMP_Uns64 getRealSize(bool isOutermost, std::string chunkID, LFA_FileRef file, DataSize64Chunk* sizeChunk) { - if ( isOutermost ) + if (isOutermost) { - return parseRF64( file, sizeChunk ); + return parseRF64(file, sizeChunk); } else { if (chunkID == "data") { return sizeChunk->dataSize; - } else + } + else { // search table - for ( XMP_Uns32 i = 0; i < sizeChunk->tableLength ; i++ ) + for (XMP_Uns32 i = 0; i < sizeChunk->tableLength; i++) { - std::string idString( fromArgs( "%.4s" , &sizeChunk->table[i].chunkId ) ); - if ( idString == chunkID ) + std::string idString(fromArgs("%.4s", &sizeChunk->table[i].chunkId)); + if (idString == chunkID) { return sizeChunk->table[i].chunkSize; } @@ -3293,184 +3881,212 @@ } static void -DumpRIFFChunk ( LFA_FileRef file, XMP_Int64 parentEnd, std::string origChunkPath, bool bigEndian=false, DataSize64Chunk* rf64Sizes = NULL ) +DumpRIFFChunk(LFA_FileRef file, XMP_Int64 parentEnd, std::string origChunkPath, bool bigEndian = false, DataSize64Chunk* rf64Sizes = NULL) { - while ( LFA_Tell(file) < parentEnd ) + while (LFA_Tell(file) < parentEnd) { bool isOutermost = origChunkPath.empty(); - XMP_Int64 chunkPos= LFA_Tell( file ); - XMP_Int64 fileSize= LFA_Measure( file ); + XMP_Int64 chunkPos = LFA_Tell(file); + XMP_Int64 fileSize = LFA_Measure(file); XMP_Int64 fileTail = fileSize - chunkPos; - if ( fileTail < 8 ) + if (fileTail < 8) { tree->pushNode("** unknown bytes **"); - tree->addOffset( file ); - tree->addComment("size: 0x%llX", fileTail ); - Skip( file, fileTail ); // Already read the 8 byte header. + tree->addOffset(file); + tree->addComment("size: 0x%llX", fileTail); + Skip(file, fileTail); // Already read the 8 byte header. tree->popNode(); } else { - XMP_Uns32 tmp1 = tree->digest32u( file, "", true ); - XMP_Uns32 chunkID = GetUns32BE(&tmp1); // flip if necessary for LE systems + XMP_Uns32 tmp = tree->digest32u(file, "", true); + XMP_Uns32 chunkID = GetUns32BE(&tmp); // flip if necessary for LE systems - std::string idString( fromArgs( "%.4s" , &chunkID ) ); + std::string idString(fromArgs("%.4s", &chunkID)); - XMP_Int64 chunkSizeWOHeader = tree->digest32u( file, "", bigEndian ); + XMP_Int64 chunkSizeWOHeader = tree->digest32u(file, "", bigEndian); + XMP_Int64 validRF64Header = chunkSizeWOHeader; XMP_Uns32 chunkType = 0; std::string typeString = ""; // only RIFF and LIST contain subchunks... - bool hasSubChunks = (idString == "RIFF") || (idString == "RF64") ||(idString == "FORM") || (idString == "LIST") || (idString == "APPL"); + bool hasSubChunks = (idString == "RIFF") || (idString == "RF64") || (idString == "FORM") || (idString == "LIST") || (idString == "APPL"); if (hasSubChunks) - { - XMP_Uns32 tmp2 = tree->digest32u( file, "", true ); - chunkType = GetUns32BE(&tmp2); // flip if necessary for LE systems - typeString = fromArgs( "%.4s" , &chunkType ) ; + { + XMP_Uns32 tmp = tree->digest32u(file, "", true); + chunkType = GetUns32BE(&tmp); // flip if necessary for LE systems + typeString = fromArgs("%.4s", &chunkType); } //get inner ID 'type' as in 'listType', 'fileType', ... //XMP_Uns32 chunkType = tree->digest32u( file ); - if ( chunkSizeWOHeader == 0xFFFFFFFF ) //RF64 size for children + if (chunkSizeWOHeader == 0xFFFFFFFF) //RF64 size for children { - chunkSizeWOHeader = getRealSize( isOutermost, idString, file, rf64Sizes ); + + chunkSizeWOHeader = getRealSize(isOutermost, idString, file, rf64Sizes); } - XMP_Int64 chunkSize = chunkSizeWOHeader + 8;// NB: XMPInt64 <- XMPUns32 - //adding size of id and length field itself + XMP_Int64 chunkSize = chunkSizeWOHeader + 8;// NB: XMPInt64 <- XMPUns32 + //adding size of id and length field itself - // calculate size if size field seems broken + // calculate size if size field seems broken if (chunkSize > parentEnd) - chunkSize = parentEnd - chunkPos; - + chunkSize = parentEnd - chunkPos; + + + std::string chunkPath = isOutermost ? (idString) : (origChunkPath + "/" + idString); + - std::string chunkPath = isOutermost ? ( idString ) : (origChunkPath + "/" + idString); - - // check special case of trailing bytes not in a valid RIFF structure - if ( isOutermost && idString != "RIFF"&& idString != "FORM" && idString != "RF64") + if (isOutermost && idString != "RIFF"&& idString != "FORM" && idString != "RF64") { //dump undefined bytes till the end of the file tree->pushNode("** unknown bytes **"); chunkSize = parentEnd - chunkPos; // get size through calculation (and not from size bytes) - tree->addComment("offset 0x%llX, size: 0x%llX",chunkPos, chunkSize ); - Skip( file, chunkSize-8 ); // Already read the 8 byte header. + tree->addComment("offset 0x%llX, size: 0x%llX", chunkPos, chunkSize); + Skip(file, chunkSize - 8); // Already read the 8 byte header. tree->popNode(); - } + } else { - - bool skipper=false; + + bool skipper = false; if (hasSubChunks) - { - if ( isOutermost ) + { + if (isOutermost) { - assertMsg("level-0 chunk must be AVI, AVIX, WAVE, AIFF, AIFC", - ( typeString == "AVI " ) || ( typeString == "AVIX" ) || ( typeString == "WAVE" ) - ||( typeString == "AIFF" ) || ( typeString == "AIFC")); + assertMsg("level-0 chunk must be AVI, AVIX, WAVE, AIFF, AIFC", + (typeString == "AVI ") || (typeString == "AVIX") || (typeString == "WAVE") + || (typeString == "AIFF") || (typeString == "AIFC")); } chunkPath = chunkPath + ":" + typeString; + XMP_Uns64 dsHeaderSize = 0xFFFFFFFF; + if (chunkSize != fileSize && idString == "RF64") + { + XMP_Uns32 tmp = tree->digest32u(file, "", true); + XMP_Uns32 chunkID = GetUns32BE(&tmp); // flip if necessary for LE systems + + std::string dsString(fromArgs("%.4s", &chunkID)); + if (dsString == "ds64") + { + //skip 4 bytes to read size of file in ds64 header + tmp = tree->digest32u(file, "", true); + XMP_Uns64 dsHeader = tree->digest64u(file, "", true); + dsHeaderSize = GetUns64BE(&dsHeader); + } + tree->pushNode(chunkPath); + tree->addComment("offset 0x%llX, size 0x%llX, size(w/o header) 0x%llX", chunkPos, chunkSize, chunkSizeWOHeader); + + tree->setKeyValue("dsChunkSize", fromArgs("0x%llX", dsHeaderSize + 8)); + + } + else + { + tree->pushNode(chunkPath); + tree->addComment("offset 0x%llX, size 0x%llX, size(w/o header) 0x%llX", chunkPos, chunkSize, chunkSizeWOHeader); + + } + tree->setKeyValue("fileSize", fromArgs("0x%llX", fileSize)); + tree->setKeyValue("validRF64Header", fromArgs("0x%llX", validRF64Header)); - tree->pushNode( chunkPath ); - tree->addComment("offset 0x%llX, size 0x%llX, size(w/o header) 0x%llX", chunkPos , chunkSize, chunkSizeWOHeader); - if ( isOutermost && idString == "RF64" ) + if (isOutermost && idString == "RF64") { - tree->pushNode( "RF64/ds64" ); + tree->pushNode("RF64/ds64"); tree->addComment("offset 0x%llX, size 0x%X, size(w/o header) 0x%X", chunkPos + 12, rf64Sizes->chunkSize + 8, rf64Sizes->chunkSize); - tree->setKeyValue( "riffSize", fromArgs( "0x%llX" , rf64Sizes->riffSize )) ; - tree->setKeyValue( "dataSize", fromArgs( "0x%llX" , rf64Sizes->dataSize )) ; - tree->setKeyValue( "sampleCount", fromArgs( "0x%llX" , rf64Sizes->sampleCount )) ; - tree->setKeyValue( "tableLength", fromArgs( "0x%X" , rf64Sizes->tableLength )) ; + tree->setKeyValue("riffSize", fromArgs("0x%llX", rf64Sizes->riffSize)); + tree->setKeyValue("dataSize", fromArgs("0x%llX", rf64Sizes->dataSize)); + tree->setKeyValue("sampleCount", fromArgs("0x%llX", rf64Sizes->sampleCount)); + tree->setKeyValue("tableLength", fromArgs("0x%X", rf64Sizes->tableLength)); tree->popNode(); - DumpRIFFChunk( file, LFA_Tell(file) + chunkSize - 12 - rf64Sizes->chunkSize - 8 /* filesize + riff chunk size - riff header(12) - rf64 header(8) */, chunkPath, bigEndian, rf64Sizes ); // recurse! + DumpRIFFChunk(file, LFA_Tell(file) + chunkSize - 12 - rf64Sizes->chunkSize - 8 /* filesize + riff chunk size - riff header(12) - rf64 header(8) */, chunkPath, bigEndian, rf64Sizes); // recurse! } - if ( ( idString + ":" + typeString == "LIST:INFO" ) || - ( idString + ":" + typeString == "LIST:Tdat" ) || - ( idString + ":" + typeString == "RIFF:AVI " ) || - ( idString + ":" + typeString == "RIFF:AVIX" ) || - ( idString + ":" + typeString == "RIFF:WAVE" ) || - ( idString + ":" + typeString == "FORM:AIFF" ) || - ( idString + ":" + typeString == "FORM:AIFC" ) || - ( idString + ":" + typeString == "LIST:hdrl" ) || - ( idString + ":" + typeString == "LIST:strl" ) || - ( idString + ":" + typeString == "LIST:movi" ) - ) - { - DumpRIFFChunk( file, LFA_Tell(file) + chunkSize - 12, chunkPath, bigEndian, rf64Sizes ); // recurse! + if ((idString + ":" + typeString == "LIST:INFO") || + (idString + ":" + typeString == "LIST:Tdat") || + (idString + ":" + typeString == "RIFF:AVI ") || + (idString + ":" + typeString == "RIFF:AVIX") || + (idString + ":" + typeString == "RIFF:WAVE") || + (idString + ":" + typeString == "FORM:AIFF") || + (idString + ":" + typeString == "FORM:AIFC") || + (idString + ":" + typeString == "LIST:hdrl") || + (idString + ":" + typeString == "LIST:strl") || + (idString + ":" + typeString == "LIST:movi") + ) + { + DumpRIFFChunk(file, LFA_Tell(file) + chunkSize - 12, chunkPath, bigEndian, rf64Sizes); // recurse! } else { - Skip( file, chunkSize - 12 ); // skip it ! + Skip(file, chunkSize - 12); // skip it ! } tree->popNode(); } else if (idString.length() == 4) // check that we got a valid idString - { + { // now that LIST:movi gets dumped, // skip some very frequent, irrelevant chunks, // otherwise the dump becomes unusably long... - std::string firstTwo = idString.substr(0,2); - std::string secondTwo = idString.substr(2,2); - if ( secondTwo == "db" || secondTwo == "dc" || secondTwo == "wb" ) // nb: _could_ colidde, requiring additional numeric test + std::string firstTwo = idString.substr(0, 2); + std::string secondTwo = idString.substr(2, 2); + if (secondTwo == "db" || secondTwo == "dc" || secondTwo == "wb") // nb: _could_ colidde, requiring additional numeric test { - skipper = true; + skipper = true; } - - if ( ! skipper ) + + if (!skipper) { - tree->pushNode( chunkPath ); + tree->pushNode(chunkPath); //Log::info( chunkPath ); - tree->addComment("offset 0x%llX, size 0x%llX, size(w/o header) 0x%llX", chunkPos , chunkSize, chunkSizeWOHeader); + tree->addComment("offset 0x%llX, size 0x%llX, size(w/o header) 0x%llX", chunkPos, chunkSize, chunkSizeWOHeader); } // tackle chunks of interest ////////////////////////////////////////////// bool isListInfo = - ( (origChunkPath == "RIFF:WAVE/LIST:INFO" || origChunkPath == "RIFF:AVI /LIST:INFO" ) - && idString.at(0) == 'I' ); // so far all mapping relevant props begin with "I" + ((origChunkPath == "RIFF:WAVE/LIST:INFO" || origChunkPath == "RIFF:AVI /LIST:INFO") + && idString.at(0) == 'I'); // so far all mapping relevant props begin with "I" bool isListTdat = (origChunkPath == "RIFF:WAVE/LIST:Tdat" || origChunkPath == "RIFF:AVI /LIST:Tdat") - && idString.at(0) != 'J' ; // just exclude JUNK/Q + && idString.at(0) != 'J'; // just exclude JUNK/Q - bool isDispChunk = - ( ( origChunkPath == "RIFF:WAVE" || origChunkPath == "RIFF:AVI ") - && idString == "DISP" ); - - bool isBextChunk = - ( ( origChunkPath == "RIFF:WAVE" || origChunkPath == "RIFF:AVI ") - && idString == "bext" ); - - bool isIXMLChunk = - ( ( origChunkPath == "RIFF:WAVE" ) - && idString == "iXML" ); + bool isDispChunk = + ((origChunkPath == "RIFF:WAVE" || origChunkPath == "RIFF:AVI ") + && idString == "DISP"); + + bool isBextChunk = + ((origChunkPath == "RIFF:WAVE" || origChunkPath == "RIFF:AVI ") + && idString == "bext"); + + bool isIXMLChunk = + ((origChunkPath == "RIFF:WAVE") + && idString == "iXML"); bool isXMPchunk = false; //assume beforehand - if ( idString == "_PMX" ) + if (idString == "_PMX") { // detour first, to detect xmp in wrong places - assertMsg( "XMP packet found in wrong place!", - ( origChunkPath == "RIFF:WAVE" || "RIFF:AVI" || "RIFF:AVIX" ) ); //be very linient here. + assertMsg("XMP packet found in wrong place!", + (origChunkPath == "RIFF:WAVE" || "RIFF:AVI" || "RIFF:AVIX")); //be very linient here. isXMPchunk = true; } - bool isIDITChunk = - ( ( origChunkPath == "RIFF:AVI/LIST:hdrl" || origChunkPath == "RIFF:AVI /LIST:hdrl" ) - && idString == "IDIT" ); + bool isIDITChunk = + ((origChunkPath == "RIFF:AVI/LIST:hdrl" || origChunkPath == "RIFF:AVI /LIST:hdrl") + && idString == "IDIT"); // deal with chunks of interest ///////////////////////////////////////////// // a little prelude for disp chunk - if ( isDispChunk ) - { + if (isDispChunk) + { XMP_Uns32 dispChunkType = LFA_ReadUns32_LE(file); // only dispChunks starting with a 0x0001 are of interest to us. // others do exist and are not an error - if ( dispChunkType != 0x0001 ) + if (dispChunkType != 0x0001) isDispChunk = false; chunkSize -= 4; @@ -3481,150 +4097,151 @@ // dump that string: std::string value; - if ( chunkSize > 8 ) // aka skip for empty chunks + if (chunkSize > 8) // aka skip for empty chunks { // first check if the string is zero terminated - LFA_Seek( file , chunkSize - 8 - 1, SEEK_CUR ); // jump to last char - bool zeroTerm = (LFA_ReadUns8( file ) == 0); - LFA_Seek( file , -(chunkSize - 8 ), SEEK_CUR ); //jump back - // some strings are zero-terminated (so despite initial length they are "c-strings" - // others are not ( "pascal strings" if you will. - // must cater to both: zero-terminated-ness should not affect resulting value. + LFA_Seek(file, chunkSize - 8 - 1, SEEK_CUR); // jump to last char + bool zeroTerm = (LFA_ReadUns8(file) == 0); + LFA_Seek(file, -(chunkSize - 8), SEEK_CUR); //jump back + // some strings are zero-terminated (so despite initial length they are "c-strings" + // others are not ( "pascal strings" if you will. + // must cater to both: zero-terminated-ness should not affect resulting value. if (zeroTerm) { // read string without zero (last char) - value = tree->digestString( file, "" , chunkSize - 8 - 1, false ); + value = tree->digestString(file, "", chunkSize - 8 - 1, false); tree->addComment(" zero terminated"); - LFA_ReadUns8( file ); // skip the zero - } + LFA_ReadUns8(file); // skip the zero + } else { // read string including last char - value = tree->digestString( file, "" , chunkSize - 8 , false ); - tree->addComment(" not zero terminated"); + value = tree->digestString(file, "", chunkSize - 8, false); + tree->addComment(" not zero terminated"); } - tree->changeValue( value ); + tree->changeValue(value); } - tree->changeValue( value ); + tree->changeValue(value); } - else if ( isXMPchunk ) + else if (isXMPchunk) { tree->pushNode("XMP packet"); - tree->addOffset( file ); - tree->addComment("packet size: 0x%llX", chunkSize - 8 ); - Skip( file, chunkSize - 8 ); - tree->addComment("packet end: 0x%llX", LFA_Tell( file ) ); - + tree->addOffset(file); + tree->addComment("packet size: 0x%llX", chunkSize - 8); + Skip(file, chunkSize - 8); + tree->addComment("packet end: 0x%llX", LFA_Tell(file)); + tree->popNode(); } - else if ( isBextChunk ) + else if (isBextChunk) { tree->pushNode("bext chunk"); - tree->addOffset( file ); - tree->addComment("packet size: 0x%llX", chunkSize - 8 ); + tree->addOffset(file); + tree->addComment("packet size: 0x%llX", chunkSize - 8); // I assume that the minimum BEXT chunk size is 602: // > 8 + ( 256+32+32+10+8+4+4+2+64+190+0 ) // ans = 610 const XMP_Int64 MIN_BEXT_SIZE = 610; - assertMsg("minimum Berx Chunk Size", chunkSize >= MIN_BEXT_SIZE ); + assertMsg("minimum Berx Chunk Size", chunkSize >= MIN_BEXT_SIZE); XMP_Int64 BEXT_CodingHistorySize = chunkSize - MIN_BEXT_SIZE; - setFixedBEXTField ( file, chunkPath+".Description" , 256 ); - setFixedBEXTField ( file, chunkPath+".Originator" , 32 ); - setFixedBEXTField ( file, chunkPath+".OriginatorReference" , 32 ); - setFixedBEXTField ( file, chunkPath+".OriginationDate" , 10 ); - setFixedBEXTField ( file, chunkPath+".OriginationTime" , 8 ); - - tree->digest32u( file, chunkPath+".TimeReferenceLow", false, true ); // DWORD == 32 Bit - tree->digest32u( file, chunkPath+".TimeReferenceHigh", false, true ); // DWORD == 32 Bit + setFixedBEXTField(file, chunkPath + ".Description", 256); + setFixedBEXTField(file, chunkPath + ".Originator", 32); + setFixedBEXTField(file, chunkPath + ".OriginatorReference", 32); + setFixedBEXTField(file, chunkPath + ".OriginationDate", 10); + setFixedBEXTField(file, chunkPath + ".OriginationTime", 8); + + tree->digest32u(file, chunkPath + ".TimeReferenceLow", false, true); // DWORD == 32 Bit + tree->digest32u(file, chunkPath + ".TimeReferenceHigh", false, true); // DWORD == 32 Bit + + tree->digest16u(file, chunkPath + ".Version", false, true); - tree->digest16u( file, chunkPath+".Version", false, true ); - // UMID has 64 bytes: - tree->digestString(file, chunkPath+".UMID",64); + tree->digestString(file, chunkPath + ".UMID", 64); //tree->digest32u( file, chunkPath+".UMID_0-4", false, true ); //tree->setKeyValue( "UMID_5-59" ); //Skip( file, 64 - 4 - 4 ); //tree->digest32u( file, chunkPath+".UMID_60-63", false, true ); - tree->setKeyValue( chunkPath+".Reserved" ); - Skip( file, 190 ); - - if ( BEXT_CodingHistorySize ) + tree->setKeyValue(chunkPath + ".Reserved"); + Skip(file, 190); + + if (BEXT_CodingHistorySize) { - setFixedBEXTField ( file, chunkPath+".CodingHistory" , BEXT_CodingHistorySize ); - + setFixedBEXTField(file, chunkPath + ".CodingHistory", BEXT_CodingHistorySize); + //tree->setKeyValue( chunkPath+".CodingHistory" ); // not bothering details. - tree->addComment( "( 0x%llx bytes ) ", BEXT_CodingHistorySize ); + tree->addComment("( 0x%llx bytes ) ", BEXT_CodingHistorySize); //Skip( file, BEXT_CodingHistorySize ); } - tree->addComment("packet end: 0x%llX", LFA_Tell( file ) ); + tree->addComment("packet end: 0x%llX", LFA_Tell(file)); tree->popNode(); - } else if ( isIXMLChunk ) { + } + else if (isIXMLChunk) { tree->pushNode("iXML packet"); - tree->addOffset( file ); - tree->addComment("packet size: 0x%llX", chunkSize - 8 ); + tree->addOffset(file); + tree->addComment("packet size: 0x%llX", chunkSize - 8); //Skip( file, chunkSize - 8 ); - size_t sizeofIXMLValue = chunkSize-8; - char* descriptionBuffer = new char[ sizeofIXMLValue + 2 ]; - LFA_Read( file, descriptionBuffer, sizeofIXMLValue, true ); - descriptionBuffer[sizeofIXMLValue]='\0'; // tack on, in case not contained - // parse till first \0 - std::string description( descriptionBuffer ); + size_t sizeofIXMLValue = chunkSize - 8; + char* descriptionBuffer = new char[sizeofIXMLValue + 2]; + LFA_Read(file, descriptionBuffer, sizeofIXMLValue, true); + descriptionBuffer[sizeofIXMLValue] = '\0'; // tack on, in case not contained + // parse till first \0 + std::string description(descriptionBuffer); // Dumping the iXML chunk. Needed for testing // Add iXML chunk as a node to tree - tree->setKeyValue( chunkPath+".ValueOfIXMLChunk", description ); - + tree->setKeyValue(chunkPath + ".ValueOfIXMLChunk", description); + delete[] descriptionBuffer; - tree->addComment("packet end: 0x%llX", LFA_Tell( file ) ); + tree->addComment("packet end: 0x%llX", LFA_Tell(file)); tree->popNode(); - + } else { - Skip( file, chunkSize - 8 ); // skip remainder of chunk ( id, length already digested ) - assertMsg( fromArgs( "inner chunk size too big, curPos:0x%llx, parentEnd:0x%llx", - LFA_Tell(file), - parentEnd ), - LFA_Tell(file) <= parentEnd ); - } - - if ( ! skipper ) + Skip(file, chunkSize - 8); // skip remainder of chunk ( id, length already digested ) + assertMsg(fromArgs("inner chunk size too big, curPos:0x%llx, parentEnd:0x%llx", + LFA_Tell(file), + parentEnd), + LFA_Tell(file) <= parentEnd); + } + + if (!skipper) tree->popNode(); } else { //dump undefined bytes in LIST tree->pushNode("** unknown bytes **"); - tree->addOffset( file ); - tree->addComment("size: 0x%llX", chunkSize ); - Skip( file, chunkSize - 8 ); + tree->addOffset(file); + tree->addComment("size: 0x%llX", chunkSize); + Skip(file, chunkSize - 8); tree->popNode(); } - if ( LFA_Tell(file) % 2 == 1 ) // if odd file position, add pad byte. + if (LFA_Tell(file) % 2 == 1) // if odd file position, add pad byte. { if (LFA_Tell(file) == parentEnd) { // last pad byte is missing tree->addComment(" (pad byte missing [bug 1521093])"); - } + } else { - XMP_Uns8 padByte = LFA_ReadUns8( file ); + XMP_Uns8 padByte = LFA_ReadUns8(file); if (!skipper) { - if ( 0 != padByte ) + if (0 != padByte) tree->addComment(" (non-zero pad byte!)"); - else + else tree->addComment(" (pad byte)"); } } @@ -3633,37 +4250,37 @@ } } // while - + } // DumpRIFFChunk -// ================================================================================================= + // ================================================================================================= static void -DumpRIFF ( LFA_FileRef file, XMP_Int64 fileLen ) +DumpRIFF(LFA_FileRef file, XMP_Int64 fileLen) { DataSize64Chunk rf64Sizes; - DumpRIFFChunk ( file, fileLen, "",false, &rf64Sizes ); + DumpRIFFChunk(file, fileLen, "", false, &rf64Sizes); } static void -DumpAIFF ( LFA_FileRef file, XMP_Int64 fileLen ) +DumpAIFF(LFA_FileRef file, XMP_Int64 fileLen) { - DumpRIFFChunk ( file, fileLen, "", true ); + DumpRIFFChunk(file, fileLen, "", true); } // ================================================================================================= static XMP_Uns32 crcTable[256]; static bool crcTableInited = false; -static XMP_Uns32 ComputeCRCforPNG ( LFA_FileRef file, XMP_Uns32 crcOffset, XMP_Uns32 crcLen ) +static XMP_Uns32 ComputeCRCforPNG(LFA_FileRef file, XMP_Uns32 crcOffset, XMP_Uns32 crcLen) { - if ( ! crcTableInited ) { - for ( int n = 0; n < 256; ++n ) { + if (!crcTableInited) { + for (int n = 0; n < 256; ++n) { XMP_Uns32 c = n; - for ( int k = 0; k < 8; ++k ) { + for (int k = 0; k < 8; ++k) { XMP_Uns32 lowBit = c & 1; c = c >> 1; - if ( lowBit != 0 ) c = c ^ 0xEDB88320; + if (lowBit != 0) c = c ^ 0xEDB88320; } crcTable[n] = c; } @@ -3671,11 +4288,11 @@ } XMP_Uns32 crc = 0xFFFFFFFF; - CaptureFileData ( file, crcOffset, crcLen ); + CaptureFileData(file, crcOffset, crcLen); - for ( XMP_Uns32 i = 0; i < crcLen; ++i ) { // ! The CRC includes the chunk type and data. + for (XMP_Uns32 i = 0; i < crcLen; ++i) { // ! The CRC includes the chunk type and data. XMP_Uns8 byte = sDataPtr[i]; - XMP_Uns8 index = (XMP_Uns8) ((crc ^ byte) & 0xFF); + XMP_Uns8 index = (XMP_Uns8)((crc ^ byte) & 0xFF); crc = crcTable[index] ^ (crc >> 8); } @@ -3683,14 +4300,14 @@ } // ComputeCRCforPNG -// ================================================================================================= + // ================================================================================================= static const XMP_Uns32 kPNG_iTXt = 0x69545874; static const XMP_Uns32 kPNG_tEXt = 0x74455874; static const XMP_Uns32 kPNG_zTXt = 0x7A545874; static XMP_Uns32 -DumpPNGChunk ( LFA_FileRef file, XMP_Uns32 pngLen, XMP_Uns32 chunkOffset ) +DumpPNGChunk(LFA_FileRef file, XMP_Uns32 pngLen, XMP_Uns32 chunkOffset) { // A PNG chunk contains: // A big endian UInt32 length for the data portion. Zero is OK. @@ -3713,52 +4330,53 @@ XMP_Uns32 chunkType; XMP_Uns32 chunkCRC; - if ( (pngLen - chunkOffset) < 12 ) { - tree->addComment ( "** Unexpected end of PNG file, %ul bytes remaining **", (pngLen - chunkOffset) ); + if ((pngLen - chunkOffset) < 12) { + tree->addComment("** Unexpected end of PNG file, %ul bytes remaining **", (pngLen - chunkOffset)); return (pngLen - chunkOffset); } - LFA_Seek ( file, chunkOffset, SEEK_SET ); - LFA_Read ( file, &chunkLen, 4, true ); - chunkLen = GetUns32BE (&chunkLen); + LFA_Seek(file, chunkOffset, SEEK_SET); + LFA_Read(file, &chunkLen, 4, true); + chunkLen = GetUns32BE(&chunkLen); - if ( chunkLen > (pngLen - chunkOffset) ) { - tree->addComment ( "** No room for PNG chunk, need %u, have %u **", chunkLen, pngLen-chunkOffset ); + if (chunkLen > (pngLen - chunkOffset)) { + tree->addComment("** No room for PNG chunk, need %u, have %u **", chunkLen, pngLen - chunkOffset); return (pngLen - chunkOffset); // ! Not chunkLen, might be bad and cause wrap-around. } - LFA_Read ( file, &chunkType, 4, true); // After read, memory is in file order. + LFA_Read(file, &chunkType, 4, true); // After read, memory is in file order. - LFA_Seek ( file, (chunkOffset + 8 + chunkLen) , SEEK_SET ); - LFA_Read ( file, &chunkCRC, 4, true); - chunkCRC = GetUns32BE (&chunkCRC); + LFA_Seek(file, (chunkOffset + 8 + chunkLen), SEEK_SET); + LFA_Read(file, &chunkCRC, 4, true); + chunkCRC = GetUns32BE(&chunkCRC); - tree->addComment ( " '%.4s', offset %u (0x%X), size %d, CRC 0x%.8X", - &chunkType, chunkOffset, chunkOffset, chunkLen, chunkCRC ); + tree->addComment(" '%.4s', offset %u (0x%X), size %d, CRC 0x%.8X", + &chunkType, chunkOffset, chunkOffset, chunkLen, chunkCRC); - XMP_Uns32 newCRC = ComputeCRCforPNG ( file, (chunkOffset + 4), (chunkLen + 4) ); + XMP_Uns32 newCRC = ComputeCRCforPNG(file, (chunkOffset + 4), (chunkLen + 4)); - if ( chunkCRC != newCRC ) tree->addComment ( "** CRC should be 0x%.8X **", newCRC ); + if (chunkCRC != newCRC) tree->addComment("** CRC should be 0x%.8X **", newCRC); - chunkType = GetUns32BE (&chunkType); // Reorder the type to compare with constants. + chunkType = GetUns32BE(&chunkType); // Reorder the type to compare with constants. - if ( (chunkType == kPNG_iTXt) || (chunkType == kPNG_tEXt) || (chunkType == kPNG_zTXt) ) { + if ((chunkType == kPNG_iTXt) || (chunkType == kPNG_tEXt) || (chunkType == kPNG_zTXt)) { - CaptureFileData ( file, (chunkOffset + 8), chunkLen ); + CaptureFileData(file, (chunkOffset + 8), chunkLen); XMP_Uns8 * keywordPtr = sDataPtr; - size_t keywordLen = strlen ((char*)keywordPtr); + size_t keywordLen = strlen((char*)keywordPtr); - PrintOnlyASCII_8 ( keywordPtr, keywordLen); + PrintOnlyASCII_8(keywordPtr, keywordLen); - if ( (chunkType == kPNG_iTXt) && (keywordLen == 17) && CheckBytes (keywordPtr, "XML:com.adobe.xmp", 18) ) { + if ((chunkType == kPNG_iTXt) && (keywordLen == 17) && CheckBytes(keywordPtr, "XML:com.adobe.xmp", 18)) { - if ( sXMPPtr != 0 ) { - tree->addComment ( " ** Redundant XMP **" ); - } else { - CaptureXMP ( (keywordPtr + 22), (chunkLen - 22), (chunkOffset + 8 + 22) ); - XMP_Uns32 otherFlags = GetUns32BE (keywordPtr+18); - if ( otherFlags != 0 ) tree->addComment ( "** bad flags %.8X **", otherFlags ); + if (sXMPPtr != 0) { + tree->addComment(" ** Redundant XMP **"); + } + else { + CaptureXMP((keywordPtr + 22), (chunkLen - 22), (chunkOffset + 8 + 22)); + XMP_Uns32 otherFlags = GetUns32BE(keywordPtr + 18); + if (otherFlags != 0) tree->addComment("** bad flags %.8X **", otherFlags); } } @@ -3769,30 +4387,30 @@ } // DumpPNGChunk -// ================================================================================================= + // ================================================================================================= static void -DumpPS ( LFA_FileRef file, XMP_Uns32 /*fileLen*/ ) +DumpPS(LFA_FileRef file, XMP_Uns32 fileLen) { XMP_Int32 psOffset; size_t psLength; - LFA_Seek ( file, 4, SEEK_SET ); // skip fileheader bytes - LFA_Read ( file, &psOffset, 4, true ); - LFA_Read ( file, &psLength, 4, true ); + LFA_Seek(file, 4, SEEK_SET); // skip fileheader bytes + LFA_Read(file, &psOffset, 4, true); + LFA_Read(file, &psLength, 4, true); tree->addComment(" psOffset: %d, psLength: %d", psOffset, psLength); // jump to psOffset Skip(file, (psOffset - 12)); - + // get the header (everything till first % - - XMP_Int64 offset = LFA_Tell(file); + + XMP_Int64 offset = LFA_Tell(file); std::string key, value; char byte = LFA_GetChar(file); bool eof = false; - while ( !eof ) + while (!eof) { key.clear(); key += byte; // add the first % @@ -3821,33 +4439,33 @@ } } tree->pushNode(key); - tree->addOffset( file ); - + tree->addOffset(file); + //for now only store value for header - if ( key =="%!PS-Adobe-3.0" ) + if (key == "%!PS-Adobe-3.0") { tree->changeValue(value); } - - tree->addComment("offset: %d", offset ); - tree->addComment("size: 0x%llX", LFA_Tell(file)-offset ); + + tree->addComment("offset: %d", offset); + tree->addComment("size: 0x%llX", LFA_Tell(file) - offset); tree->popNode(); - - offset = LFA_Tell(file); + + offset = LFA_Tell(file); } // Now just get everything else and store all keys that start with % // get the key // start of the PostScript DSC header comment - + /*XMP_Uns8 buffer [11]; LFA_Read ( file, &buffer, sizeof(buffer), true ); if (!CheckBytes( buffer, "%!PS-Adobe-", 11)) { - tree->comment ( "** Invalid PS, unknown PS file tag." ); - return; + tree->comment ( "** Invalid PS, unknown PS file tag." ); + return; } // Check the PostScript DSC major version number. @@ -3855,37 +4473,37 @@ LFA_Read ( file, &byte, sizeof(byte), true ); psMajorVer = 0; - while ( IsNumeric( byte ) ) + while ( IsNumeric( byte ) ) { - psMajorVer = (psMajorVer * 10) + (byte - '0'); - if ( psMajorVer > 1000 ) { - tree->comment ( "** Invalid PS, Overflow." ); - return; - }; // Overflow. - LFA_Read ( file, &byte, sizeof(byte), true ); + psMajorVer = (psMajorVer * 10) + (byte - '0'); + if ( psMajorVer > 1000 ) { + tree->comment ( "** Invalid PS, Overflow." ); + return; + }; // Overflow. + LFA_Read ( file, &byte, sizeof(byte), true ); } if ( psMajorVer < 3 ){ - tree->comment ( "** Invalid PS, The version must be at least 3.0." ); - return; + tree->comment ( "** Invalid PS, The version must be at least 3.0." ); + return; }; // The version must be at least 3.0. if ( byte != '.' ){ - tree->comment ( "** Invalid PS, No minor number" ); - return; + tree->comment ( "** Invalid PS, No minor number" ); + return; }; // No minor number. LFA_Read ( file, &byte, sizeof(byte), true ); // Check the PostScript DSC minor version number. psMinorVer = 0; - while ( IsNumeric( byte ) ) + while ( IsNumeric( byte ) ) { - psMinorVer = (psMinorVer * 10) + (byte - '0'); - if ( psMinorVer > 1000 ) { - tree->comment ( "** Invalid PS, Overflow." ); - return; - }; // Overflow. - LFA_Read ( file, &byte, sizeof(byte), true ); + psMinorVer = (psMinorVer * 10) + (byte - '0'); + if ( psMinorVer > 1000 ) { + tree->comment ( "** Invalid PS, Overflow." ); + return; + }; // Overflow. + LFA_Read ( file, &byte, sizeof(byte), true ); } tree->addComment(" psMajor Version: %d, psMinor Version: %d", psMajorVer, psMinorVer);*/ @@ -3894,25 +4512,25 @@ // ================================================================================================= static void -DumpPNG ( LFA_FileRef file, XMP_Uns32 pngLen ) +DumpPNG(LFA_FileRef file, XMP_Uns32 pngLen) { // A PNG file contains an 8 byte signature followed by a sequence of chunks. XMP_Uns32 chunkOffset = 8; - while ( chunkOffset < pngLen ) { - XMP_Uns32 chunkLen = DumpPNGChunk ( file, pngLen, chunkOffset ); + while (chunkOffset < pngLen) { + XMP_Uns32 chunkLen = DumpPNGChunk(file, pngLen, chunkOffset); chunkOffset += chunkLen; } - if ( sXMPPtr != 0 ) DumpXMP ( "PNG XMP 'iTXt' chunk" ); + if (sXMPPtr != 0) DumpXMP("PNG XMP 'iTXt' chunk"); } // DumpPNG -// ================================================================================================= + // ================================================================================================= static void -DumpInDesign (LFA_FileRef file, XMP_Uns32 inddLen) +DumpInDesign(LFA_FileRef file, XMP_Uns32 inddLen) { InDesignMasterPage masters[2]; size_t dbPages; @@ -3920,18 +4538,19 @@ // FIgure out which master page to use. - LFA_Seek (file, 0, SEEK_SET); - LFA_Read ( file, &masters, sizeof(masters), true); + LFA_Seek(file, 0, SEEK_SET); + LFA_Read(file, &masters, sizeof(masters), true); - XMP_Uns64 seq0 = GetUns64LE ((XMP_Uns8 *) &masters[0].fSequenceNumber); - XMP_Uns64 seq1 = GetUns64LE ((XMP_Uns8 *) &masters[1].fSequenceNumber); + XMP_Uns64 seq0 = GetUns64LE((XMP_Uns8 *)&masters[0].fSequenceNumber); + XMP_Uns64 seq1 = GetUns64LE((XMP_Uns8 *)&masters[1].fSequenceNumber); if (seq0 > seq1) { - dbPages = GetUns32LE ((XMP_Uns8 *) &masters[0].fFilePages); + dbPages = GetUns32LE((XMP_Uns8 *)&masters[0].fFilePages); cobjEndian = masters[0].fObjectStreamEndian; tree->addComment(" Using master page 0"); - } else { - dbPages = GetUns32LE ((XMP_Uns8 *) &masters[1].fFilePages); + } + else { + dbPages = GetUns32LE((XMP_Uns8 *)&masters[1].fFilePages); cobjEndian = masters[1].fObjectStreamEndian; tree->addComment(" Using master page 1"); } @@ -3950,20 +4569,20 @@ InDesignContigObjMarker cobjHead; - LFA_Seek (file, cobjPos, SEEK_SET); - LFA_Read ( file, &cobjHead, sizeof(cobjHead), true); + LFA_Seek(file, cobjPos, SEEK_SET); + LFA_Read(file, &cobjHead, sizeof(cobjHead), true); - if (! CheckBytes (&cobjHead.fGUID, kINDDContigObjHeaderGUID, kInDesignGUIDSize)) { + if (!CheckBytes(&cobjHead.fGUID, kINDDContigObjHeaderGUID, kInDesignGUIDSize)) { // No Contiguous Object header. Could be in zero padding for the last page. - XMP_Uns8 fileTail [kINDD_PageSize]; + XMP_Uns8 fileTail[kINDD_PageSize]; size_t tailLen = inddLen - cobjPos; bool endOK = (tailLen < kINDD_PageSize); if (endOK) { - LFA_Seek ( file, cobjPos, SEEK_SET ); - LFA_Read ( file, fileTail, sizeof(fileTail), true); + LFA_Seek(file, cobjPos, SEEK_SET); + LFA_Read(file, fileTail, sizeof(fileTail), true); for (size_t i = 0; i < tailLen; ++i) { if (fileTail[i] != 0) { endOK = false; @@ -3978,10 +4597,10 @@ } - cobjHead.fObjectUID = GetUns32LE (&cobjHead.fObjectUID); - cobjHead.fObjectClassID = GetUns32LE (&cobjHead.fObjectClassID); - cobjHead.fStreamLength = GetUns32LE (&cobjHead.fStreamLength); - cobjHead.fChecksum = GetUns32LE (&cobjHead.fChecksum); + cobjHead.fObjectUID = GetUns32LE(&cobjHead.fObjectUID); + cobjHead.fObjectClassID = GetUns32LE(&cobjHead.fObjectClassID); + cobjHead.fStreamLength = GetUns32LE(&cobjHead.fStreamLength); + cobjHead.fChecksum = GetUns32LE(&cobjHead.fChecksum); cobjLen = cobjHead.fStreamLength + (2 * sizeof(InDesignContigObjMarker)); @@ -3991,63 +4610,65 @@ if ((cobjHead.fObjectClassID & 0x40000000) == 0) tree->addComment("read only"); XMP_Uns32 xmpLen; - LFA_Read ( file, &xmpLen, 4, true); + LFA_Read(file, &xmpLen, 4, true); if (bigEndian) { - xmpLen = GetUns32BE (&xmpLen); - } else { - xmpLen = GetUns32LE (&xmpLen); + xmpLen = GetUns32BE(&xmpLen); + } + else { + xmpLen = GetUns32LE(&xmpLen); } XMP_Uns8 xmpStart[16]; // Enough for " (4+16)) && ((xmpLen+4) == cobjHead.fStreamLength) && - CheckBytes (xmpStart, " (4 + 16)) && ((xmpLen + 4) == cobjHead.fStreamLength) && + CheckBytes(xmpStart, "addComment("** redundant XMP **"); - } else { - tree->addComment("XMP"); - CaptureXMPF (file, (cobjPos + sizeof(InDesignContigObjMarker) + 4), xmpLen); - } + if (sXMPPtr != 0) { + tree->addComment("** redundant XMP **"); + } + else { + tree->addComment("XMP"); + CaptureXMPF(file, (cobjPos + sizeof(InDesignContigObjMarker) + 4), xmpLen); + } } } - if (sXMPPtr != 0) DumpXMP ("InDesign XMP Contiguous Object"); + if (sXMPPtr != 0) DumpXMP("InDesign XMP Contiguous Object"); } // DumpInDesign -// ================================================================================================= + // ================================================================================================= static void -DumpSVGTag ( std::string basePath, XML_NodePtr currentNode ) +DumpSVGTag(std::string basePath, XML_NodePtr currentNode) { - if ( currentNode ) + if (currentNode) { - tree->pushNode ( basePath + currentNode->name ); + tree->pushNode(basePath + currentNode->name); // Iterating over all XML children. XML_NodeVector currNodeVector = currentNode->content; - for ( XML_NodeVector::size_type i = 0; i < currNodeVector.size ( ); i++ ) + for (size_t i = 0; i < currNodeVector.size(); i++) { // Dump all children who are element nodes. - if ( currNodeVector[i]->kind == kElemNode ) - DumpSVGTag ( basePath + currentNode->name + "/", currNodeVector[i] ); + if (currNodeVector[i]->kind == kElemNode) + DumpSVGTag(basePath + currentNode->name + "/", currNodeVector[i]); // Extract the value from datanodes and put in TagMap if it's not yet available. - if ( currNodeVector[i]->kind == kCDataNode && tree->getValue ( basePath + currentNode->name ) == "" ) - tree->updateKeyValue ( basePath + currentNode->name, currNodeVector[i]->value ); + if (currNodeVector[i]->kind == kCDataNode && tree->getValue(basePath + currentNode->name) == "") + tree->updateKeyValue(basePath + currentNode->name, currNodeVector[i]->value); } } } // DumpSVGTag -// ================================================================================================= + // ================================================================================================= static void -DumpSVG ( LFA_FileRef file, XMP_Uns32 svgLen ) +DumpSVG(LFA_FileRef file, XMP_Uns32 svgLen) { // SVG is an XML based format.We consider any file as SVG file if the given file contains a SVG tag. // Hence CheckFileFormat looks for presence of " // - ExpatAdapter * pExpatAdapter = XMP_NewExpatAdapter ( false ); + ExpatAdapter * pExpatAdapter = XMP_NewExpatAdapter(false); - if ( pExpatAdapter == 0 ) + if (pExpatAdapter == 0) { - tree->comment ( "ExpatAdapter initialization failed. Cann't parse SVG file." ); + tree->comment("ExpatAdapter initialization failed. Cann't parse SVG file."); return; } // Allocating big enough memory on heap to read file contents. XMP_Uns8 *fileContent = new XMP_Uns8[svgLen + 1]; - memset ( fileContent, 0, (svgLen + 1)*sizeof ( XMP_Uns8 ) ); + memset(fileContent, 0, (svgLen + 1) * sizeof(XMP_Uns8)); // Reading total file in buffer (fileContent) - LFA_Seek ( file, 0, SEEK_SET ); - LFA_Read ( file, fileContent, svgLen + 1, false ); + LFA_Seek(file, 0, SEEK_SET); + LFA_Read(file, fileContent, svgLen + 1, false); // Parsing the file with ExpatAdapter - pExpatAdapter->ParseBuffer ( fileContent, svgLen + 1, false /* not the end */ ); + pExpatAdapter->ParseBuffer(fileContent, svgLen + 1, false /* not the end */); // Finding element and adding to TagMap tree. - XML_NodePtr svgNode = pExpatAdapter->tree.GetNamedElement ( "http://www.w3.org/2000/svg", "svg" ); - DumpSVGTag ( "", svgNode ); + XML_NodePtr svgNode = pExpatAdapter->tree.GetNamedElement("http://www.w3.org/2000/svg", "svg"); + DumpSVGTag("", svgNode); // De-allocating all the resources. - if ( fileContent ) + if (fileContent) { delete[] fileContent; fileContent = NULL; } - if ( pExpatAdapter ) + if (pExpatAdapter) { delete pExpatAdapter; pExpatAdapter = NULL; @@ -4106,13 +4727,13 @@ } // DumpSVG -// ================================================================================================= + // ================================================================================================= #define kSWF_FileAttributesTag 69 #define kSWF_MetadataTag 77 static void -DumpSWF ( LFA_FileRef file, XMP_Uns32 swfLen ) +DumpSWF(LFA_FileRef file, XMP_Uns32 swfLen) { // SWF is a chunky format, the chunks are called tags. The data of a tag cannot contain an // offset to another tag, so tags can generally be freely inserted, removed, etc. Each tag has a @@ -4157,160 +4778,165 @@ // byte boundary. The first field is 5 bits long and gives the number of bits in each of the // other 4 fields (0..31). The others are signed integers for the X min/max and Y min/max // coordinates. The frame rectangle field is at least 2 bytes long, and at most 17 bytes long. - - XMP_Uns8 buffer [100]; // Big enough, need 32 for file header and 38 for FileAttributes. + + XMP_Uns8 buffer[100]; // Big enough, need 32 for file header and 38 for FileAttributes. size_t ioCount; - + // Dump the file header. bool isCompressed = false; - bool hasMetadata = false; - + bool hasMetadata = false; + XMP_Uns8 fileVersion; XMP_Uns32 fullLength; XMP_Uns8 rectBits; XMP_Uns16 frameRate, frameCount; - - ioCount = LFA_Read ( file, buffer, sizeof(buffer), false); - if ( ioCount < 14 ) { - tree->comment ( "** Invalid SWF, file header is too short." ); + + ioCount = LFA_Read(file, buffer, sizeof(buffer), false); + if (ioCount < 14) { + tree->comment("** Invalid SWF, file header is too short."); return; } - - if ( CheckBytes ( buffer, "CWS", 3 ) ) { + + if (CheckBytes(buffer, "CWS", 3)) { isCompressed = true; - } else if ( ! CheckBytes ( buffer, "FWS", 3 ) ) { - tree->comment ( "** Invalid SWF, unknown file header signature." ); + } + else if (!CheckBytes(buffer, "FWS", 3)) { + tree->comment("** Invalid SWF, unknown file header signature."); return; } - + fileVersion = buffer[3]; - fullLength = GetUns32LE ( &buffer[4] ); - rectBits = buffer[8] >> 3; - + fullLength = GetUns32LE(&buffer[4]); + rectBits = buffer[8] >> 3; + XMP_Uns32 rectBytes = ((5 + (4 * rectBits)) / 8) + 1; XMP_Uns32 headerBytes = 8 + rectBytes + 4; - - if ( ioCount < headerBytes ) { - tree->comment ( "** Invalid SWF, file header is too short." ); + + if (ioCount < headerBytes) { + tree->comment("** Invalid SWF, file header is too short."); return; } - - frameRate = GetUns16LE ( &buffer[8+rectBytes] ); - frameCount = GetUns16LE ( &buffer[8+rectBytes+2] ); - + + frameRate = GetUns16LE(&buffer[8 + rectBytes]); + frameCount = GetUns16LE(&buffer[8 + rectBytes + 2]); + // *** Someday decode the frame rectangle. - - tree->pushNode( "File Header" ); - tree->addComment ( "%scompressed, version %d, full length %d, frame rate %d, frame count %d", - (isCompressed ? "" : "un"), fileVersion, fullLength, frameRate, frameCount ); + + tree->pushNode("File Header"); + tree->addComment("%scompressed, version %d, full length %d, frame rate %d, frame count %d", + (isCompressed ? "" : "un"), fileVersion, fullLength, frameRate, frameCount); tree->popNode(); - if ( isCompressed ) { + if (isCompressed) { // *** Add support to decompress into a temp file. - tree->comment ( "** Ignoring compressed SWF contents." ); + tree->comment("** Ignoring compressed SWF contents."); return; } - + // Dump the tags in the body of the file. - + XMP_Uns16 tagType; XMP_Uns32 tagOffset, tagLength, headerLength, dataLength; - - for ( tagOffset = headerBytes; (tagOffset < swfLen); tagOffset += tagLength ) { + + for (tagOffset = headerBytes; (tagOffset < swfLen); tagOffset += tagLength) { // Read the tag header, extract the type and data length. - - LFA_Seek ( file, tagOffset, SEEK_SET ); - ioCount = LFA_Read ( file, buffer, sizeof(buffer), false); - - if ( ioCount < 2 ) { - tree->comment ( "** Invalid SWF, tag header is too short at offset %u (0x%X).", tagOffset, tagOffset ); + LFA_Seek(file, tagOffset, SEEK_SET); + ioCount = LFA_Read(file, buffer, sizeof(buffer), false); + + + if (ioCount < 2) { + tree->comment("** Invalid SWF, tag header is too short at offset %u (0x%X).", tagOffset, tagOffset); break; } - - tagType = GetUns16LE ( &buffer[0] ); + + tagType = GetUns16LE(&buffer[0]); dataLength = tagType & 0x3F; tagType = tagType >> 6; - - if ( dataLength < 63 ) { + + if (dataLength < 63) { headerLength = 2; - } else { - if ( ioCount < 6 ) { - tree->comment ( "** Invalid SWF, tag header is too short at offset %u (0x%X).", tagOffset, tagOffset ); + } + else { + if (ioCount < 6) { + tree->comment("** Invalid SWF, tag header is too short at offset %u (0x%X).", tagOffset, tagOffset); break; } headerLength = 6; - dataLength = GetUns32LE ( &buffer[2] ); + dataLength = GetUns32LE(&buffer[2]); } tagLength = headerLength + dataLength; - + // Make sure the tag fits in the file, being careful about arithmetic overflow. - - if ( tagLength > (swfLen - tagOffset) ) { - tree->comment ( "** Invalid SWF, tag is too long at offset %u (0x%X).", tagOffset, tagOffset ); + + if (tagLength > (swfLen - tagOffset)) { + tree->comment("** Invalid SWF, tag is too long at offset %u (0x%X).", tagOffset, tagOffset); break; } - + // See if this is the FileAttributes tag or the Metadata tag. - - if ( (tagOffset == headerBytes) && (tagType != kSWF_FileAttributesTag) && (fileVersion >= 8) ) { - tree->comment ( "** Invalid SWF, first tag is not FileAttributes." ); + + if ((tagOffset == headerBytes) && (tagType != kSWF_FileAttributesTag) && (fileVersion >= 8)) { + tree->comment("** Invalid SWF, first tag is not FileAttributes."); } - if ( tagType == kSWF_FileAttributesTag ) { + if (tagType == kSWF_FileAttributesTag) { - if ( dataLength < 4 ) { - tree->comment ( "** Invalid SWF, FileAttributes tag is too short at offset %u (0x%X).", tagOffset, tagOffset ); + if (dataLength < 4) { + tree->comment("** Invalid SWF, FileAttributes tag is too short at offset %u (0x%X).", tagOffset, tagOffset); continue; } - + XMP_Uns32 xmpFlag = GetUns32LE(&(buffer[headerLength])) & 0x10; - if ( xmpFlag != 0 ) { + if (xmpFlag != 0) { hasMetadata = true; } - - tree->pushNode( "FileAttributes tag" ); - tree->addComment ( "Offset %d (0x%X), %s XMP", tagOffset, tagOffset, (hasMetadata ? "has" : "no") ); - tree->popNode( ); - } else if ( tagType == kSWF_MetadataTag ) { + tree->pushNode("FileAttributes tag"); + tree->addComment("Offset %d (0x%X), %s XMP", tagOffset, tagOffset, (hasMetadata ? "has" : "no")); + tree->popNode(); + + } + else if (tagType == kSWF_MetadataTag) { - if ( ! hasMetadata ) { - tree->comment ( "** Invalid SWF, Metadata tag without HasMetadata flag at offset %u (0x%X).", tagOffset, tagOffset ); + if (!hasMetadata) { + tree->comment("** Invalid SWF, Metadata tag without HasMetadata flag at offset %u (0x%X).", tagOffset, tagOffset); continue; } - tree->pushNode( "Metadata tag" ); - tree->addComment ( "Offset %d (0x%X)", tagOffset, tagOffset ); - tree->popNode( ); - - if ( sXMPPtr != 0 ) { - tree->comment ( " ** Redundant Metadata tag" ); - } else { - CaptureXMPF ( file, (tagOffset + headerLength), dataLength ); + tree->pushNode("Metadata tag"); + tree->addComment("Offset %d (0x%X)", tagOffset, tagOffset); + tree->popNode(); + + if (sXMPPtr != 0) { + tree->comment(" ** Redundant Metadata tag"); + } + else { + CaptureXMPF(file, (tagOffset + headerLength), dataLength); } //if ( sXMPPtr != 0 ) DumpXMP ( "SWF Metadata tag (#77) XMP" ); - } else { - tree->pushNode( "tag #%d", tagType ); - tree->addComment ( "Offset %d (0x%X)", tagOffset, tagOffset ); - tree->popNode( ); - } - - } - + } + else { + tree->pushNode("tag #%d", tagType); + tree->addComment("Offset %d (0x%X)", tagOffset, tagOffset); + tree->popNode(); + } + + } + } // DumpSWF -// ================================================================================================= + // ================================================================================================= -static XMP_Uns32 DumpScriptDataArray ( LFA_FileRef file, XMP_Uns32 sdOffset, XMP_Uns32 count, - bool isStrict, bool isOnXMP = false ); -static XMP_Uns32 DumpScriptDataObject ( LFA_FileRef file, XMP_Uns32 sdOffset ); -static XMP_Uns32 DumpScriptDataObjectList ( LFA_FileRef file, XMP_Uns32 sdOffset ); +static XMP_Uns32 DumpScriptDataArray(LFA_FileRef file, XMP_Uns32 sdOffset, XMP_Uns32 count, + bool isStrict, bool isOnXMP = false); +static XMP_Uns32 DumpScriptDataObject(LFA_FileRef file, XMP_Uns32 sdOffset); +static XMP_Uns32 DumpScriptDataObjectList(LFA_FileRef file, XMP_Uns32 sdOffset); -static inline XMP_Uns32 GetUns24BE ( XMP_Uns8 * ptr ) +static inline XMP_Uns32 GetUns24BE(XMP_Uns8 * ptr) { return (GetUns32BE(ptr) >> 8); } @@ -4323,350 +4949,354 @@ } -static XMP_Uns32 DumpScriptDataValue ( LFA_FileRef file, XMP_Uns32 sdOffset, bool isOnXMP = false ) +static XMP_Uns32 DumpScriptDataValue(LFA_FileRef file, XMP_Uns32 sdOffset, bool isOnXMP = false) { - XMP_Uns8 buffer [64*1024]; + XMP_Uns8 buffer[64 * 1024]; size_t ioCount; XMP_Uns8 kind; XMP_Uns16 u16; XMP_Uns32 u32; XMP_Uns64 u64; - - LFA_Seek ( file, sdOffset, SEEK_SET ); - ioCount = LFA_Read ( file, &kind, 1, true); - if ( ioCount != 1 ) { - tree->comment ( "** Failure reading ScriptDataValue kind, ioCount = %d", ioCount ); + + LFA_Seek(file, sdOffset, SEEK_SET); + ioCount = LFA_Read(file, &kind, 1, true); + if (ioCount != 1) { + tree->comment("** Failure reading ScriptDataValue kind, ioCount = %d", ioCount); return sdOffset; } - - if ( isOnXMP ) { - if ( (kind != 8) && (kind != 2) && (kind != 0xC) ) { - tree->comment ( "** Invalid kind for onXMPData tag **" ); + + if (isOnXMP) { + if ((kind != 8) && (kind != 2) && (kind != 0xC)) { + tree->comment("** Invalid kind for onXMPData tag **"); } } - + XMP_Uns64 time; XMP_Int16 tz; - switch ( kind ) { - - case 0x00: // A number, IEEE double. - ReadSDValue ( 8 ); - u64 = GetUns64BE ( &buffer[0] ); - tree->addComment ( "float = %f", *((double*)(&u64)) ); - return (sdOffset + 1 + 8); - - case 0x01: // A 0/1 Boolean. (??? general Uns8?) - ReadSDValue ( 1 ); - tree->addComment ( "bool = %d", buffer[0] ); - return (sdOffset + 1 + 1); - - case 0x02: // A short UTF-8 string, leading 2 byte count. - ReadSDValue ( 2 ); - u16 = GetUns16BE ( &buffer[0] ); - ReadSDValue ( u16 ); - if (int(u16) < 4096 ) - { - tree->addComment ( "string (%d) = \"%.*s\"", u16, u16, buffer ); - } else { - tree->addComment ( "string (%d) ", u16 ); - } - if ( buffer[u16-1] != 0 ) tree->addComment ( "value lacks trailing nul" ); - if ( isOnXMP ) CaptureXMPF ( file, (sdOffset+1+2), u16 ); - return (sdOffset + 1 + 2 + u16); - - case 0x03: // An object list, triples of 0x02/key/value, ends at 0x02000009. - tree->addComment ( "object list" ); - return DumpScriptDataObjectList ( file, sdOffset+1 ); - - case 0x04: // A movie clip path as short UTF-8 string - ReadSDValue ( 2 ); - u16 = GetUns16BE ( &buffer[0] ); - ReadSDValue ( u16 ); - tree->addComment ( "movie (%d) = \"%.*s\"", u16, u16, buffer ); - if ( buffer[u16-1] != 0 ) tree->addComment ( "value lacks trailing nul" ); - return (sdOffset + 1 + 2 + u16); - - case 0x05: // A null, single byte. - tree->addComment ( "null" ); - return (sdOffset + 1); - - case 0x06: // A undefined, single byte. - tree->addComment ( "undefined" ); - return (sdOffset + 1); - - case 0x07: // A reference, Uns16. - ReadSDValue ( 2 ); - u16 = GetUns16BE ( &buffer[0] ); - tree->addComment ( "reference = %d", u16 ); - return (sdOffset + 1 + 2); - - case 0x08: // An ECMA array, 32-bit count then any number of key/value pairs. Has 0x000009 terminator. - ReadSDValue ( 4 ); - u32 = GetUns32BE ( &buffer[0] ); - tree->addComment ( "ECMA array [%d]", u32 ); - return DumpScriptDataArray ( file, sdOffset+1+4, u32, false, isOnXMP ); - - case 0x09: // End of object or array. Should not see this here! - tree->addComment ( "** end **" ); - return (sdOffset + 1); - - case 0x0A: // A strict array, count then that many key/value pairs, no 0x000009 terminator. - ReadSDValue ( 4 ); - u32 = GetUns32BE ( &buffer[0] ); - tree->addComment ( "strict array [%d]", u32 ); - return DumpScriptDataArray ( file, sdOffset+1+4, u32, true ); - - case 0x0B: // A date, Uns64 milliseconds since Jan 1 1970, Int16 TZ offset in minutes. - ReadSDValue ( 10 ); - time = GetUns64BE ( &buffer[0] ); - tz = (XMP_Int16) GetUns16BE ( &buffer[8] ); - tree->addComment ( "date, time=%ULL, tz=%d", time, tz ); - return (sdOffset + 1 + 10); - - case 0x0C: // A long UTF-8 string, leading 4 byte count. - ReadSDValue ( 4 ); - u32 = GetUns32BE ( &buffer[0] ); - if ( u32 < sizeof(buffer) ) { - ReadSDValue ( u32 ); - tree->addComment ( "long string (%d) = \"%.*s\"", u32, u32, buffer ); - if ( buffer[u32-1] != 0 ) tree->addComment ( "value lacks trailing nul" ); - } else { - ReadSDValue ( sizeof(buffer) ); - tree->addComment ( "long string (%d) = \"%.*s\"", u32, sizeof(buffer), buffer ); - tree->comment ( "** truncated long string output **" ); - } - if ( isOnXMP ) CaptureXMPF ( file, (sdOffset+1+4), u32 ); - return (sdOffset + 1 + 4 + u32); - - case 0x0D: // Unsupported, single byte. - tree->addComment ( "unsupported" ); - return (sdOffset + 1); - - case 0x0E: // A RecordSet. (???) - tree->addComment ( "** record set ?? **" ); - return (sdOffset + 1); - - case 0x0F: // XML as a long UTF-8 string - ReadSDValue ( 4 ); - u32 = GetUns32BE ( &buffer[0] ); - if ( u32 < sizeof(buffer) ) { - ReadSDValue ( u32 ); - tree->addComment ( "XML (%d) = \"%.*s\"", u32, u32, buffer ); - if ( buffer[u32-1] != 0 ) tree->addComment ( "value lacks trailing nul" ); - } else { - ReadSDValue ( sizeof(buffer) ); - tree->addComment ( "XML (%d) = \"%.*s\"", u32, sizeof(buffer), buffer ); - tree->comment ( "** truncated long string output **" ); - } - if ( isOnXMP ) CaptureXMPF ( file, (sdOffset+1+4), u32 ); - return (sdOffset + 1 + 4 + u32); - - case 0x10: // A typed object list, short string class name, object list (like case 0x03). - ReadSDValue ( 2 ); - u16 = GetUns16BE ( &buffer[0] ); - ReadSDValue ( u16 ); - tree->addComment ( "class, name = %.*s", u16, u16, buffer ); - if ( buffer[u16-1] == 0 ) tree->addComment ( "name has trailing nul" ); - return DumpScriptDataObjectList ( file, (sdOffset + 1 + 2 + u16) ); - - case 0x11: // AMF 3 data. (???) - tree->addComment ( "** AMF 3 data ?? **" ); - return (sdOffset + 1); - - default: - tree->addComment ( "** unknown kind = %d **", kind ); - return (sdOffset + 1); - + switch (kind) { + + case 0x00: // A number, IEEE double. + ReadSDValue(8); + u64 = GetUns64BE(&buffer[0]); + tree->addComment("float = %f", *((double*)(&u64))); + return (sdOffset + 1 + 8); + + case 0x01: // A 0/1 Boolean. (??? general Uns8?) + ReadSDValue(1); + tree->addComment("bool = %d", buffer[0]); + return (sdOffset + 1 + 1); + + case 0x02: // A short UTF-8 string, leading 2 byte count. + ReadSDValue(2); + u16 = GetUns16BE(&buffer[0]); + ReadSDValue(u16); + if (int(u16) < 4096) + { + tree->addComment("string (%d) = \"%.*s\"", u16, u16, buffer); + } + else { + tree->addComment("string (%d) ", u16); + } + if (buffer[u16 - 1] != 0) tree->addComment("value lacks trailing nul"); + if (isOnXMP) CaptureXMPF(file, (sdOffset + 1 + 2), u16); + return (sdOffset + 1 + 2 + u16); + + case 0x03: // An object list, triples of 0x02/key/value, ends at 0x02000009. + tree->addComment("object list"); + return DumpScriptDataObjectList(file, sdOffset + 1); + + case 0x04: // A movie clip path as short UTF-8 string + ReadSDValue(2); + u16 = GetUns16BE(&buffer[0]); + ReadSDValue(u16); + tree->addComment("movie (%d) = \"%.*s\"", u16, u16, buffer); + if (buffer[u16 - 1] != 0) tree->addComment("value lacks trailing nul"); + return (sdOffset + 1 + 2 + u16); + + case 0x05: // A null, single byte. + tree->addComment("null"); + return (sdOffset + 1); + + case 0x06: // A undefined, single byte. + tree->addComment("undefined"); + return (sdOffset + 1); + + case 0x07: // A reference, Uns16. + ReadSDValue(2); + u16 = GetUns16BE(&buffer[0]); + tree->addComment("reference = %d", u16); + return (sdOffset + 1 + 2); + + case 0x08: // An ECMA array, 32-bit count then any number of key/value pairs. Has 0x000009 terminator. + ReadSDValue(4); + u32 = GetUns32BE(&buffer[0]); + tree->addComment("ECMA array [%d]", u32); + return DumpScriptDataArray(file, sdOffset + 1 + 4, u32, false, isOnXMP); + + case 0x09: // End of object or array. Should not see this here! + tree->addComment("** end **"); + return (sdOffset + 1); + + case 0x0A: // A strict array, count then that many key/value pairs, no 0x000009 terminator. + ReadSDValue(4); + u32 = GetUns32BE(&buffer[0]); + tree->addComment("strict array [%d]", u32); + return DumpScriptDataArray(file, sdOffset + 1 + 4, u32, true); + + case 0x0B: // A date, Uns64 milliseconds since Jan 1 1970, Int16 TZ offset in minutes. + ReadSDValue(10); + time = GetUns64BE(&buffer[0]); + tz = (XMP_Int16)GetUns16BE(&buffer[8]); + tree->addComment("date, time=%ULL, tz=%d", time, tz); + return (sdOffset + 1 + 10); + + case 0x0C: // A long UTF-8 string, leading 4 byte count. + ReadSDValue(4); + u32 = GetUns32BE(&buffer[0]); + if (u32 < sizeof(buffer)) { + ReadSDValue(u32); + tree->addComment("long string (%d) = \"%.*s\"", u32, u32, buffer); + if (buffer[u32 - 1] != 0) tree->addComment("value lacks trailing nul"); + } + else { + ReadSDValue(sizeof(buffer)); + tree->addComment("long string (%d) = \"%.*s\"", u32, sizeof(buffer), buffer); + tree->comment("** truncated long string output **"); + } + if (isOnXMP) CaptureXMPF(file, (sdOffset + 1 + 4), u32); + return (sdOffset + 1 + 4 + u32); + + case 0x0D: // Unsupported, single byte. + tree->addComment("unsupported"); + return (sdOffset + 1); + + case 0x0E: // A RecordSet. (???) + tree->addComment("** record set ?? **"); + return (sdOffset + 1); + + case 0x0F: // XML as a long UTF-8 string + ReadSDValue(4); + u32 = GetUns32BE(&buffer[0]); + if (u32 < sizeof(buffer)) { + ReadSDValue(u32); + tree->addComment("XML (%d) = \"%.*s\"", u32, u32, buffer); + if (buffer[u32 - 1] != 0) tree->addComment("value lacks trailing nul"); + } + else { + ReadSDValue(sizeof(buffer)); + tree->addComment("XML (%d) = \"%.*s\"", u32, sizeof(buffer), buffer); + tree->comment("** truncated long string output **"); + } + if (isOnXMP) CaptureXMPF(file, (sdOffset + 1 + 4), u32); + return (sdOffset + 1 + 4 + u32); + + case 0x10: // A typed object list, short string class name, object list (like case 0x03). + ReadSDValue(2); + u16 = GetUns16BE(&buffer[0]); + ReadSDValue(u16); + tree->addComment("class, name = %.*s", u16, u16, buffer); + if (buffer[u16 - 1] == 0) tree->addComment("name has trailing nul"); + return DumpScriptDataObjectList(file, (sdOffset + 1 + 2 + u16)); + + case 0x11: // AMF 3 data. (???) + tree->addComment("** AMF 3 data ?? **"); + return (sdOffset + 1); + + default: + tree->addComment("** unknown kind = %d **", kind); + return (sdOffset + 1); + } } // DumpScriptDataValue -// ================================================================================================= + // ================================================================================================= -static XMP_Uns32 DumpScriptVariable ( LFA_FileRef file, XMP_Uns32 sdOffset, bool isOnXMP = false ) +static XMP_Uns32 DumpScriptVariable(LFA_FileRef file, XMP_Uns32 sdOffset, bool isOnXMP = false) { - XMP_Uns8 buffer [64*1024]; + XMP_Uns8 buffer[64 * 1024]; size_t ioCount; - - LFA_Seek ( file, sdOffset, SEEK_SET ); - ioCount = LFA_Read ( file, buffer, 2, true ); - if ( ioCount != 2 ) { - tree->comment ( "** Failure reading DumpScriptVariable start, ioCount = %d", ioCount ); + + LFA_Seek(file, sdOffset, SEEK_SET); + ioCount = LFA_Read(file, buffer, 2, true); + if (ioCount != 2) { + tree->comment("** Failure reading DumpScriptVariable start, ioCount = %d", ioCount); return (sdOffset + ioCount); } - - XMP_Uns16 nameLen = GetUns16BE ( &buffer[0] ); - ioCount = LFA_Read ( file, buffer, nameLen, true ); - if ( ioCount != nameLen ) { - tree->comment ( "** Failure reading ScriptDataObject name, ioCount = %d", ioCount ); + + XMP_Uns16 nameLen = GetUns16BE(&buffer[0]); + ioCount = LFA_Read(file, buffer, nameLen, true); + if (ioCount != nameLen) { + tree->comment("** Failure reading ScriptDataObject name, ioCount = %d", ioCount); return (sdOffset + 3 + ioCount); } - - tree->pushNode ( "%.*s @ 0x%X", nameLen, buffer, sdOffset ); - if ( buffer[nameLen-1] == 0 ) tree->addComment ( "name has trailing nul" ); - if ( strncmp ( (char*)buffer, "liveXML", nameLen ) != 0 ) isOnXMP = false; // ! Else keep the input value. - XMP_Uns32 nextOffset = DumpScriptDataValue ( file, (sdOffset+2+nameLen), isOnXMP ); + + tree->pushNode("%.*s @ 0x%X", nameLen, buffer, sdOffset); + if (buffer[nameLen - 1] == 0) tree->addComment("name has trailing nul"); + if (strncmp((char*)buffer, "liveXML", nameLen) != 0) isOnXMP = false; // ! Else keep the input value. + XMP_Uns32 nextOffset = DumpScriptDataValue(file, (sdOffset + 2 + nameLen), isOnXMP); tree->popNode(); return nextOffset; } // DumpScriptVariable -// ================================================================================================= + // ================================================================================================= -static XMP_Uns32 DumpScriptDataArray ( LFA_FileRef file, XMP_Uns32 sdOffset, XMP_Uns32 headerCount, - bool isStrict, bool isOnXMP /* = false */ ) +static XMP_Uns32 DumpScriptDataArray(LFA_FileRef file, XMP_Uns32 sdOffset, XMP_Uns32 headerCount, + bool isStrict, bool isOnXMP /* = false */) { - XMP_Uns8 buffer [3]; + XMP_Uns8 buffer[3]; size_t ioCount; - + XMP_Uns32 actualCount = 0; - XMP_Uns32 currOffset = sdOffset; - - if ( isStrict ) { - - for ( ; headerCount > 0; --headerCount ) { - XMP_Uns32 nextOffset = DumpScriptVariable ( file, currOffset ); - if ( nextOffset == currOffset ) { - tree->comment ( "** Failure reading DumpScriptDataArray, no progress" ); + XMP_Uns32 currOffset = sdOffset; + + if (isStrict) { + + for (; headerCount > 0; --headerCount) { + XMP_Uns32 nextOffset = DumpScriptVariable(file, currOffset); + if (nextOffset == currOffset) { + tree->comment("** Failure reading DumpScriptDataArray, no progress"); return currOffset; } currOffset = nextOffset; } - - } else { - - while ( true ) { - - LFA_Seek ( file, currOffset, SEEK_SET ); - ioCount = LFA_Read ( file, buffer, 3, true ); - if ( ioCount != 3 ) { - tree->comment ( "** Failure check DumpScriptDataArray, ioCount = %d", ioCount ); + + } + else { + + while (true) { + + LFA_Seek(file, currOffset, SEEK_SET); + ioCount = LFA_Read(file, buffer, 3, true); + if (ioCount != 3) { + tree->comment("** Failure check DumpScriptDataArray, ioCount = %d", ioCount); return (currOffset + ioCount); } - if ( GetUns24BE ( &buffer[0] ) == 9 ) break; - - XMP_Uns32 nextOffset = DumpScriptVariable ( file, currOffset, isOnXMP ); - if ( nextOffset == currOffset ) { - tree->comment ( "** Failure reading DumpScriptDataArray, no progress" ); + if (GetUns24BE(&buffer[0]) == 9) break; + + XMP_Uns32 nextOffset = DumpScriptVariable(file, currOffset, isOnXMP); + if (nextOffset == currOffset) { + tree->comment("** Failure reading DumpScriptDataArray, no progress"); return currOffset; } - + ++actualCount; currOffset = nextOffset; - + } - - if ( (headerCount != (XMP_Uns32)(-1)) && (headerCount != actualCount) ) { - tree->comment ( "Count mismatch, actual = %d", actualCount ); // ! Not an error! + + if ((headerCount != (XMP_Uns32)(-1)) && (headerCount != actualCount)) { + tree->comment("Count mismatch, actual = %d", actualCount); // ! Not an error! } - + currOffset += 3; // ! Include the 0x000009 terminator. - + } - + return currOffset; } // DumpScriptDataArray -// ================================================================================================= + // ================================================================================================= -static XMP_Uns32 DumpScriptDataObject ( LFA_FileRef file, XMP_Uns32 sdOffset ) +static XMP_Uns32 DumpScriptDataObject(LFA_FileRef file, XMP_Uns32 sdOffset) { - XMP_Uns8 buffer [64*1024]; + XMP_Uns8 buffer[64 * 1024]; size_t ioCount; - - LFA_Seek ( file, sdOffset, SEEK_SET ); - ioCount = LFA_Read ( file, buffer, 2,true); - if ( ioCount != 2 ) { - tree->comment ( "** Failure reading ScriptDataObject name length, ioCount = %d", ioCount ); + + LFA_Seek(file, sdOffset, SEEK_SET); + ioCount = LFA_Read(file, buffer, 2, true); + if (ioCount != 2) { + tree->comment("** Failure reading ScriptDataObject name length, ioCount = %d", ioCount); return (sdOffset + ioCount); } - - XMP_Uns16 nameLen = GetUns16BE ( &buffer[1] ); - ioCount = LFA_Read ( file, buffer, nameLen, true); - if ( ioCount != nameLen ) { - tree->comment ( "** Failure reading ScriptDataObject name, ioCount = %d", ioCount ); + + XMP_Uns16 nameLen = GetUns16BE(&buffer[1]); + ioCount = LFA_Read(file, buffer, nameLen, true); + if (ioCount != nameLen) { + tree->comment("** Failure reading ScriptDataObject name, ioCount = %d", ioCount); return (sdOffset + 2 + ioCount); } - - tree->pushNode ( "%.*s @ 0x%X", nameLen, buffer, sdOffset ); - if ( buffer[nameLen-1] == 0 ) tree->addComment ( "name has trailing nul" ); - XMP_Uns32 nextOffset = DumpScriptDataValue ( file, (sdOffset+2+nameLen) ); + + tree->pushNode("%.*s @ 0x%X", nameLen, buffer, sdOffset); + if (buffer[nameLen - 1] == 0) tree->addComment("name has trailing nul"); + XMP_Uns32 nextOffset = DumpScriptDataValue(file, (sdOffset + 2 + nameLen)); tree->popNode(); - + return nextOffset; } // DumpScriptDataObject -// ================================================================================================= + // ================================================================================================= -static XMP_Uns32 DumpScriptDataObjectList ( LFA_FileRef file, XMP_Uns32 sdOffset ) +static XMP_Uns32 DumpScriptDataObjectList(LFA_FileRef file, XMP_Uns32 sdOffset) { - XMP_Uns8 buffer [3]; + XMP_Uns8 buffer[3]; size_t ioCount; - + XMP_Uns32 currOffset = sdOffset; - - while ( true ) { - - LFA_Seek ( file, currOffset, SEEK_SET ); - ioCount = LFA_Read ( file, buffer, 3, true); - if ( ioCount != 3 ) { - tree->comment ( "** Failure check ScriptDataObjectList, ioCount = %d", ioCount ); + + while (true) { + + LFA_Seek(file, currOffset, SEEK_SET); + ioCount = LFA_Read(file, buffer, 3, true); + if (ioCount != 3) { + tree->comment("** Failure check ScriptDataObjectList, ioCount = %d", ioCount); return (currOffset + ioCount); } - - XMP_Uns32 endFlag = GetUns24BE ( &buffer[0] ); - if ( endFlag == 9 ) return (currOffset + 3); - - XMP_Uns32 nextOffset = DumpScriptDataObject ( file, currOffset ); - if ( nextOffset == currOffset ) { - tree->comment ( "** Failure reading ScriptDataObjectList, no progress" ); + + XMP_Uns32 endFlag = GetUns24BE(&buffer[0]); + if (endFlag == 9) return (currOffset + 3); + + XMP_Uns32 nextOffset = DumpScriptDataObject(file, currOffset); + if (nextOffset == currOffset) { + tree->comment("** Failure reading ScriptDataObjectList, no progress"); return currOffset; } - + currOffset = nextOffset; - + } } // DumpScriptDataObjectList -// ================================================================================================= + // ================================================================================================= -static XMP_Uns32 DumpScriptDataTagContent ( LFA_FileRef file, XMP_Uns32 sdOffset, XMP_Uns32 tagTime ) +static XMP_Uns32 DumpScriptDataTagContent(LFA_FileRef file, XMP_Uns32 sdOffset, XMP_Uns32 tagTime) { - XMP_Uns8 buffer [64*1024]; + XMP_Uns8 buffer[64 * 1024]; size_t ioCount; - - LFA_Seek ( file, sdOffset, SEEK_SET ); - ioCount = LFA_Read ( file, buffer, 3, true ); - if ( (ioCount != 3) || (buffer[0] != 2) ) { - tree->comment ( "** Failure reading ScriptDataObject start, ioCount = %d, buffer[0]=0x%X", ioCount, buffer[0] ); + + LFA_Seek(file, sdOffset, SEEK_SET); + ioCount = LFA_Read(file, buffer, 3, true); + if ((ioCount != 3) || (buffer[0] != 2)) { + tree->comment("** Failure reading ScriptDataObject start, ioCount = %d, buffer[0]=0x%X", ioCount, buffer[0]); return (sdOffset + ioCount); } - - XMP_Uns16 nameLen = GetUns16BE ( &buffer[1] ); - ioCount = LFA_Read ( file, buffer, nameLen, true ); - if ( ioCount != nameLen ) { - tree->comment ( "** Failure reading ScriptDataObject name, ioCount = %d", ioCount ); + + XMP_Uns16 nameLen = GetUns16BE(&buffer[1]); + ioCount = LFA_Read(file, buffer, nameLen, true); + if (ioCount != nameLen) { + tree->comment("** Failure reading ScriptDataObject name, ioCount = %d", ioCount); return (sdOffset + 3 + ioCount); } - - tree->addComment ( "%.*s @ 0x%X", nameLen, buffer, sdOffset ); - if ( buffer[nameLen-1] == 0 ) tree->addComment ( "name has trailing nul" ); - - bool isOnXMP = (tagTime == 0) && (nameLen == 9) && (strncmp ( (char*)buffer, "onXMPData", 9 ) == 0); - return DumpScriptDataValue ( file, (sdOffset+1+2+nameLen), isOnXMP ); + + tree->addComment("%.*s @ 0x%X", nameLen, buffer, sdOffset); + if (buffer[nameLen - 1] == 0) tree->addComment("name has trailing nul"); + + bool isOnXMP = (tagTime == 0) && (nameLen == 9) && (strncmp((char*)buffer, "onXMPData", 9) == 0); + return DumpScriptDataValue(file, (sdOffset + 1 + 2 + nameLen), isOnXMP); } // DumpScriptDataTagContent -// ================================================================================================= + // ================================================================================================= static void -DumpFLV ( LFA_FileRef file, XMP_Uns32 flvLen ) +DumpFLV(LFA_FileRef file, XMP_Uns32 flvLen) { // FLV must not be confused with SWF, they are quite different internally. FLV is a chunky // format, the chunks are called tags. All multi-byte integers in FLV are stored in big endian @@ -4699,127 +5329,130 @@ // SCRIPTDATADATE. It isn't clear if these SCRIPTDATA* things are FLV tags, or substructure // within the data of tag type 18. - XMP_Uns8 buffer [100]; + XMP_Uns8 buffer[100]; size_t ioCount; XMP_Uns32 size, time, stream, backSize; - - ioCount = LFA_Read ( file, buffer, 9+4, true); - if ( ioCount != 9+4 ) { - tree->comment ( "** Failure reading FLV header, ioCount = %d", ioCount ); + + ioCount = LFA_Read(file, buffer, 9 + 4, true); + if (ioCount != 9 + 4) { + tree->comment("** Failure reading FLV header, ioCount = %d", ioCount); return; } - - size = GetUns32BE ( &buffer[5] ); - tree->addComment ( "FLV header: \"%.3s\", version %d, flags 0x%.2X, size %d (0x%X)", - &buffer[0], buffer[3], buffer[4], size ); - - LFA_Seek ( file, size, SEEK_SET ); - ioCount = LFA_Read ( file, buffer, 4, true); - if ( ioCount != 4 ) { - tree->comment ( "** Failure reading leading backSize, ioCount = %d", ioCount ); + + size = GetUns32BE(&buffer[5]); + tree->addComment("FLV header: \"%.3s\", version %d, flags 0x%.2X, size %d (0x%X)", + &buffer[0], buffer[3], buffer[4], size); + + LFA_Seek(file, size, SEEK_SET); + ioCount = LFA_Read(file, buffer, 4, true); + if (ioCount != 4) { + tree->comment("** Failure reading leading backSize, ioCount = %d", ioCount); return; } - backSize = GetUns32BE ( &buffer[0] ); - if ( backSize != 0 ) { - tree->comment ( "** Bad leading backSize = %d", backSize ); + backSize = GetUns32BE(&buffer[0]); + if (backSize != 0) { + tree->comment("** Bad leading backSize = %d", backSize); return; } - - for ( XMP_Uns32 tagOffset = (size+4); tagOffset < flvLen; tagOffset += (11+size+4) ) { - LFA_Seek ( file, tagOffset, SEEK_SET ); - ioCount = LFA_Read ( file, buffer, 11, true); // Back pointer plus tag header. - if ( ioCount != 11 ) { - tree->comment ( "** Failure reading FLV tag, ioCount = %d", ioCount ); + for (XMP_Uns32 tagOffset = (size + 4); tagOffset < flvLen; tagOffset += (11 + size + 4)) { + + LFA_Seek(file, tagOffset, SEEK_SET); + ioCount = LFA_Read(file, buffer, 11, true); // Back pointer plus tag header. + if (ioCount != 11) { + tree->comment("** Failure reading FLV tag, ioCount = %d", ioCount); return; } - - size = GetUns24BE ( &buffer[1] ); - time = GetUns24BE ( &buffer[4] ); + + size = GetUns24BE(&buffer[1]); + time = GetUns24BE(&buffer[4]); time += ((XMP_Uns32)buffer[7] << 24); - stream = GetUns24BE ( &buffer[8] ); - - if ( time != 0 ) break; // ! Just do the time 0 tags for this tool. - - char label [100]; - char comment [1000]; - + stream = GetUns24BE(&buffer[8]); + + if (time != 0) break; // ! Just do the time 0 tags for this tool. + + char label[100]; + char comment[1000]; + XMP_Uns8 kind = buffer[0]; - if ( kind == 8 ) { - if ( time == 0 ) sprintf ( label, "Audio" ); // Don't normally print, there are too many. - } else if ( kind == 9 ) { - if ( time == 0 ) sprintf ( label, "Video" ); // Don't normally print, there are too many. - } else if ( kind == 18 ) { - sprintf ( label, "ScriptData" ); - } else { - sprintf ( label, "", kind ); - } - sprintf ( comment, "%s @ 0x%X, size=%d, time=%d, stream=%d", label, tagOffset, size, time, stream ); - - tree->pushNode ( label ); - tree->addComment ( comment ); - - LFA_Seek ( file, (tagOffset+11+size), SEEK_SET ); - ioCount = LFA_Read ( file, buffer, 4, true ); // Back pointer plus tag header. - if ( ioCount != 4 ) { - tree->comment ( "** Failure reading backSize, ioCount = %d", ioCount ); + if (kind == 8) { + if (time == 0) sprintf(label, "Audio"); // Don't normally print, there are too many. + } + else if (kind == 9) { + if (time == 0) sprintf(label, "Video"); // Don't normally print, there are too many. + } + else if (kind == 18) { + sprintf(label, "ScriptData"); + } + else { + sprintf(label, "", kind); + } + sprintf(comment, "%s @ 0x%X, size=%d, time=%d, stream=%d", label, tagOffset, size, time, stream); + + tree->pushNode(label); + tree->addComment(comment); + + LFA_Seek(file, (tagOffset + 11 + size), SEEK_SET); + ioCount = LFA_Read(file, buffer, 4, true); // Back pointer plus tag header. + if (ioCount != 4) { + tree->comment("** Failure reading backSize, ioCount = %d", ioCount); return; } - backSize = GetUns32BE ( &buffer[0] ); - if ( backSize != (11+size) ) tree->comment ( "** Bad backSize= %d", backSize ); + backSize = GetUns32BE(&buffer[0]); + if (backSize != (11 + size)) tree->comment("** Bad backSize= %d", backSize); - if ( kind == 18 ) { - XMP_Uns32 endOffset = DumpScriptDataTagContent ( file, (tagOffset+11), time ); - if ( endOffset != (tagOffset+11+size) ) { - tree->comment ( "** Bad endOffset = 0x%X", endOffset ); + if (kind == 18) { + XMP_Uns32 endOffset = DumpScriptDataTagContent(file, (tagOffset + 11), time); + if (endOffset != (tagOffset + 11 + size)) { + tree->comment("** Bad endOffset = 0x%X", endOffset); } } - + tree->popNode(); } - - if ( sXMPPtr != 0 ) DumpXMP ( "FLV onXMPData tag" ); + + if (sXMPPtr != 0) DumpXMP("FLV onXMPData tag"); } // DumpFLV -// ================================================================================================= + // ================================================================================================= static bool -PrintID3Encoding ( XMP_Uns8 encoding, XMP_Uns8 * strPtr ) +PrintID3Encoding(XMP_Uns8 encoding, XMP_Uns8 * strPtr) { bool bigEndian = true; - switch ( encoding ) { - case 0 : - tree->addComment ( "Latin1" ); - break; - case 1 : - if ( *strPtr == 0xFF ) bigEndian = false; - tree->addComment ( "UTF-16 with BOM, %s)", (bigEndian ? "BE" : "LE") ); - break; - case 2 : - tree->addComment ( "UTF-16 BE" ); - break; - case 3 : - tree->addComment ( "UTF-8" ); - break; - default : - tree->addComment ( "** unknown **" ); - break; + switch (encoding) { + case 0: + tree->addComment("Latin1"); + break; + case 1: + if (*strPtr == 0xFF) bigEndian = false; + tree->addComment("UTF-16 with BOM, %s)", (bigEndian ? "BE" : "LE")); + break; + case 2: + tree->addComment("UTF-16 BE"); + break; + case 3: + tree->addComment("UTF-8"); + break; + default: + tree->addComment("** unknown **"); + break; } return bigEndian; } // PrintID3Encoding -// ================================================================================================= + // ================================================================================================= -//static void -//PrintID3EncodedText (XMP_Uns8 encoding, void * _strPtr, const char * label) -//{ -//} // PrintID3EncodedText + //static void + //PrintID3EncodedText (XMP_Uns8 encoding, void * _strPtr, const char * label) + //{ + //} // PrintID3EncodedText -// ================================================================================================= + // ================================================================================================= struct ID3_Header { char id3[3]; @@ -4846,95 +5479,100 @@ // ================================================================================================= -static void DumpID3v22Frames ( LFA_FileRef file, XMP_Uns8 /*vMajor*/, XMP_Uns32 framePos, XMP_Uns32 frameEnd ) { +static void DumpID3v22Frames(LFA_FileRef file, XMP_Uns8 vMajor, XMP_Uns32 framePos, XMP_Uns32 frameEnd) { // Dump the frames in an ID3 v2.2 tag. - while ( (framePos < frameEnd) && ((frameEnd - framePos) >= 6) ) { + while ((framePos < frameEnd) && ((frameEnd - framePos) >= 6)) { ID3_v22_FrameHeader frameHead; - LFA_Seek ( file, framePos, SEEK_SET ); - LFA_Read ( file, &frameHead, sizeof(frameHead), true ); + LFA_Seek(file, framePos, SEEK_SET); + LFA_Read(file, &frameHead, sizeof(frameHead), true); - if ( CheckBytes ( frameHead.id, "\x0", 1 ) ) break; // Assume into padding. - // FIXED: there could be just 1 or 2 or 3 bytes of padding total !! + if (CheckBytes(frameHead.id, "\x0", 1)) break; // Assume into padding. + // FIXED: there could be just 1 or 2 or 3 bytes of padding total !! XMP_Uns32 frameSize = ((XMP_Uns32)frameHead.sizeHigh << 16) + GetUns16BE(&frameHead.sizeLow); - tree->setKeyValue ( - fromArgs ( "ID3v2:%.3s", frameHead.id ), "", //no value yet, tree->changeValue() below - fromArgs ( "offset %d (0x%X), size %d", framePos, framePos, frameSize ) ); + tree->setKeyValue( + fromArgs("ID3v2:%.3s", frameHead.id), "", //no value yet, tree->changeValue() below + fromArgs("offset %d (0x%X), size %d", framePos, framePos, frameSize)); - if ( frameSize == 0 ) { + if (frameSize == 0) { // NOTHING TO DO HERE. // i.e. on 0-byte frames, including known ones... // ( i.e. the testcase of a (errorneous) TCON 0 byte frame ) - } else if ( (frameHead.id[0] == 'T') ||(frameHead.id[0] == 'W')) { // Text and URL fields + } + else if ((frameHead.id[0] == 'T') || (frameHead.id[0] == 'W')) { // Text and URL fields - CaptureFileData (file, 0, frameSize); + CaptureFileData(file, 0, frameSize); XMP_Uns8 encoding = 0; XMP_Uns8 skip = 0; - if ( frameHead.id[0] == 'T' ) { // URL field has no encoding byte + if (frameHead.id[0] == 'T') { // URL field has no encoding byte encoding = sDataPtr[0]; skip = 1; } - bool bigEndian = PrintID3Encoding (encoding, (sDataPtr + skip)); - if ( encoding == 0 ) { - tree->changeValue ( convert8Bit ( sDataPtr + skip, false, frameSize-skip ) ); - } else { - tree->changeValue( convert16Bit( bigEndian, sDataPtr + skip, false, (frameSize - skip) ) ); + bool bigEndian = PrintID3Encoding(encoding, (sDataPtr + skip)); + if (encoding == 0) { + tree->changeValue(convert8Bit(sDataPtr + skip, false, frameSize - skip)); + } + else { + tree->changeValue(convert16Bit(bigEndian, sDataPtr + skip, false, (frameSize - skip))); } - } else if (CheckBytes (frameHead.id, "PRV", 3) && (frameSize >= 4)) { + } + else if (CheckBytes(frameHead.id, "PRV", 3) && (frameSize >= 4)) { // checking on the XMP packet - CaptureFileData ( file, 0, frameSize ); //NB: has side effect: sDataLen, sDataMax, sDataPtr - tree->changeValue ( convert8Bit ( sDataPtr, false, strlen((char*)sDataPtr) ) ); - if ( CheckBytes ( sDataPtr, "XMP\x0", 4 ) ) { - CaptureXMPF ( file, (framePos + sizeof(frameHead) + 4), (frameSize - 4) ); + CaptureFileData(file, 0, frameSize); //NB: has side effect: sDataLen, sDataMax, sDataPtr + tree->changeValue(convert8Bit(sDataPtr, false, strlen((char*)sDataPtr))); + if (CheckBytes(sDataPtr, "XMP\x0", 4)) { + CaptureXMPF(file, (framePos + sizeof(frameHead) + 4), (frameSize - 4)); } - } else if ( CheckBytes ( frameHead.id, "COM", 3 ) || CheckBytes ( frameHead.id, "ULT", 3 ) ) { + } + else if (CheckBytes(frameHead.id, "COM", 3) || CheckBytes(frameHead.id, "ULT", 3)) { const char * descrLabel = "ID3v2:COM-descr"; - if ( CheckBytes ( frameHead.id, "ULT", 3 ) ) descrLabel = "ID3v2:ULT-descr"; + if (CheckBytes(frameHead.id, "ULT", 3)) descrLabel = "ID3v2:ULT-descr"; - CaptureFileData ( file, 0, frameSize ); + CaptureFileData(file, 0, frameSize); XMP_Uns8 * frameEnd2 = sDataPtr + frameSize; XMP_Uns8 encoding = sDataPtr[0]; - char * lang = (char*) (sDataPtr + 1); + char * lang = (char*)(sDataPtr + 1); - tree->addComment ( "lang '%.3s'", lang ); - bool bigEndian = PrintID3Encoding ( encoding, (sDataPtr + 4) ); + tree->addComment("lang '%.3s'", lang); + bool bigEndian = PrintID3Encoding(encoding, (sDataPtr + 4)); - if ( encoding == 0 ) { + if (encoding == 0) { XMP_Uns8 * descrPtr = sDataPtr + 4; XMP_Uns8 * valuePtr = descrPtr; - while ( *valuePtr != 0 ) ++valuePtr; + while (*valuePtr != 0) ++valuePtr; ++valuePtr; size_t descrBytes = valuePtr - descrPtr - 1; - tree->changeValue ( convert8Bit ( valuePtr, false, frameEnd2 - valuePtr ) ); - tree->setKeyValue ( descrLabel, convert8Bit ( descrPtr, false, descrBytes ).c_str() ); + tree->changeValue(convert8Bit(valuePtr, false, frameEnd2 - valuePtr)); + tree->setKeyValue(descrLabel, convert8Bit(descrPtr, false, descrBytes).c_str()); - } else { + } + else { - XMP_Uns16 * descrPtr = (XMP_Uns16*) (sDataPtr + 4); + XMP_Uns16 * descrPtr = (XMP_Uns16*)(sDataPtr + 4); XMP_Uns16 * valuePtr = descrPtr; - while ( *valuePtr != 0 ) ++valuePtr; + while (*valuePtr != 0) ++valuePtr; ++valuePtr; size_t descrBytes = 2 * (valuePtr - descrPtr - 1); size_t valueBytes = 2 * ((XMP_Uns16*)frameEnd2 - valuePtr); - tree->changeValue ( convert16Bit ( bigEndian, (XMP_Uns8*) valuePtr, false, valueBytes ) ); - tree->setKeyValue ( descrLabel, convert16Bit ( bigEndian, (XMP_Uns8*) descrPtr, false, descrBytes ).c_str() ); + tree->changeValue(convert16Bit(bigEndian, (XMP_Uns8*)valuePtr, false, valueBytes)); + tree->setKeyValue(descrLabel, convert16Bit(bigEndian, (XMP_Uns8*)descrPtr, false, descrBytes).c_str()); } @@ -4944,221 +5582,226 @@ } - if ( framePos < frameEnd ) { - tree->setKeyValue ( "", "", - fromArgs ( "Padding assumed, offset %d (0x%X), size %d", framePos, framePos, (frameEnd - framePos) ) ); + if (framePos < frameEnd) { + tree->setKeyValue("", "", + fromArgs("Padding assumed, offset %d (0x%X), size %d", framePos, framePos, (frameEnd - framePos))); } } // DumpID3v22Frames -// ================================================================================================= + // ================================================================================================= -static void DumpID3v23Frames ( LFA_FileRef file, XMP_Uns8 vMajor, XMP_Uns32 framePos, XMP_Uns32 frameEnd ) { +static void DumpID3v23Frames(LFA_FileRef file, XMP_Uns8 vMajor, XMP_Uns32 framePos, XMP_Uns32 frameEnd) { // Dump the frames in an ID3 v2.3 or v2.4 tag. int iIterator = 0; - while ( (framePos < frameEnd) && ((frameEnd - framePos) >= 10) ) { + while ((framePos < frameEnd) && ((frameEnd - framePos) >= 10)) { ID3_v23_FrameHeader frameHead; - LFA_Seek ( file, framePos, SEEK_SET ); - LFA_Read ( file, &frameHead, sizeof(frameHead), true ); + LFA_Seek(file, framePos, SEEK_SET); + LFA_Read(file, &frameHead, sizeof(frameHead), true); - if ( CheckBytes ( frameHead.id, "\x0", 1 ) ) break; // Assume into padding. - // FIXED: there could be just 1 or 2 or 3 bytes of padding total !! + if (CheckBytes(frameHead.id, "\x0", 1)) break; // Assume into padding. + // FIXED: there could be just 1 or 2 or 3 bytes of padding total !! - frameHead.size = GetID3Size ( vMajor, &frameHead.size ); - frameHead.flags = GetUns16BE ( &frameHead.flags ); + frameHead.size = GetID3Size(vMajor, &frameHead.size); + frameHead.flags = GetUns16BE(&frameHead.flags); - tree->setKeyValue ( - fromArgs ( "ID3v2:%.4s", frameHead.id ), "", //no value yet, tree->changeValue() below - fromArgs ( "offset %d (0x%X), size %d, flags 0x%.2X", framePos, framePos, frameHead.size, frameHead.flags ) ); + tree->setKeyValue( + fromArgs("ID3v2:%.4s", frameHead.id), "", //no value yet, tree->changeValue() below + fromArgs("offset %d (0x%X), size %d, flags 0x%.2X", framePos, framePos, frameHead.size, frameHead.flags)); - if ( frameHead.size == 0 ) { + if (frameHead.size == 0) { // NOTHING TO DO HERE. // i.e. on 0-byte frames, including known ones... // ( i.e. the testcase of a (errorneous) TCON 0 byte frame ) - } else if ( (frameHead.id[0] == 'T') ||(frameHead.id[0] == 'W')) { // Text and URL fields + } + else if ((frameHead.id[0] == 'T') || (frameHead.id[0] == 'W')) { // Text and URL fields - CaptureFileData (file, 0, frameHead.size); + CaptureFileData(file, 0, frameHead.size); XMP_Uns8 encoding = 0; XMP_Uns8 skip = 0; - if ( frameHead.id[0] == 'T' ) { // URL field has no encoding byte + if (frameHead.id[0] == 'T') { // URL field has no encoding byte encoding = sDataPtr[0]; skip = 1; } - bool bigEndian = PrintID3Encoding (encoding, (sDataPtr + skip)); - if ( (encoding == 0) || (encoding == 3) ) { - tree->changeValue ( convert8Bit( sDataPtr + skip, false, frameHead.size-skip ) ); - } else if ((encoding == 1) || (encoding == 2)) { - tree->changeValue( convert16Bit( bigEndian, sDataPtr + skip, false, (frameHead.size - skip) ) ); + bool bigEndian = PrintID3Encoding(encoding, (sDataPtr + skip)); + if ((encoding == 0) || (encoding == 3)) { + tree->changeValue(convert8Bit(sDataPtr + skip, false, frameHead.size - skip)); + } + else if ((encoding == 1) || (encoding == 2)) { + tree->changeValue(convert16Bit(bigEndian, sDataPtr + skip, false, (frameHead.size - skip))); } - } else if (CheckBytes (frameHead.id, "PRIV", 4) && (frameHead.size >= 4)) { + } + else if (CheckBytes(frameHead.id, "PRIV", 4) && (frameHead.size >= 4)) { // checking on the XMP packet - CaptureFileData ( file, 0, frameHead.size ); //NB: has side effect: sDataLen, sDataMax, sDataPtr - tree->changeValue ( convert8Bit ( sDataPtr, false, strlen((char*)sDataPtr) ) ); - if ( CheckBytes ( sDataPtr, "XMP\x0", 4 ) ) { - CaptureXMPF ( file, (framePos + sizeof(frameHead) + 4), (frameHead.size - 4) ); + CaptureFileData(file, 0, frameHead.size); //NB: has side effect: sDataLen, sDataMax, sDataPtr + tree->changeValue(convert8Bit(sDataPtr, false, strlen((char*)sDataPtr))); + if (CheckBytes(sDataPtr, "XMP\x0", 4)) { + CaptureXMPF(file, (framePos + sizeof(frameHead) + 4), (frameHead.size - 4)); } - } else if ( CheckBytes ( frameHead.id, "COMM", 4 ) || CheckBytes ( frameHead.id, "USLT", 4 ) ) { + } + else if (CheckBytes(frameHead.id, "COMM", 4) || CheckBytes(frameHead.id, "USLT", 4)) { const char * descrLabel = "ID3v2:COMM-descr"; - if ( CheckBytes ( frameHead.id, "USLT", 4 ) ) descrLabel = "ID3v2:USLT-descr"; + if (CheckBytes(frameHead.id, "USLT", 4)) descrLabel = "ID3v2:USLT-descr"; - CaptureFileData ( file, 0, frameHead.size ); + CaptureFileData(file, 0, frameHead.size); XMP_Uns8 * frameEnd2 = sDataPtr + frameHead.size; XMP_Uns8 encoding = sDataPtr[0]; - char * lang = (char*) (sDataPtr + 1); + char * lang = (char*)(sDataPtr + 1); - tree->addComment ( "lang '%.3s'", lang ); - bool bigEndian = PrintID3Encoding ( encoding, (sDataPtr + 4) ); + tree->addComment("lang '%.3s'", lang); + bool bigEndian = PrintID3Encoding(encoding, (sDataPtr + 4)); - if ( (encoding == 0) || (encoding == 3) ) { + if ((encoding == 0) || (encoding == 3)) { XMP_Uns8 * descrPtr = sDataPtr + 4; XMP_Uns8 * valuePtr = descrPtr; - while ( *valuePtr != 0 ) ++valuePtr; + while (*valuePtr != 0) ++valuePtr; ++valuePtr; size_t descrBytes = valuePtr - descrPtr - 1; - tree->changeValue ( convert8Bit ( valuePtr, false, frameEnd2 - valuePtr ) ); - tree->setKeyValue ( descrLabel, convert8Bit ( descrPtr, false, descrBytes ).c_str() ); + tree->changeValue(convert8Bit(valuePtr, false, frameEnd2 - valuePtr)); + tree->setKeyValue(descrLabel, convert8Bit(descrPtr, false, descrBytes).c_str()); - } else if ( (encoding == 1) || (encoding == 2) ) { + } + else if ((encoding == 1) || (encoding == 2)) { - XMP_Uns16 * descrPtr = (XMP_Uns16*) (sDataPtr + 4); + XMP_Uns16 * descrPtr = (XMP_Uns16*)(sDataPtr + 4); XMP_Uns16 * valuePtr = descrPtr; - while ( *valuePtr != 0 ) ++valuePtr; + while (*valuePtr != 0) ++valuePtr; ++valuePtr; size_t descrBytes = 2 * (valuePtr - descrPtr - 1); size_t valueBytes = 2 * ((XMP_Uns16*)frameEnd2 - valuePtr); - tree->changeValue ( convert16Bit ( bigEndian, (XMP_Uns8*) valuePtr, false, valueBytes ) ); - tree->setKeyValue ( descrLabel, convert16Bit ( bigEndian, (XMP_Uns8*) descrPtr, false, descrBytes ).c_str() ); + tree->changeValue(convert16Bit(bigEndian, (XMP_Uns8*)valuePtr, false, valueBytes)); + tree->setKeyValue(descrLabel, convert16Bit(bigEndian, (XMP_Uns8*)descrPtr, false, descrBytes).c_str()); } } - - else if ( CheckBytes ( frameHead.id , "APIC" , 4 ) ) { + + else if (CheckBytes(frameHead.id, "APIC", 4)) { ++iIterator; unsigned int iOffset = 0; - CaptureFileData ( file , 0 , frameHead.size ); + CaptureFileData(file, 0, frameHead.size); char encoding[2]; - memset ( encoding , 0x0 , 2 ); + memset(encoding, 0x0, 2); encoding[0] = sDataPtr[iOffset++]; - tree->setKeyValue ( fromArgs ( "ID3v2:APIC-encodingType_%d" , iIterator ) , encoding ); + tree->setKeyValue(fromArgs("ID3v2:APIC-encodingType_%d", iIterator), encoding); - char * mimeType = ( char* ) (sDataPtr + iOffset); - iOffset += strlen ( mimeType ) + 1; //1 is for null termination - tree->setKeyValue ( fromArgs ( "ID3v2:APIC-mimeType_%d" , iIterator ) , mimeType ); + char * mimeType = (char*)(sDataPtr + iOffset); + iOffset += strlen(mimeType) + 1; //1 is for null termination + tree->setKeyValue(fromArgs("ID3v2:APIC-mimeType_%d", iIterator), mimeType); char pictureType[2]; - memset ( pictureType , 0x0 , 2 ); + memset(pictureType, 0x0, 2); pictureType[0] = sDataPtr[iOffset++]; - tree->setKeyValue ( fromArgs ( "ID3v2:APIC-pictureType_%1d" , iIterator ) , pictureType ); + tree->setKeyValue(fromArgs("ID3v2:APIC-pictureType_%1d", iIterator), pictureType); - bool bigEndian = PrintID3Encoding ( encoding[0] , (sDataPtr + iOffset) ); - if ( encoding[0] == 0x00 ) { + bool bigEndian = PrintID3Encoding(encoding[0], (sDataPtr + iOffset)); + if (encoding[0] == 0x00) { XMP_Uns8 * descrPtr = sDataPtr + iOffset; XMP_Uns8 * valuePtr = descrPtr; - while ( *valuePtr != 0 ) ++valuePtr; + while (*valuePtr != 0) ++valuePtr; ++valuePtr; //Null termination size_t descrBytes = valuePtr - descrPtr; - tree->setKeyValue ( fromArgs ( "ID3v2:APIC-descr_%d" , iIterator ) , convert8Bit ( descrPtr , false , descrBytes - 1 ).c_str ( ) ); + tree->setKeyValue(fromArgs("ID3v2:APIC-descr_%d", iIterator), convert8Bit(descrPtr, false, descrBytes - 1).c_str()); iOffset += descrBytes; } - else if ( encoding[0] == 0x01 ) { + else if (encoding[0] == 0x01) { - XMP_Uns16 * descrPtr = ( XMP_Uns16* ) (sDataPtr + iOffset); + XMP_Uns16 * descrPtr = (XMP_Uns16*)(sDataPtr + iOffset); XMP_Uns16 * valuePtr = descrPtr; - while ( *valuePtr != 0 ) ++valuePtr; + while (*valuePtr != 0) ++valuePtr; ++valuePtr; //Null termination size_t descrBytes = 2 * (valuePtr - descrPtr); - tree->setKeyValue ( fromArgs ( "ID3v2:APIC-descr_%d" , iIterator ) , convert16Bit ( bigEndian , ( XMP_Uns8* ) (descrPtr + 1) , false , descrBytes - 4 ).c_str ( ) ); + tree->setKeyValue(fromArgs("ID3v2:APIC-descr_%d", iIterator), convert16Bit(bigEndian, (XMP_Uns8*)(descrPtr + 1), false, descrBytes - 4).c_str()); iOffset += descrBytes; } - + XMP_Uns8 *picPtr = (sDataPtr + iOffset); unsigned long size_PictureData = frameHead.size - iOffset; - + char picDataSize[11]; - memset ( picDataSize , 0x0 , 11 ); - sprintf ( picDataSize, "%lu", size_PictureData ); + memset(picDataSize, 0x0, 11); + sprintf(picDataSize, "%lu", size_PictureData); std::string picData; - picData.assign ( ( char* ) picPtr , size_PictureData ); + picData.assign((char*)picPtr, size_PictureData); - tree->setKeyValue ( fromArgs ( "ID3v2:APIC-pictureData_%d" , iIterator ) , picData ); - tree->setKeyValue ( fromArgs ( "ID3v2:APIC-pictureDataSize_%d" , iIterator ) , picDataSize ); + tree->setKeyValue(fromArgs("ID3v2:APIC-pictureData_%d", iIterator), picData); + tree->setKeyValue(fromArgs("ID3v2:APIC-pictureDataSize_%d", iIterator), picDataSize); } framePos += (sizeof(frameHead) + frameHead.size); - + } - - if ( iIterator ) { + + if (iIterator) { char noOfAPICs[11]; - memset ( noOfAPICs , 0x0 , 11 ); - sprintf ( noOfAPICs , "%d" , iIterator ); - tree->setKeyValue ( "ID3v2:NoOfAPIC" , noOfAPICs ); + memset(noOfAPICs, 0x0, 11); + sprintf(noOfAPICs, "%d", iIterator); + tree->setKeyValue("ID3v2:NoOfAPIC", noOfAPICs); } - if ( framePos < frameEnd ) { - tree->setKeyValue ( "", "", - fromArgs ( "Padding assumed, offset %d (0x%X), size %d", framePos, framePos, (frameEnd - framePos) ) ); + if (framePos < frameEnd) { + tree->setKeyValue("", "", + fromArgs("Padding assumed, offset %d (0x%X), size %d", framePos, framePos, (frameEnd - framePos))); } } // DumpID3v23Frames -// ================================================================================================= + // ================================================================================================= static void -DumpMP3 ( LFA_FileRef file, XMP_Uns32 /*mp3Len*/ ) +DumpMP3(LFA_FileRef file, XMP_Uns32 /*mp3Len*/) { // ** We're ignoring the effects of the unsync flag, and not checking the CRC (if present). - assert (sizeof(ID3_Header) == 10); - assert (sizeof(ID3_v23_FrameHeader) == 10); + assert(sizeof(ID3_Header) == 10); + assert(sizeof(ID3_v23_FrameHeader) == 10); // Detect ID3v1 header: - if ( LFA_Measure( file ) > 128 ) + if (LFA_Measure(file) > 128) { - LFA_Seek( file, -128, SEEK_END ); - XMP_Uns32 tagID = 0xFFFFFF00 & LFA_ReadUns32_BE( file ); - if ( tagID == 0x54414700 ) // must be "TAG" + LFA_Seek(file, -128, SEEK_END); + XMP_Uns32 tagID = 0xFFFFFF00 & LFA_ReadUns32_BE(file); + if (tagID == 0x54414700) // must be "TAG" { // Dump ID3v1 header: tree->pushNode("ID3v1"); - Rewind( file, 1 ); // read one byte too many... + Rewind(file, 1); // read one byte too many... - tree->digestString( file, "ID3v1:title", 30, false, true ); - tree->digestString( file, "ID3v1:artist", 30, false, true ); - tree->digestString( file, "ID3v1:album", 30, false, true ); - tree->digestString( file, "ID3v1:year", 4, false, true ); - tree->digestString( file, "ID3v1:comment", 30, false, true ); - tree->digest( file, "ID3v1:genreNo", 0, 1 ); + tree->digestString(file, "ID3v1:title", 30, false, true); + tree->digestString(file, "ID3v1:artist", 30, false, true); + tree->digestString(file, "ID3v1:album", 30, false, true); + tree->digestString(file, "ID3v1:year", 4, false, true); + tree->digestString(file, "ID3v1:comment", 30, false, true); + tree->digest(file, "ID3v1:genreNo", 0, 1); // ID3v1.1 trackNo byte dance: - Rewind( file, 3); - LFA_Tell( file ); - if ( LFA_ReadUns8( file ) == 0 ) - tree->digest( file, "ID3v1:trackNo", 0, 1 ); + Rewind(file, 3); + LFA_Tell(file); + if (LFA_ReadUns8(file) == 0) + tree->digest(file, "ID3v1:trackNo", 0, 1); tree->popNode(); } @@ -5166,19 +5809,19 @@ // Dump ID3v2 header: ID3_Header id3Head; - LFA_Seek (file, 0, SEEK_SET); - LFA_Read ( file, &id3Head, sizeof(id3Head), true); + LFA_Seek(file, 0, SEEK_SET); + LFA_Read(file, &id3Head, sizeof(id3Head), true); - if (! CheckBytes (id3Head.id3, "ID3", 3)) { + if (!CheckBytes(id3Head.id3, "ID3", 3)) { tree->setKeyValue("No ID3v2 tag"); return; } - XMP_Uns32 id3Len = GetSyncSafe32 (id3Head.splitSize); + XMP_Uns32 id3Len = GetSyncSafe32(id3Head.splitSize); XMP_Uns32 framePos = sizeof(id3Head); // The offset of the next (first) ID3 frame. XMP_Uns32 frameEnd = framePos + id3Len; - tree->pushNode("ID3v2.%d.%d, size %d, flags 0x%.2X",id3Head.vMajor, id3Head.vMinor, id3Len, id3Head.flags); + tree->pushNode("ID3v2.%d.%d, size %d, flags 0x%.2X", id3Head.vMajor, id3Head.vMinor, id3Len, id3Head.flags); if (id3Head.flags != 0) { tree->addComment("%s%s%s%s", @@ -5188,7 +5831,7 @@ ((id3Head.flags & 0x10) ? ", has footer" : "")); } - if ( (id3Head.vMajor < 2) || (id3Head.vMajor > 4) ) { + if ((id3Head.vMajor < 2) || (id3Head.vMajor > 4)) { tree->addComment(" ** Unrecognized major version tree."); tree->popNode(); return; @@ -5201,113 +5844,115 @@ XMP_Uns32 extHeaderLen; extHeaderLen = tree->digest32u(file); - extHeaderLen = GetID3Size (id3Head.vMajor, &extHeaderLen); + extHeaderLen = GetID3Size(id3Head.vMajor, &extHeaderLen); framePos += (4 + extHeaderLen); - switch ( id3Head.vMajor ) { - - case 2: { - // #error "implement" - break; - } - - case 3: { - XMP_Uns16 extHeaderFlags; - LFA_Read ( file, &extHeaderFlags, 2, true ); - extHeaderFlags = GetUns16BE (&extHeaderFlags); - - XMP_Uns32 padLen; - LFA_Read ( file, &padLen, 4, true ); - padLen = GetUns32BE (&padLen); - - frameEnd -= padLen; - - tree->pushNode("Extended header MajorV3 size %d, flags 0x%.4X, pad size %d", - extHeaderLen, extHeaderFlags, padLen); - - if (extHeaderFlags & 0x8000) { - XMP_Uns32 crc; - LFA_Read ( file, &crc, 4, true ); - crc = GetUns32BE (&crc); - tree->setKeyValue( "CRC" , fromArgs("0x%.8X", crc) ); - } - tree->popNode(); - break; + switch (id3Head.vMajor) { + + case 2: { + // #error "implement" + break; + } + + case 3: { + XMP_Uns16 extHeaderFlags; + LFA_Read(file, &extHeaderFlags, 2, true); + extHeaderFlags = GetUns16BE(&extHeaderFlags); + + XMP_Uns32 padLen; + LFA_Read(file, &padLen, 4, true); + padLen = GetUns32BE(&padLen); + + frameEnd -= padLen; + + tree->pushNode("Extended header MajorV3 size %d, flags 0x%.4X, pad size %d", + extHeaderLen, extHeaderFlags, padLen); + + if (extHeaderFlags & 0x8000) { + XMP_Uns32 crc; + LFA_Read(file, &crc, 4, true); + crc = GetUns32BE(&crc); + tree->setKeyValue("CRC", fromArgs("0x%.8X", crc)); } - - case 4: { - XMP_Uns8 flagCount; - LFA_Read ( file, &flagCount, 1, true ); - - tree->pushNode("Extended header MajorV4 size %d, flag count %d", extHeaderLen, flagCount); - - for (size_t i = 0; i < flagCount; ++i) { - XMP_Uns8 flag; - LFA_Read ( file, &flag, 1, true ); - tree->setKeyValue( fromArgs( "Flag %.2d", flag ) , fromArgs( "0x%.2X", flag ) ); - } - tree->popNode(); - break; + tree->popNode(); + break; + } + + case 4: { + XMP_Uns8 flagCount; + LFA_Read(file, &flagCount, 1, true); + + tree->pushNode("Extended header MajorV4 size %d, flag count %d", extHeaderLen, flagCount); + + for (size_t i = 0; i < flagCount; ++i) { + XMP_Uns8 flag; + LFA_Read(file, &flag, 1, true); + tree->setKeyValue(fromArgs("Flag %.2d", flag), fromArgs("0x%.2X", flag)); } - - default: - tree->addComment ( "unknown major version !" ); - break; - + tree->popNode(); + break; + } + + default: + tree->addComment("unknown major version !"); + break; + } } //////////////////////////////////////////////////// // Dump the ID3 frames - - if ( id3Head.vMajor == 2 ) { - DumpID3v22Frames ( file, id3Head.vMajor, framePos, frameEnd ); - } else { - DumpID3v23Frames ( file, id3Head.vMajor, framePos, frameEnd ); + + if (id3Head.vMajor == 2) { + DumpID3v22Frames(file, id3Head.vMajor, framePos, frameEnd); + } + else { + DumpID3v23Frames(file, id3Head.vMajor, framePos, frameEnd); } - if (sXMPPtr != 0) DumpXMP ("ID3 'PRIV' \"XMP\" frame"); + if (sXMPPtr != 0) DumpXMP("ID3 'PRIV' \"XMP\" frame"); tree->popNode(); } // DumpMP3 -// ================================================================================================= + // ================================================================================================= static void -PacketScan (LFA_FileRef file, XMP_Int64 fileLen) +PacketScan(LFA_FileRef file, XMP_Int64 fileLen) { try { - XMPScanner scanner (fileLen); - LFA_Seek (file, 0, SEEK_SET); + XMPScanner scanner(fileLen); + LFA_Seek(file, 0, SEEK_SET); - XMP_Uns8 buffer [64*1024]; + XMP_Uns8 buffer[64 * 1024]; XMP_Uns32 filePos, readLen; for (filePos = 0; filePos < fileLen; filePos += readLen) { - readLen = LFA_Read ( file, buffer, sizeof(buffer), false ); - if (readLen == 0) throw std::logic_error ("Empty read"); - scanner.Scan (buffer, filePos, readLen); + readLen = LFA_Read(file, buffer, sizeof(buffer), false); + if (readLen == 0) throw std::logic_error("Empty read"); + scanner.Scan(buffer, filePos, readLen); } size_t snipCount = scanner.GetSnipCount(); - XMPScanner::SnipInfoVector snips (snipCount); - scanner.Report (snips); + XMPScanner::SnipInfoVector snips(snipCount); + scanner.Report(snips); size_t packetCount = 0; for (size_t s = 0; s < snipCount; ++s) { if (snips[s].fState == XMPScanner::eValidPacketSnip) { ++packetCount; - CaptureXMPF (file, (XMP_Uns32)snips[s].fOffset, (XMP_Uns32)snips[s].fLength); - DumpXMP ("packet scan"); + CaptureXMPF(file, (XMP_Uns32)snips[s].fOffset, (XMP_Uns32)snips[s].fLength); + DumpXMP("packet scan"); } } if (packetCount == 0) tree->addComment(" No packets found"); - } catch (...) { + } + catch (...) { tree->addComment("** Scanner failure tree."); @@ -5315,8 +5960,8 @@ } // PacketScan -// ================================================================================================= -// External Routines + // ================================================================================================= + // External Routines namespace DumpFile_NS { // ! Xcode compiler warns about normal offsetof macro. @@ -5332,104 +5977,104 @@ // is not ANSI-C thus things could go wrong on one platform or another... // // returns nothing, but asserts will be triggered if something is wrong. - static bool selfTestDone=false; + static bool selfTestDone = false; void selfTest() { //only very first call at each runtime runs the selfTest (mostly verify about structPacking etc...) if (DumpFile_NS::selfTestDone) return; - assert (sizeof (ASF_GUID) == 16); - assert (SafeOffsetOf (ASF_GUID, part1) == 0); + assert(sizeof(ASF_GUID) == 16); + assert(SafeOffsetOf(ASF_GUID, part1) == 0); - assert (SafeOffsetOf (ASF_GUID, part2) == 4); - assert (SafeOffsetOf (ASF_GUID, part3) == 6); - assert (SafeOffsetOf (ASF_GUID, part4) == 8); - assert (SafeOffsetOf (ASF_GUID, part5) == 10); - - assert (sizeof (ASF_ObjHeader) == (16 + 8)); - assert (SafeOffsetOf (ASF_ObjHeader, guid) == 0); - assert (SafeOffsetOf (ASF_ObjHeader, size) == 16); - - assert (sizeof (ASF_FileProperties) == kASF_FilePropertiesSize); - assert (SafeOffsetOf (ASF_FileProperties, guid) == 0); - assert (SafeOffsetOf (ASF_FileProperties, size) == 16); - assert (SafeOffsetOf (ASF_FileProperties, fileID) == 24); - assert (SafeOffsetOf (ASF_FileProperties, fileSize) == 40); - assert (SafeOffsetOf (ASF_FileProperties, creationDate) == 48); - assert (SafeOffsetOf (ASF_FileProperties, dataPacketsCount) == 56); - assert (SafeOffsetOf (ASF_FileProperties, playDuration) == 64); - assert (SafeOffsetOf (ASF_FileProperties, sendDuration) == 72); - assert (SafeOffsetOf (ASF_FileProperties, preroll) == 80); - assert (SafeOffsetOf (ASF_FileProperties, flags) == 88); - assert (SafeOffsetOf (ASF_FileProperties, minDataPacketSize) == 92); - assert (SafeOffsetOf (ASF_FileProperties, maxDataPacketSize) == 96); - assert (SafeOffsetOf (ASF_FileProperties, maxBitrate) == 100); - - assert (sizeof (ASF_ContentDescription) == kASF_ContentDescriptionSize); - assert (SafeOffsetOf (ASF_ContentDescription, guid) == 0); - assert (SafeOffsetOf (ASF_ContentDescription, size) == 16); - assert (SafeOffsetOf (ASF_ContentDescription, titleLen) == 24); - assert (SafeOffsetOf (ASF_ContentDescription, authorLen) == 26); - assert (SafeOffsetOf (ASF_ContentDescription, copyrightLen) == 28); - assert (SafeOffsetOf (ASF_ContentDescription, descriptionLen) == 30); - assert (SafeOffsetOf (ASF_ContentDescription, ratingLen) == 32); - - assert (sizeof (InDesignMasterPage) == kINDD_PageSize); - assert (SafeOffsetOf (InDesignMasterPage, fGUID) == 0); - assert (SafeOffsetOf (InDesignMasterPage, fMagicBytes) == 16); - assert (SafeOffsetOf (InDesignMasterPage, fObjectStreamEndian) == 24); - assert (SafeOffsetOf (InDesignMasterPage, fIrrelevant1) == 25); - assert (SafeOffsetOf (InDesignMasterPage, fSequenceNumber) == 264); - assert (SafeOffsetOf (InDesignMasterPage, fIrrelevant2) == 272); - assert (SafeOffsetOf (InDesignMasterPage, fFilePages) == 280); - assert (SafeOffsetOf (InDesignMasterPage, fIrrelevant3) == 284); - - assert (sizeof (InDesignContigObjMarker) == 32); - assert (SafeOffsetOf (InDesignContigObjMarker, fGUID) == 0); - assert (SafeOffsetOf (InDesignContigObjMarker, fObjectUID) == 16); - assert (SafeOffsetOf (InDesignContigObjMarker, fObjectClassID) == 20); - assert (SafeOffsetOf (InDesignContigObjMarker, fStreamLength) == 24); - assert (SafeOffsetOf (InDesignContigObjMarker, fChecksum) == 28); + assert(SafeOffsetOf(ASF_GUID, part2) == 4); + assert(SafeOffsetOf(ASF_GUID, part3) == 6); + assert(SafeOffsetOf(ASF_GUID, part4) == 8); + assert(SafeOffsetOf(ASF_GUID, part5) == 10); + + assert(sizeof(ASF_ObjHeader) == (16 + 8)); + assert(SafeOffsetOf(ASF_ObjHeader, guid) == 0); + assert(SafeOffsetOf(ASF_ObjHeader, size) == 16); + + assert(sizeof(ASF_FileProperties) == kASF_FilePropertiesSize); + assert(SafeOffsetOf(ASF_FileProperties, guid) == 0); + assert(SafeOffsetOf(ASF_FileProperties, size) == 16); + assert(SafeOffsetOf(ASF_FileProperties, fileID) == 24); + assert(SafeOffsetOf(ASF_FileProperties, fileSize) == 40); + assert(SafeOffsetOf(ASF_FileProperties, creationDate) == 48); + assert(SafeOffsetOf(ASF_FileProperties, dataPacketsCount) == 56); + assert(SafeOffsetOf(ASF_FileProperties, playDuration) == 64); + assert(SafeOffsetOf(ASF_FileProperties, sendDuration) == 72); + assert(SafeOffsetOf(ASF_FileProperties, preroll) == 80); + assert(SafeOffsetOf(ASF_FileProperties, flags) == 88); + assert(SafeOffsetOf(ASF_FileProperties, minDataPacketSize) == 92); + assert(SafeOffsetOf(ASF_FileProperties, maxDataPacketSize) == 96); + assert(SafeOffsetOf(ASF_FileProperties, maxBitrate) == 100); + + assert(sizeof(ASF_ContentDescription) == kASF_ContentDescriptionSize); + assert(SafeOffsetOf(ASF_ContentDescription, guid) == 0); + assert(SafeOffsetOf(ASF_ContentDescription, size) == 16); + assert(SafeOffsetOf(ASF_ContentDescription, titleLen) == 24); + assert(SafeOffsetOf(ASF_ContentDescription, authorLen) == 26); + assert(SafeOffsetOf(ASF_ContentDescription, copyrightLen) == 28); + assert(SafeOffsetOf(ASF_ContentDescription, descriptionLen) == 30); + assert(SafeOffsetOf(ASF_ContentDescription, ratingLen) == 32); + + assert(sizeof(InDesignMasterPage) == kINDD_PageSize); + assert(SafeOffsetOf(InDesignMasterPage, fGUID) == 0); + assert(SafeOffsetOf(InDesignMasterPage, fMagicBytes) == 16); + assert(SafeOffsetOf(InDesignMasterPage, fObjectStreamEndian) == 24); + assert(SafeOffsetOf(InDesignMasterPage, fIrrelevant1) == 25); + assert(SafeOffsetOf(InDesignMasterPage, fSequenceNumber) == 264); + assert(SafeOffsetOf(InDesignMasterPage, fIrrelevant2) == 272); + assert(SafeOffsetOf(InDesignMasterPage, fFilePages) == 280); + assert(SafeOffsetOf(InDesignMasterPage, fIrrelevant3) == 284); + + assert(sizeof(InDesignContigObjMarker) == 32); + assert(SafeOffsetOf(InDesignContigObjMarker, fGUID) == 0); + assert(SafeOffsetOf(InDesignContigObjMarker, fObjectUID) == 16); + assert(SafeOffsetOf(InDesignContigObjMarker, fObjectClassID) == 20); + assert(SafeOffsetOf(InDesignContigObjMarker, fStreamLength) == 24); + assert(SafeOffsetOf(InDesignContigObjMarker, fChecksum) == 28); - selfTestDone=true; + selfTestDone = true; } // selfTest } /*namespace DumpFile_NS*/ -// ------------------------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------------------------- -void DumpFile::Scan (std::string filename, TagTree &tagTree, bool resetTree) +void DumpFile::Scan(std::string filename, TagTree &tagTree, bool resetTree) { DumpFile_NS::selfTest(); //calls selftest (will happen only once per runtime, optimization done) - if( resetTree ) + if (resetTree) { tagTree.reset(); } tree = &tagTree; // static "global" helper to avoid looping throug 'tree' 24x7 - // Read the first 4K of the file into a local buffer and determine the file format. - // ! We're using ANSI C calls that don't handle files over 2GB. - // ! Should switch to copies of the "LFA" routines used inside XMP. + // Read the first 4K of the file into a local buffer and determine the file format. + // ! We're using ANSI C calls that don't handle files over 2GB. + // ! Should switch to copies of the "LFA" routines used inside XMP. - LFA_FileRef fileRef = LFA_Open( filename.c_str(), 'r' ); + LFA_FileRef fileRef = LFA_Open(filename.c_str(), 'r'); - assertMsg ( std::string("can't open ")+filename, fileRef != 0 ); + assertMsg(std::string("can't open ") + filename, fileRef != 0); - LFA_Seek( fileRef, 0, SEEK_END ); + LFA_Seek(fileRef, 0, SEEK_END); XMP_Int64 fileLen = LFA_Tell(fileRef); - XMP_Uns8 first4K [4096]; + XMP_Uns8 first4K[4096]; - LFA_Seek ( fileRef, 0, SEEK_SET ); - LFA_Read ( fileRef, first4K, 4096, false); + LFA_Seek(fileRef, 0, SEEK_SET); + LFA_Read(fileRef, first4K, 4096, false); - LFA_Seek ( fileRef, 0, SEEK_SET ); //rewinds - // (remains rewinded behind CheckFileDFormat, since that call does not get the fileRef handle) + LFA_Seek(fileRef, 0, SEEK_SET); //rewinds + // (remains rewinded behind CheckFileDFormat, since that call does not get the fileRef handle) - XMP_FileFormat format = CheckFileFormat ( filename.c_str(), first4K, fileLen ); + XMP_FileFormat format = CheckFileFormat(filename.c_str(), first4K, fileLen); - if ( sXMPPtr != 0) free(sXMPPtr); + if (sXMPPtr != 0) free(sXMPPtr); sXMPPtr = 0; sXMPMax = 0; sXMPLen = 0; @@ -5438,158 +6083,178 @@ //TODO refactor-out XMP_Uns8 * fileContent = 0; // *** Hack for old file-in-RAM code. - if ( format == kXMP_JPEGFile ) { + if (format == kXMP_JPEGFile) { - tagTree.pushNode ( "Dumping JPEG file" ); - tagTree.addComment ( "size %lld (0x%llx)", fileLen, fileLen ); + tagTree.pushNode("Dumping JPEG file"); + tagTree.addComment("size %lld (0x%llx)", fileLen, fileLen); { - fileContent = (XMP_Uns8*) malloc(fileLen); - LFA_Seek ( fileRef, 0, SEEK_SET ); - LFA_Read ( fileRef, fileContent, fileLen, true ); - DumpJPEG ( fileContent, fileLen ); + fileContent = (XMP_Uns8*)malloc(fileLen); + LFA_Seek(fileRef, 0, SEEK_SET); + LFA_Read(fileRef, fileContent, fileLen, true); + DumpJPEG(fileContent, fileLen); } tagTree.popNode(); - } else if ( format == kXMP_PhotoshopFile ) { + } + else if (format == kXMP_PhotoshopFile) { - tagTree.pushNode ( "Dumping Photoshop file" ); - tagTree.addComment ( "size %lld (0x%llx)", fileLen, fileLen ); + tagTree.pushNode("Dumping Photoshop file"); + tagTree.addComment("size %lld (0x%llx)", fileLen, fileLen); { - fileContent = (XMP_Uns8*) malloc(fileLen); - LFA_Seek ( fileRef, 0, SEEK_SET ); - LFA_Read ( fileRef, fileContent, fileLen, true); - DumpPhotoshop ( fileContent, fileLen ); + fileContent = (XMP_Uns8*)malloc(fileLen); + LFA_Seek(fileRef, 0, SEEK_SET); + LFA_Read(fileRef, fileContent, fileLen, true); + DumpPhotoshop(fileContent, fileLen); } tagTree.popNode(); - } else if ( format == kXMP_TIFFFile ) { + } + else if (format == kXMP_TIFFFile) { - tagTree.pushNode ( "Dumping TIFF file" ); - tagTree.addComment ( "size %lld (0x%llx)", fileLen, fileLen ); + tagTree.pushNode("Dumping TIFF file"); + tagTree.addComment("size %lld (0x%llx)", fileLen, fileLen); { - fileContent = (XMP_Uns8*) malloc(fileLen); - LFA_Seek ( fileRef, 0, SEEK_SET ); - LFA_Read ( fileRef, fileContent, fileLen, true); - DumpTIFF ( fileContent, fileLen, 0, "TIFF file" , ""); + fileContent = (XMP_Uns8*)malloc(fileLen); + LFA_Seek(fileRef, 0, SEEK_SET); + LFA_Read(fileRef, fileContent, fileLen, true); + DumpTIFF(fileContent, fileLen, 0, "TIFF file", ""); } tagTree.popNode(); - } else if ( format == kXMP_WMAVFile ) { + } + else if (format == kXMP_WMAVFile) { - tagTree.pushNode ( "Dumping ASF (WMA/WMV) file" ); - tagTree.addComment ( "size %lld (0x%llx)", fileLen, fileLen ); - DumpASF ( fileRef, fileLen ); + tagTree.pushNode("Dumping ASF (WMA/WMV) file"); + tagTree.addComment("size %lld (0x%llx)", fileLen, fileLen); + DumpASF(fileRef, fileLen); tagTree.popNode(); - } else if ( format == kXMP_AVIFile ) { + } + else if (format == kXMP_AVIFile) { - tagTree.pushNode ( "Dumping AVI file" ); - tagTree.addComment ( "size %lld (0x%llx)", fileLen, fileLen ); - DumpRIFF ( fileRef, fileLen ); + tagTree.pushNode("Dumping AVI file"); + tagTree.addComment("size %lld (0x%llx)", fileLen, fileLen); + DumpRIFF(fileRef, fileLen); tagTree.popNode(); - } else if ( format == kXMP_WAVFile ) { + } + else if (format == kXMP_WAVFile) { - tagTree.pushNode ( "Dumping WAV file" ); - tagTree.addComment ( "size %lld (0x%llx)", fileLen, fileLen ); - DumpRIFF ( fileRef, fileLen ); + tagTree.pushNode("Dumping WAV file"); + tagTree.addComment("size %lld (0x%llx)", fileLen, fileLen); + DumpRIFF(fileRef, fileLen); tagTree.popNode(); - } else if ( format == kXMP_AIFFFile ) { + } + else if (format == kXMP_AIFFFile) { - tagTree.pushNode ( "Dumping AIFF file" ); - tagTree.addComment ( "size %lld (0x%llx)", fileLen, fileLen ); - DumpAIFF ( fileRef, fileLen ); + tagTree.pushNode("Dumping AIFF file"); + tagTree.addComment("size %lld (0x%llx)", fileLen, fileLen); + DumpAIFF(fileRef, fileLen); tagTree.popNode(); - } else if ( format == kXMP_MPEG4File || format == kXMP_MOVFile || format == kXMP_JPEG2KFile ) { - // all ISO formats ( MPEG4, MOV, JPEG2000) handled jointly, + } + else if (format == kXMP_MPEG4File || format == kXMP_MOVFile || format == kXMP_JPEG2KFile || format == kXMP_HEIFFile) { + // all ISO formats ( MPEG4, MOV, JPEG2000,HEIF) handled jointly, // - no longer relying on any advance "isQT" flagging - tagTree.pushNode ( "ISO file" ); - Log::info("size: %d", fileLen ); - tagTree.addComment ( "size %I64d (0x%I64X)", fileLen, fileLen ); - DumpISO( fileRef, fileLen ); + tagTree.pushNode("ISO file"); + Log::info("size: %d", fileLen); + // tagTree.addComment ( "size %I64d (0x%I64X)", fileLen, fileLen ); + tagTree.addComment("size %lld (0x%llX)", fileLen, fileLen); + ISOMetaKeys.clear(); + DumpISO(fileRef, fileLen); tagTree.popNode(); - } else if ( format == kXMP_PNGFile ) { + } + else if (format == kXMP_PNGFile) { - tagTree.pushNode ( "Dumping PNG file" ); - tagTree.addComment ( "size %lld (0x%llx)", fileLen, fileLen ); - DumpPNG ( fileRef, fileLen ); + tagTree.pushNode("Dumping PNG file"); + tagTree.addComment("size %lld (0x%llx)", fileLen, fileLen); + DumpPNG(fileRef, fileLen); tagTree.popNode(); - } else if ( format == kXMP_InDesignFile ) { + } + else if (format == kXMP_InDesignFile) { - tagTree.pushNode ( "Dumping InDesign file" ); - tagTree.addComment ( "size %lld (0x%llx)", fileLen, fileLen ); - DumpInDesign ( fileRef, fileLen ); + tagTree.pushNode("Dumping InDesign file"); + tagTree.addComment("size %lld (0x%llx)", fileLen, fileLen); + DumpInDesign(fileRef, fileLen); tagTree.popNode(); - } else if ( format == kXMP_SWFFile ) { + } + else if (format == kXMP_SWFFile) { - tagTree.pushNode ( "Dumping SWF file" ); - tagTree.addComment ( "size %lld (0x%llx)", fileLen, fileLen ); - DumpSWF ( fileRef, fileLen ); + tagTree.pushNode("Dumping SWF file"); + tagTree.addComment("size %lld (0x%llx)", fileLen, fileLen); + DumpSWF(fileRef, fileLen); tagTree.popNode(); - } else if ( format == kXMP_FLVFile ) { + } + else if (format == kXMP_FLVFile) { - tagTree.pushNode ( "Dumping FLV file" ); - tagTree.addComment ( "size %lld (0x%llx)", fileLen, fileLen ); - DumpFLV ( fileRef, fileLen ); + tagTree.pushNode("Dumping FLV file"); + tagTree.addComment("size %lld (0x%llx)", fileLen, fileLen); + DumpFLV(fileRef, fileLen); tagTree.popNode(); - } else if ( format == kXMP_MP3File ) { + } + else if (format == kXMP_MP3File) { - tagTree.pushNode ( "Dumping MP3 file" ); - tagTree.addComment ( "size %lld (0x%llx)", fileLen, fileLen ); - DumpMP3 ( fileRef, fileLen ); + tagTree.pushNode("Dumping MP3 file"); + tagTree.addComment("size %lld (0x%llx)", fileLen, fileLen); + DumpMP3(fileRef, fileLen); tagTree.popNode(); - } else if ( format == kXMP_UCFFile ) { + } + else if (format == kXMP_UCFFile) { - tagTree.pushNode ( "Dumping UCF (Universal Container Format) file" ); - tagTree.addComment ( "size %lld (0x%llx)", fileLen, fileLen ); - DumpUCF ( fileRef, fileLen ); + tagTree.pushNode("Dumping UCF (Universal Container Format) file"); + tagTree.addComment("size %lld (0x%llx)", fileLen, fileLen); + DumpUCF(fileRef, fileLen); tagTree.popNode(); - } else if ( format == kXMP_MPEGFile ) { + } + else if (format == kXMP_MPEGFile) { - tagTree.comment ( "** Recognized MPEG-2 file type, but this is a pure sidecar solution. No legacy dump available at this time." ); + tagTree.comment("** Recognized MPEG-2 file type, but this is a pure sidecar solution. No legacy dump available at this time."); - } else if ( format == kXMP_PostScriptFile ) { + } + else if (format == kXMP_PostScriptFile) { - tagTree.pushNode ( "Dumping PostScript file" ); - tagTree.addComment ( "size %lld (0x%llx)", fileLen, fileLen ); - DumpPS ( fileRef, fileLen ); + tagTree.pushNode("Dumping PostScript file"); + tagTree.addComment("size %lld (0x%llx)", fileLen, fileLen); + DumpPS(fileRef, fileLen); tagTree.popNode(); - } else if ( format == kXMP_SVGFile ) { + } + else if (format == kXMP_SVGFile) { - tagTree.pushNode ( "Dumping SVG file" ); - tagTree.addComment ( "size %lld (0x%llx)", fileLen, fileLen ); - DumpSVG ( fileRef, fileLen ); - tagTree.popNode ( ); - } else if ( format == kXMP_UnknownFile ) { + tagTree.pushNode("Dumping SVG file"); + tagTree.addComment("size %lld (0x%llx)", fileLen, fileLen); + DumpSVG(fileRef, fileLen); + tagTree.popNode(); + } + else if (format == kXMP_UnknownFile) { - tagTree.pushNode ( "Unknown format. packet scanning, size %d (0x%X)", fileLen, fileLen ); - PacketScan ( fileRef, fileLen ); + tagTree.pushNode("Unknown format. packet scanning, size %d (0x%X)", fileLen, fileLen); + PacketScan(fileRef, fileLen); tagTree.popNode(); - } else { - tagTree.comment ( "** Recognized file type, '%.4s', but no smart dumper for it.", &format ); + } + else { + tagTree.comment("** Recognized file type, '%.4s', but no smart dumper for it.", &format); } - if ( fileContent != 0) free(fileContent); + if (fileContent != 0) free(fileContent); LFA_Close(fileRef); } // DumpFile -void DumpFile::dumpFile( std::string filename ) +void DumpFile::dumpFile(std::string filename) { TagTree localTree; - DumpFile::Scan( filename , localTree ); // (important test in itself for validity) + DumpFile::Scan(filename, localTree); // (important test in itself for validity) localTree.dumpTree(); } diff -Nru exempi-2.5.2/samples/source/common/globals.h exempi-2.6.1/samples/source/common/globals.h --- exempi-2.5.2/samples/source/common/globals.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/samples/source/common/globals.h 2021-11-18 03:53:54.000000000 +0000 @@ -17,13 +17,13 @@ #include //sanity check platform/endianess - #if !defined(WIN_ENV) && !defined(MAC_ENV) && !defined(UNIX_ENV) && !defined(IOS_ENV) - #error "XMP environment error - must define one of MAC_ENV, WIN_ENV, UNIX_ENV or IOS_ENV" + #if !defined(WIN_ENV) && !defined(MAC_ENV) && !defined(UNIX_ENV) && !defined(IOS_ENV) && !defined(ANDROID_ENV) + #error "XMP environment error - must define one of MAC_ENV, WIN_ENV, UNIX_ENV or IOS_ENV or ANDROID_ENV" #endif #ifdef WIN_ENV #define XMPQE_LITTLE_ENDIAN 1 - #elif (defined(MAC_ENV) || defined(IOS_ENV)) + #elif (defined(MAC_ENV) || defined(IOS_ENV)) || defined(ANDROID_ENV) #if __BIG_ENDIAN__ #define XMPQE_BIG_ENDIAN 1 #elif __LITTLE_ENDIAN__ @@ -39,11 +39,13 @@ #define XMPQE_BIG_ENDIAN 0 #endif #else - #error "Unknown build environment, neither WIN_ENV nor MAC_ENV nor UNIX_ENV" + #error "Unknown build environment, neither WIN_ENV nor MAC_ENV nor UNIX_ENV nor ANDROID_ENV" #endif const static unsigned int XMPQE_BUFFERSIZE=4096; //should do for all my buffer output, but you never now (stdarg dilemma) + + const char OMNI_CSTRING[]={0x41,0xE4,0xB8,0x80,0x42,0xE4,0xBA,0x8C,0x43,0xC3,0x96,0x44,0xF0,0x90,0x81,0x91,0x45,'\0'}; const char BOM_CSTRING[]={0xEF,0xBB,0xBF,'\0'}; // nb: forgetting the '\0' is a very evil mistake. const std::string OMNI_STRING(OMNI_CSTRING); diff -Nru exempi-2.5.2/samples/source/common/TagTree.cpp exempi-2.6.1/samples/source/common/TagTree.cpp --- exempi-2.5.2/samples/source/common/TagTree.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/samples/source/common/TagTree.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -158,13 +158,15 @@ // require all == false => leave the throwing to this routine if (numOfBytes != LFA_Read ( file, value, numOfBytes, false)) // saying 1,4 guarantes read as ordered (4,1 would not) Log::error("could not read %d number of files (End of File reached?)",numOfBytes); -#if !IOS_ENV +#if !IOS_ENV && !WIN_UNIVERSAL_ENV char* out=new char[2 + numOfBytes*3 + 5]; //'0x12 34 45 78 ' length formula: 2 ("0x") + numOfBytes x 3 + 5 (padding) if (!key.empty()) { snprintf(out,3,"0x"); XMP_Int64 i; // *) - for (i=0; i < numOfBytes; i++) - snprintf(&out[2+i*3],4,"%.2X ",value[i]); //always must allow that extra 0-byte on mac (overwritten again and again) + for (i = 0; i < numOfBytes; i++) + { + snprintf(&out[2 + i * 3], 4, "%.2X ", value[i]); //always must allow that extra 0-byte on mac (overwritten again and again) + } snprintf(&out[2+i*3],1,"%c",'\0'); // *) using i one more time (needed while bug 1613297 regarding snprintf not fixed) setKeyValue(key,out); } @@ -180,7 +182,7 @@ } #endif - delete [] out; + delete[] out; if (!returnValue) delete [] value; //if we own it, we delete it } @@ -245,7 +247,7 @@ if ( ((kBigEndianHost==1) && !BigEndian ) || ((kBigEndianHost==0) && BigEndian )) // "XOR" Flip4(&r); if (!key.empty()) { - char out[15]; //longest signed int is "–2147483648", 11 chars + char out[15]; //longest signed int is "-2147483648", 11 chars snprintf(out,14,"%d",r); //signed, mind the trailing \0 on Mac btw setKeyValue(key,out); } @@ -278,7 +280,7 @@ if ( ((kBigEndianHost==1) && !BigEndian ) || ((kBigEndianHost==0) && BigEndian )) // "XOR" Flip2(&r); if (!key.empty()) { - char out[10]; //longest signed int is "–32768", 6 chars + char out[10]; //longest signed int is "�32768", 6 chars snprintf(out,9,"%d",r); setKeyValue(key,out); } @@ -511,6 +513,8 @@ // 3 points for doing it here: shortness, convenience, 64bit forks needed #if WIN_ENV addComment( "offset: 0x%I64X", LFA_Tell( file ) ); + #elif ANDROID_ENV + addComment( "offset: 0x%llX", LFA_Tell( file ) ); #else addComment( "offset: 0x%ll.16X", LFA_Tell( file ) ); #endif diff -Nru exempi-2.5.2/samples/source/CustomSchema.cpp exempi-2.6.1/samples/source/CustomSchema.cpp --- exempi-2.5.2/samples/source/CustomSchema.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/samples/source/CustomSchema.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2008 Adobe Systems Incorporated +// Copyright 2008 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= /** diff -Nru exempi-2.5.2/samples/source/DumpMainXMP.cpp exempi-2.6.1/samples/source/DumpMainXMP.cpp --- exempi-2.5.2/samples/source/DumpMainXMP.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/samples/source/DumpMainXMP.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2002 Adobe Systems Incorporated +// Copyright 2002 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= /** @@ -84,7 +84,7 @@ ok = xmpFile.GetFileInfo ( 0, &openFlags, &format, &handlerFlags ); if ( ! ok ) return; - fprintf ( sLogFile, "File info : format = \"%.4s\", handler flags = %.8X\n", &format, handlerFlags ); + fprintf ( sLogFile, "File info : format = %.8X, handler flags = %.8X\n", format, handlerFlags ); fflush ( sLogFile ); ok = xmpFile.GetXMP ( &xmpMeta, 0, &xmpPacket ); diff -Nru exempi-2.5.2/samples/source/DumpScannedXMP.cpp exempi-2.6.1/samples/source/DumpScannedXMP.cpp --- exempi-2.5.2/samples/source/DumpScannedXMP.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/samples/source/DumpScannedXMP.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2002 Adobe Systems Incorporated +// Copyright 2002 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= /** @@ -64,12 +64,12 @@ { std::string xmlString; xmlString.append ( length, ' ' ); - fseek ( inFile, offset, SEEK_SET ); + fseek ( inFile, (long)offset, SEEK_SET ); fread ( (void*)xmlString.data(), 1, length, inFile ); char title [1000]; - sprintf ( title, "// Dumping raw input for \"%s\" (%lu..%lu)", fileName, offset, (offset + length - 1) ); + sprintf ( title, "// Dumping raw input for \"%s\" (%zu..%zu)", fileName, offset, (offset + length - 1) ); printf ( "// " ); for ( size_t i = 3; i < strlen(title); ++i ) printf ( "=" ); printf ( "\n\n%s\n\n%.*s\n\n", title, (int)length, xmlString.c_str() ); @@ -77,7 +77,7 @@ SXMPMeta xmpObj; try { - xmpObj.ParseFromBuffer ( xmlString.c_str(), length ); + xmpObj.ParseFromBuffer ( xmlString.c_str(), (XMP_StringLen)length ); } catch ( ... ) { printf ( "## Parse failed\n\n" ); return; @@ -88,11 +88,11 @@ string xmpString; xmpObj.SerializeToBuffer ( &xmpString, kXMP_OmitPacketWrapper ); - printf ( "\nPretty serialization, %lu bytes :\n\n%s\n", xmpString.size(), xmpString.c_str() ); + printf ( "\nPretty serialization, %zu bytes :\n\n%s\n", xmpString.size(), xmpString.c_str() ); fflush ( stdout ); xmpObj.SerializeToBuffer ( &xmpString, (kXMP_OmitPacketWrapper | kXMP_UseCompactFormat) ); - printf ( "Compact serialization, %lu bytes :\n\n%s\n", xmpString.size(), xmpString.c_str() ); + printf ( "Compact serialization, %zu bytes :\n\n%s\n", xmpString.size(), xmpString.c_str() ); fflush ( stdout ); } // ProcessPacket diff -Nru exempi-2.5.2/samples/source/Makefile.in exempi-2.6.1/samples/source/Makefile.in --- exempi-2.5.2/samples/source/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/samples/source/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -421,6 +421,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/samples/source/ModifyingXMP.cpp exempi-2.6.1/samples/source/ModifyingXMP.cpp --- exempi-2.5.2/samples/source/ModifyingXMP.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/samples/source/ModifyingXMP.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2008 Adobe Systems Incorporated +// Copyright 2008 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= /** diff -Nru exempi-2.5.2/samples/source/ReadingXMP.cpp exempi-2.6.1/samples/source/ReadingXMP.cpp --- exempi-2.5.2/samples/source/ReadingXMP.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/samples/source/ReadingXMP.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2008 Adobe Systems Incorporated +// Copyright 2008 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= /** diff -Nru exempi-2.5.2/samples/source/xmpcommand/Actions.cpp exempi-2.6.1/samples/source/xmpcommand/Actions.cpp --- exempi-2.5.2/samples/source/xmpcommand/Actions.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/samples/source/xmpcommand/Actions.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2006 Adobe Systems Incorporated +// Copyright 2006 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= // actions.cpp|h diff -Nru exempi-2.5.2/samples/source/xmpcommand/Actions.h exempi-2.6.1/samples/source/xmpcommand/Actions.h --- exempi-2.5.2/samples/source/xmpcommand/Actions.h 2016-12-07 05:07:54.000000000 +0000 +++ exempi-2.6.1/samples/source/xmpcommand/Actions.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2006 Adobe Systems Incorporated +// Copyright 2006 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef __ACTIONS_h__ diff -Nru exempi-2.5.2/samples/source/xmpcommand/PrintUsage.cpp exempi-2.6.1/samples/source/xmpcommand/PrintUsage.cpp --- exempi-2.5.2/samples/source/xmpcommand/PrintUsage.cpp 2016-12-07 05:07:54.000000000 +0000 +++ exempi-2.6.1/samples/source/xmpcommand/PrintUsage.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2006 Adobe Systems Incorporated +// Copyright 2006 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "samples/source/common/globals.h" diff -Nru exempi-2.5.2/samples/source/xmpcommand/PrintUsage.h exempi-2.6.1/samples/source/xmpcommand/PrintUsage.h --- exempi-2.5.2/samples/source/xmpcommand/PrintUsage.h 2016-12-07 05:07:54.000000000 +0000 +++ exempi-2.6.1/samples/source/xmpcommand/PrintUsage.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2006 Adobe Systems Incorporated +// Copyright 2006 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef __XMPQE_PRINT_USAGE_h__ diff -Nru exempi-2.5.2/samples/source/xmpcommand/XMPCommand.cpp exempi-2.6.1/samples/source/xmpcommand/XMPCommand.cpp --- exempi-2.5.2/samples/source/xmpcommand/XMPCommand.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/samples/source/xmpcommand/XMPCommand.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2005 Adobe Systems Incorporated +// Copyright 2005 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= /** diff -Nru exempi-2.5.2/samples/source/XMPCoreCoverage.cpp exempi-2.6.1/samples/source/XMPCoreCoverage.cpp --- exempi-2.5.2/samples/source/XMPCoreCoverage.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/samples/source/XMPCoreCoverage.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2002 Adobe Systems Incorporated +// Copyright 2002 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= /** @@ -388,7 +388,7 @@ for ( size_t i = 0; i < xmp.size(); ++i ) { if ( (xmp[i] == '\x0A') || (xmp[i] == '\x0D') ) { if ( strncmp ( &xmp[i], newline, strlen(newline) ) != 0 ) { - fprintf ( log, "** Wrong newline at offset %d\n", i ); + fprintf ( log, "** Wrong newline at offset %zd\n", i ); } if ( strlen(newline) == 2 ) ++i; } @@ -1091,27 +1091,27 @@ tmpStr2.erase(); meta.SerializeToBuffer ( &tmpStr1 ); meta.SerializeToBuffer ( &tmpStr2, kXMP_IncludeThumbnailPad ); - fprintf ( log, "Thumbnailpad adds %d bytes\n", tmpStr2.size()-tmpStr1.size() ); + fprintf ( log, "Thumbnailpad adds %zd bytes\n", tmpStr2.size()-tmpStr1.size() ); tmpStr1.erase(); meta.SerializeToBuffer ( &tmpStr1, kXMP_ReadOnlyPacket ); size_t minSize = tmpStr1.size(); - fprintf ( log, "Minimum packet size is %d bytes\n", minSize ); + fprintf ( log, "Minimum packet size is %zd bytes\n", minSize ); tmpStr1.erase(); meta.SerializeToBuffer ( &tmpStr1, kXMP_ExactPacketLength, minSize+1234 ); - fprintf ( log, "Minimum+1234 packet size is %d bytes\n", tmpStr1.size() ); + fprintf ( log, "Minimum+1234 packet size is %zd bytes\n", tmpStr1.size() ); if ( tmpStr1.size() != (minSize + 1234) ) fprintf ( log, "** Bad packet length **\n" ); tmpStr1.erase(); meta.SerializeToBuffer ( &tmpStr1, kXMP_ExactPacketLength, minSize ); - fprintf ( log, "Minimum+0 packet size is %d bytes\n", tmpStr1.size() ); + fprintf ( log, "Minimum+0 packet size is %zd bytes\n", tmpStr1.size() ); if ( tmpStr1.size() != minSize ) fprintf ( log, "** Bad packet length **\n" ); try { tmpStr1.erase(); meta.SerializeToBuffer ( &tmpStr1, kXMP_ExactPacketLength, minSize-1 ); - fprintf ( log, "#ERROR: No exception for minimum-1, size is %d bytes **\n", tmpStr1.size() ); + fprintf ( log, "#ERROR: No exception for minimum-1, size is %zd bytes **\n", tmpStr1.size() ); } catch ( XMP_Error & excep ) { fprintf ( log, "Serialize in minimum-1 - threw XMP_Error #%d : %s\n", excep.GetID(), excep.GetErrMsg() ); } catch ( ... ) { @@ -1538,19 +1538,19 @@ tmpStr1 = "0"; int1 = SXMPUtils::ConvertToInt ( tmpStr1 ); - fprintf ( log, "ConvertToInt 0 : %d\n", int1 ); + fprintf ( log, "ConvertToInt 0 : %ld\n", int1 ); int1 = SXMPUtils::ConvertToInt ( "42" ); - fprintf ( log, "ConvertToInt 42 : %d\n", int1 ); + fprintf ( log, "ConvertToInt 42 : %ld\n", int1 ); int1 = SXMPUtils::ConvertToInt ( "-42" ); - fprintf ( log, "ConvertToInt -42 : %d\n", int1 ); + fprintf ( log, "ConvertToInt -42 : %ld\n", int1 ); int1 = SXMPUtils::ConvertToInt ( "0x7FFFFFFF" ); - fprintf ( log, "ConvertToInt 0x7FFFFFFF : %d\n", int1 ); + fprintf ( log, "ConvertToInt 0x7FFFFFFF : %ld\n", int1 ); int1 = SXMPUtils::ConvertToInt ( "0x80000000" ); - fprintf ( log, "ConvertToInt 0x80000000 : %d\n", int1 ); + fprintf ( log, "ConvertToInt 0x80000000 : %ld\n", int1 ); int1 = SXMPUtils::ConvertToInt ( "0x7FFFFFFF" ); - fprintf ( log, "ConvertToInt 0x7FFFFFFF as hex : %X\n", int1 ); + fprintf ( log, "ConvertToInt 0x7FFFFFFF as hex : %lX\n", int1 ); int1 = SXMPUtils::ConvertToInt ( "0x80000000" ); - fprintf ( log, "ConvertToInt 0x80000000 as hex : %X\n", int1 ); + fprintf ( log, "ConvertToInt 0x80000000 as hex : %lX\n", int1 ); fprintf ( log, "\n" ); diff -Nru exempi-2.5.2/samples/source/XMPFilesCoverage.cpp exempi-2.6.1/samples/source/XMPFilesCoverage.cpp --- exempi-2.5.2/samples/source/XMPFilesCoverage.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/samples/source/XMPFilesCoverage.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2002 Adobe Systems Incorporated +// Copyright 2002 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= /** @@ -81,8 +81,8 @@ format = kXMP_ ## fmt ## File; \ flags = 0; \ ok = SXMPFiles::GetFormatInfo ( format, &flags ); \ - fprintf ( sLogFile, "kXMP_" #fmt "File = \"%.4s\", %s, flags = 0x%X\n", \ - &format, (ok ? "smart" : "dumb"), flags ); + fprintf ( sLogFile, "kXMP_" #fmt "File = %.8X, %s, flags = 0x%X\n", \ + format, (ok ? "smart" : "dumb"), flags ); static void DumpHandlerInfo() { @@ -158,8 +158,8 @@ ok = xmpFile->GetFileInfo ( 0, &openFlags, &format, &handlerFlags ); if ( ! ok ) return; - fprintf ( sLogFile, "File info : format = \"%.4s\", handler flags = 0x%X, open flags = 0x%X (%s)\n", - &format, handlerFlags, openFlags, (isUpdate ? "update" : "read-only") ); + fprintf ( sLogFile, "File info : format = %.8X, handler flags = 0x%X, open flags = 0x%X (%s)\n", + format, handlerFlags, openFlags, (isUpdate ? "update" : "read-only") ); ok = xmpFile->GetXMP ( xmpMeta, 0, &xmpPacket ); if ( ! ok ) { diff -Nru exempi-2.5.2/samples/testfiles/Makefile.in exempi-2.6.1/samples/testfiles/Makefile.in --- exempi-2.5.2/samples/testfiles/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/samples/testfiles/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -296,6 +296,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/source/Endian.h exempi-2.6.1/source/Endian.h --- exempi-2.5.2/source/Endian.h 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/source/Endian.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,11 +1,11 @@ /************************************************************************** * -* ADOBE SYSTEMS INCORPORATED -* Copyright 2010 Adobe Systems Incorporated +* Copyright Adobe +* Copyright 2010 Adobe * All Rights Reserved * * NOTICE: Adobe permits you to use, modify, and distribute this file in -* accordance with the terms of the Adobe license agreement accompanying it. +* accordance with the terms of the Adobe license agreement accompanying it. * **************************************************************************/ diff -Nru exempi-2.5.2/source/EndianUtils.hpp exempi-2.6.1/source/EndianUtils.hpp --- exempi-2.5.2/source/EndianUtils.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/source/EndianUtils.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,20 +2,20 @@ #define __EndianUtils_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. #include "public/include/XMP_Const.h" -#if SUNOS_SPARC || SUNOS || XMP_IOS_ARM +#if SUNOS_SPARC || SUNOS || XMP_IOS_ARM || XMP_ANDROID_ARM #include "string.h" -#endif //SUNOS_SPARC || SUNOS || XMP_IOS_ARM +#endif //SUNOS_SPARC || SUNOS || XMP_IOS_ARM || XMP_ANDROID_ARM // *** These should be in a more common location. The Unicode conversions of XMPCore have similar utils. // *** May want to improve with PowerPC swapping load/store, or SSE instructions. @@ -34,8 +34,30 @@ #else #error "Neither __BIG_ENDIAN__ nor __LITTLE_ENDIAN__ is set" #endif +#elif XMP_AndroidBuild + #if __BIG_ENDIAN__ + #define kBigEndianHost 1 + #elif __LITTLE_ENDIAN__ + #define kBigEndianHost 0 + #else + #error "Neither __BIG_ENDIAN__ nor __LITTLE_ENDIAN__ is set" + #endif #elif XMP_UNIXBuild +// Use this endian check that is more reliable as it takes into account +// Non Intel or Sparc. #include "public/include/XMP_UnixEndian.h" + /* + #ifndef kBigEndianHost // Typically in the makefile for generic UNIX. + #if __GNUC__ && (__i386__ || __x86_64__) + #define kBigEndianHost 0 + #elif __GNUC__ && (__sparc__) + #define kBigEndianHost 1 + #define kLittleEndianHost 0 + #else + #error "Must define kBigEndianHost as 0 or 1 in the makefile." + #endif + #endif + */ #else #error "Unknown build environment" #endif @@ -62,7 +84,7 @@ // ================================================================================================= -#if SUNOS_SPARC || SUNOS || XMP_IOS_ARM +#if SUNOS_SPARC || SUNOS || XMP_IOS_ARM || XMP_ANDROID_ARM #define DefineAndGetValue(type,addr) type value = 0; memcpy ( &value, addr, sizeof(type) ) #define DefineAndSetValue(type,addr) memcpy(addr, &value, sizeof(type)) #define DefineFlipAndSet(type,x,addr) type temp; memcpy(&temp, addr, sizeof(type)); temp = Flip##x(temp); memcpy(addr, &temp, sizeof(type)) @@ -70,7 +92,7 @@ #define DefineAndGetValue(type,addr) type value = *((type*)addr) #define DefineAndSetValue(type,addr) *((type*)addr) = value #define DefineFlipAndSet(type,x,addr) type* uPtr = (type*) addr; *uPtr = Flip##x ( *uPtr ) -#endif //#if SUNOS_SPARC || SUNOS || XMP_IOS_ARM +#endif //#if SUNOS_SPARC || SUNOS || XMP_IOS_ARM || XMP_ANDROID_ARM // ------------------------------------------------------------------------------------------------- diff -Nru exempi-2.5.2/source/ExpatAdapter.hpp exempi-2.6.1/source/ExpatAdapter.hpp --- exempi-2.5.2/source/ExpatAdapter.hpp 2017-01-29 18:00:29.000000000 +0000 +++ exempi-2.6.1/source/ExpatAdapter.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,11 +2,11 @@ #define __ExpatAdapter_hpp__ // ================================================================================================= -// Copyright 2005 Adobe Systems Incorporated +// Copyright 2005 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! Must be the first #include! diff -Nru exempi-2.5.2/source/Host_IO.hpp exempi-2.6.1/source/Host_IO.hpp --- exempi-2.5.2/source/Host_IO.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/source/Host_IO.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,11 +2,11 @@ #define __Host_IO_hpp__ 1 // ================================================================================================= -// Copyright 2010 Adobe Systems Incorporated +// Copyright 2010 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. @@ -21,7 +21,7 @@ #elif XMP_MacBuild #include #include // Mac uses the POSIX folder functions. -#elif XMP_UNIXBuild | XMP_iOSBuild +#elif XMP_UNIXBuild | XMP_iOSBuild | XMP_AndroidBuild #include #else #error "Unknown host platform." @@ -99,12 +99,14 @@ #if XMP_WinBuild typedef HANDLE FileRef; static const FileRef noFileRef = INVALID_HANDLE_VALUE; - #elif XMP_MacBuild - typedef FSIORefNum FileRef; + #elif XMP_AndroidBuild + typedef int FileRef; static const FileRef noFileRef = -1; - #elif XMP_UNIXBuild | XMP_iOSBuild + typedef off64_t XMP_off_t; + #elif XMP_MacBuild | XMP_UNIXBuild | XMP_iOSBuild typedef int FileRef; static const FileRef noFileRef = -1; + typedef off_t XMP_off_t; #endif bool Exists ( const char* filePath ); @@ -168,7 +170,7 @@ #elif XMP_MacBuild typedef DIR* FolderRef; static const FolderRef noFolderRef = 0; - #elif XMP_UNIXBuild | XMP_iOSBuild + #elif XMP_UNIXBuild | XMP_iOSBuild | XMP_AndroidBuild typedef DIR* FolderRef; static const FolderRef noFolderRef = 0; #endif diff -Nru exempi-2.5.2/source/Host_IO-POSIX.cpp exempi-2.6.1/source/Host_IO-POSIX.cpp --- exempi-2.5.2/source/Host_IO-POSIX.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/source/Host_IO-POSIX.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. @@ -22,7 +22,7 @@ #include #include -#if (SUNOS_SPARC || SUNOS_X86 || XMP_IOS_ARM) +#if (SUNOS_SPARC || SUNOS_X86 || XMP_IOS_ARM || XMP_ANDROID_ARM) #include #endif @@ -30,8 +30,8 @@ // Host_IO implementations for POSIX // ================================= -#if (! XMP_MacBuild) & (! XMP_UNIXBuild) & (! XMP_iOSBuild) - #error "This is the POSIX implementation of Host_IO for Mac, iOS and general UNIX." +#if (! XMP_MacBuild) & (! XMP_UNIXBuild) & (! XMP_iOSBuild) & (! XMP_AndroidBuild) + #error "This is the POSIX implementation of Host_IO for Mac, iOS , Android and general UNIX." #endif // ================================================================================================= @@ -39,7 +39,9 @@ // ================================================================================================= // Make sure off_t is 64 bits and signed. -// static char check_off_t_size [ (sizeof(off_t) == 8) ? 1 : -1 ]; +// Due to bug in NDK r12b size of off_t at 32 bit systems is 32 bit despite giving _FILE_OFFSET_BITS=64 flag. So only for Android off64_t is used +// UNUSED -- hub static char check_off_t_size [ (sizeof(Host_IO::XMP_off_t) == 8) ? 1 : -1 ]; + // *** No std::numeric_limits? static char check_off_t_sign [ std::numeric_limits::is_signed ? -1 : 1 ]; static bool HaveWriteAccess( const std::string & path ); @@ -387,8 +389,8 @@ XMP_Int64 Host_IO::Length ( Host_IO::FileRef refNum ) { - off_t currPos = lseek ( refNum, 0, kXMP_SeekFromCurrent ); - off_t length = lseek ( refNum, 0, kXMP_SeekFromEnd ); + Host_IO::XMP_off_t currPos = lseek ( refNum, 0, kXMP_SeekFromCurrent ); + Host_IO::XMP_off_t length = lseek ( refNum, 0, kXMP_SeekFromEnd ); if ( (currPos == -1) || (length == -1) ) XMP_Throw ( "Host_IO::Length, lseek failure", kXMPErr_ExternalFailure ); (void) lseek ( refNum, currPos, kXMP_SeekFromStart ); @@ -491,7 +493,7 @@ // Host_IO::GetNextChild // ===================== -#if (SUNOS_SPARC || SUNOS_X86 || XMP_IOS_ARM) +#if (SUNOS_SPARC || SUNOS_X86 || XMP_IOS_ARM || XMP_ANDROID_ARM) class SafeMalloc { public: void* pointer; @@ -509,7 +511,7 @@ if ( folder == Host_IO::noFolderRef ) return false; - #if ! (SUNOS_SPARC || SUNOS_X86 || XMP_IOS_ARM) + #if ! (SUNOS_SPARC || SUNOS_X86 || XMP_IOS_ARM || XMP_ANDROID_ARM) struct dirent _childInfo; struct dirent* childInfo = &_childInfo; #else diff -Nru exempi-2.5.2/source/Host_IO-Win.cpp exempi-2.6.1/source/Host_IO-Win.cpp --- exempi-2.5.2/source/Host_IO-Win.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/source/Host_IO-Win.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. @@ -125,8 +125,19 @@ } Host_IO::FileRef fileHandle; +#ifdef WIN_UNIVERSAL_ENV + CREATEFILE2_EXTENDED_PARAMETERS params; + params.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS); + params.dwFileAttributes = (FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS); + params.lpSecurityAttributes = 0; + params.hTemplateFile = 0; + params.dwFileFlags = 0; + params.dwSecurityQosFlags = 0; + fileHandle = CreateFile2((LPCWSTR)wideName.data(), (GENERIC_READ | GENERIC_WRITE), 0, CREATE_ALWAYS, ¶ms); +#else fileHandle = CreateFileW ( (LPCWSTR)wideName.data(), (GENERIC_READ | GENERIC_WRITE), 0, 0, CREATE_ALWAYS, - (FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS), 0 ); + (FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS), 0 ); +#endif if ( fileHandle == INVALID_HANDLE_VALUE ) XMP_Throw ( "Host_IO::Create, cannot create file", kXMPErr_InternalFailure );; CloseHandle ( fileHandle ); @@ -305,11 +316,13 @@ if ( ::Exists ( wideNewPath ) ) XMP_Throw ( "Host_IO::Rename, new path exists", kXMPErr_InternalFailure ); - - - BOOL ok = MoveFileW ( (LPCWSTR)wideOldPath.data(), (LPCWSTR)wideNewPath.data() ); - if ( ! ok ) XMP_Throw ( "Host_IO::Rename, MoveFileW failure", kXMPErr_ExternalFailure ); - +#if XMP_UWP + BOOL ok = MoveFileExW((LPCWSTR)wideOldPath.data(), (LPCWSTR)wideNewPath.data(), MOVEFILE_REPLACE_EXISTING); + if (!ok) XMP_Throw("Host_IO::Rename, MoveFileExW failure", kXMPErr_ExternalFailure); +#else + BOOL ok = MoveFileW((LPCWSTR)wideOldPath.data(), (LPCWSTR)wideNewPath.data()); + if (!ok) XMP_Throw("Host_IO::Rename, MoveFileW failure", kXMPErr_ExternalFailure); +#endif } // Host_IO::Rename // ================================================================================================= @@ -490,7 +503,11 @@ std::string utf16; // FindFirstFile wants native UTF-16. if ( !GetWidePath ( findPath.c_str(), utf16 ) ) XMP_Throw ( "Host_IO::OpenFolder, GetWidePath failure", kXMPErr_ExternalFailure ); +#if XMP_UWP + Host_IO::FolderRef folder = FindFirstFileExW((LPCWSTR)utf16.c_str(), FindExInfoStandard,&childInfo, FindExSearchNameMatch,NULL, FIND_FIRST_EX_CASE_SENSITIVE); +#else Host_IO::FolderRef folder = FindFirstFileW ( (LPCWSTR) utf16.c_str(), &childInfo ); +#endif if ( folder == noFolderRef ) XMP_Throw ( "Host_IO::OpenFolder - FindFirstFileW failed", kXMPErr_ExternalFailure ); // The first child should be ".", which we want to ignore anyway. XMP_Assert ( (folder == noFolderRef) || (childInfo.cFileName[0] == '.') ); @@ -626,7 +643,16 @@ bool Exists ( const std::string & widePath ) { - DWORD attrs = GetFileAttributesW ( (LPCWSTR)widePath.data() ); + DWORD attrs = INVALID_FILE_ATTRIBUTES; +#if XMP_UWP + _WIN32_FILE_ATTRIBUTE_DATA fileDataAttr; + fileDataAttr.dwFileAttributes = INVALID_FILE_ATTRIBUTES; + if(GetFileAttributesExW((LPCWSTR)widePath.data(), GetFileExInfoStandard, &fileDataAttr)) + attrs = fileDataAttr.dwFileAttributes; +#else + attrs = GetFileAttributesW ( (LPCWSTR)widePath.data() ); +#endif + return ( attrs != INVALID_FILE_ATTRIBUTES); } @@ -634,7 +660,14 @@ Host_IO::FileMode GetFileMode ( const std::string & widePath ) { // ! A shortcut is seen as a file, we would need extra code to recognize it and find the target. - DWORD fileAttrs = GetFileAttributesW ( (LPCWSTR) widePath.c_str() ); + DWORD fileAttrs = INVALID_FILE_ATTRIBUTES; +#if XMP_UWP + _WIN32_FILE_ATTRIBUTE_DATA fileDataAttr; + if(GetFileAttributesExW((LPCWSTR)widePath.data(), GetFileExInfoStandard, &fileDataAttr)) + fileAttrs = fileDataAttr.dwFileAttributes; +#else + fileAttrs = GetFileAttributesW ( (LPCWSTR) widePath.c_str() ); +#endif if ( fileAttrs == INVALID_FILE_ATTRIBUTES ) return Host_IO::kFMode_DoesNotExist; // ! Any failure turns into does-not-exist. if ( fileAttrs & FILE_ATTRIBUTE_DIRECTORY ) return Host_IO::kFMode_IsFolder; @@ -654,8 +687,21 @@ } Host_IO::FileRef fileHandle; + +#if XMP_UWP + CREATEFILE2_EXTENDED_PARAMETERS params; + params.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS); + params.dwFileAttributes = (FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS); + params.lpSecurityAttributes = 0; + params.hTemplateFile = 0; + params.dwFileFlags = 0; + params.dwSecurityQosFlags = 0; + fileHandle = CreateFile2((LPCWSTR)widePath.data(), access, share, OPEN_EXISTING, ¶ms); +#else fileHandle = CreateFileW ( (LPCWSTR)widePath.data(), access, share, 0, OPEN_EXISTING, (FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS), 0 ); +#endif + if ( fileHandle == INVALID_HANDLE_VALUE ) { DWORD osCode = GetLastError(); if ( (osCode == ERROR_FILE_NOT_FOUND) || (osCode == ERROR_PATH_NOT_FOUND) || (osCode == ERROR_FILE_OFFLINE) ) { @@ -680,8 +726,20 @@ } Host_IO::FileRef fileHandle; + +#if WIN_UNIVERSAL_ENV + CREATEFILE2_EXTENDED_PARAMETERS params; + params.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS); + params.dwFileAttributes = (FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS); + params.lpSecurityAttributes = 0; + params.hTemplateFile = 0; + params.dwFileFlags = 0; + params.dwSecurityQosFlags = 0; + fileHandle = CreateFile2((LPCWSTR)widePath.data(), access, share, OPEN_EXISTING, ¶ms); +#else fileHandle = CreateFileW ( (LPCWSTR)widePath.data(), access, share, 0, OPEN_EXISTING, (FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS), 0 ); +#endif if ( fileHandle == INVALID_HANDLE_VALUE ) { DWORD osCode = GetLastError(); if ( (osCode == ERROR_FILE_NOT_FOUND) || (osCode == ERROR_PATH_NOT_FOUND) || (osCode == ERROR_FILE_OFFLINE) ) { @@ -746,14 +804,18 @@ std::string partialPath=utfPath.substr(0,newpos); if ( ! GetWidePath(partialPath.c_str(), widePath) || widePath.length() == 0) XMP_Throw ( "Host_IO::GetCasePresevedLeafName, cannot convert path", kXMPErr_ExternalFailure ); - searchNext = ::FindFirstFileW ( (LPCWSTR) widePath.c_str(), &fileInfo ); +#if XMP_UWP + searchNext = FindFirstFileExW((LPCWSTR)widePath.c_str(), FindExInfoStandard, &fileInfo, FindExSearchNameMatch, NULL, FIND_FIRST_EX_CASE_SENSITIVE); +#else + searchNext = ::FindFirstFileW((LPCWSTR)widePath.c_str(), &fileInfo); +#endif if( searchNext == INVALID_HANDLE_VALUE || ! ::FindClose(searchNext) ) XMP_Throw ( "Host_IO::GetCasePresevedLeafName, cannot convert path", kXMPErr_ExternalFailure ); allocate_size=::WideCharToMultiByte(CP_UTF8,0,fileInfo.cFileName,-1,NULL,0,NULL,NULL); leafname.reserve(allocate_size); leafname.assign ( allocate_size , 0 ); - retValue=::WideCharToMultiByte(CP_UTF8,0,fileInfo.cFileName,-1,(LPSTR)leafname.data(),leafname.length(),NULL,NULL); + retValue=::WideCharToMultiByte(CP_UTF8,0,fileInfo.cFileName,-1,(LPSTR)leafname.data(),(int)(leafname.length()),NULL,NULL); if ( ! retValue ) XMP_Throw ( "Host_IO::GetCasePresevedLeafName, cannot convert path", kXMPErr_ExternalFailure ); } @@ -781,6 +843,7 @@ // ============================= std::string Host_IO::GetCasePreservedName( const std::string& inputPath ) { +#ifndef XMP_UWP if ( ! ContainsNonASCIICodePoints( inputPath ) ) { DWORD allocate_size,retValue; @@ -812,6 +875,7 @@ return systempath.c_str(); } else +#endif { return ConstructPreservedPath( inputPath ); } diff -Nru exempi-2.5.2/source/IOUtils.cpp exempi-2.6.1/source/IOUtils.cpp --- exempi-2.5.2/source/IOUtils.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/source/IOUtils.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2013 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2013 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "source/IOUtils.hpp" diff -Nru exempi-2.5.2/source/IOUtils.hpp exempi-2.6.1/source/IOUtils.hpp --- exempi-2.5.2/source/IOUtils.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/source/IOUtils.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,11 +2,11 @@ #define __IOUtils_hpp__ 1 // ================================================================================================= -// Copyright 2013 Adobe Systems Incorporated +// Copyright 2013 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= diff -Nru exempi-2.5.2/source/Makefile.in exempi-2.6.1/source/Makefile.in --- exempi-2.5.2/source/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/source/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -374,6 +374,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/source/PerfUtils.cpp exempi-2.6.1/source/PerfUtils.cpp --- exempi-2.5.2/source/PerfUtils.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/source/PerfUtils.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2006 Adobe Systems Incorporated +// Copyright 2006 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" @@ -75,7 +75,7 @@ // ================================================================================================= -#if XMP_UNIXBuild +#if XMP_UNIXBuild | XMP_AndroidBuild const char * PerfUtils::GetTimerInfo() { diff -Nru exempi-2.5.2/source/PerfUtils.hpp exempi-2.6.1/source/PerfUtils.hpp --- exempi-2.5.2/source/PerfUtils.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/source/PerfUtils.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,11 +2,11 @@ #define __PerfUtils_hpp__ 1 // ================================================================================================= -// Copyright 2006 Adobe Systems Incorporated +// Copyright 2006 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" @@ -15,7 +15,7 @@ #include #elif XMP_WinBuild #include -#elif XMP_UNIXBuild | XMP_iOSBuild +#elif XMP_UNIXBuild | XMP_iOSBuild | XMP_AndroidBuild #include #endif @@ -25,7 +25,7 @@ // typedef LARGE_INTEGER MomentValue; typedef LONGLONG MomentValue; static const MomentValue kZeroMoment = 0; - #elif XMP_UNIXBuild + #elif XMP_UNIXBuild | XMP_AndroidBuild typedef struct timespec MomentValue; static const MomentValue kZeroMoment = {0, 0}; #elif XMP_iOSBuild | XMP_MacBuild diff -Nru exempi-2.5.2/source/SafeStringAPIs.cpp exempi-2.6.1/source/SafeStringAPIs.cpp --- exempi-2.5.2/source/SafeStringAPIs.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/source/SafeStringAPIs.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,20 +1,10 @@ -/************************************************************************* -* -* ADOBE CONFIDENTIAL -* ___________________ -* -* Copyright 2010 Adobe Systems Incorporated -* All Rights Reserved. -* -* NOTICE: All information contained herein is, and remains -* the property of Adobe Systems Incorporated and its suppliers, -* if any. The intellectual and technical concepts contained -* herein are proprietary to Adobe Systems Incorporated and its -* suppliers and are protected by trade secret or copyright law. -* Dissemination of this information or reproduction of this material -* is strictly forbidden unless prior written permission is obtained -* from Adobe Systems Incorporated. -**************************************************************************/ +// ================================================================================================= +// Copyright 2020 Adobe +// All Rights Reserved. +// NOTICE: Adobe permits you to use, modify, and distribute this file in +// accordance with the terms of the Adobe license agreement accompanying +// it. +// ================================================================================================= #include /* Include standard ANSI C stuff: size_t, NULL etc */ #include /* memmove etc. defined here */ @@ -315,7 +305,7 @@ *buffer = '\0'; return 0; } - SafeInt32 n = (count + 1) < size ? (count + 1) : size; //MIN(count+1, size); + SafeInt32 n = (SafeInt32)((count + 1) < size ? (count + 1) : size); //MIN(count+1, size); SafeInt32 numBytes = vsnprintf(buffer, n, format, argp); if(numBytes >= static_cast(size) && count >= size) { diff -Nru exempi-2.5.2/source/SafeStringAPIs.h exempi-2.6.1/source/SafeStringAPIs.h --- exempi-2.5.2/source/SafeStringAPIs.h 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/source/SafeStringAPIs.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,20 +1,10 @@ -/************************************************************************* -* -* ADOBE CONFIDENTIAL -* ___________________ -* -* Copyright 2010 Adobe Systems Incorporated -* All Rights Reserved. -* -* NOTICE: All information contained herein is, and remains -* the property of Adobe Systems Incorporated and its suppliers, -* if any. The intellectual and technical concepts contained -* herein are proprietary to Adobe Systems Incorporated and its -* suppliers and are protected by trade secret or copyright law. -* Dissemination of this information or reproduction of this material -* is strictly forbidden unless prior written permission is obtained -* from Adobe Systems Incorporated. -**************************************************************************/ +// ================================================================================================= +// Copyright 2020 Adobe +// All Rights Reserved. +// NOTICE: Adobe permits you to use, modify, and distribute this file in +// accordance with the terms of the Adobe license agreement accompanying +// it. +// ================================================================================================= //Safe String APIs Version 1.0 diff -Nru exempi-2.5.2/source/SafeTypes.h exempi-2.6.1/source/SafeTypes.h --- exempi-2.5.2/source/SafeTypes.h 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/source/SafeTypes.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,21 +1,10 @@ -/************************************************************************* -* -* ADOBE CONFIDENTIAL -* ___________________ -* -* Copyright 2010 Adobe Systems Incorporated -* All Rights Reserved. -* -* NOTICE: All information contained herein is, and remains -* the property of Adobe Systems Incorporated and its suppliers, -* if any. The intellectual and technical concepts contained -* herein are proprietary to Adobe Systems Incorporated and its -* suppliers and are protected by trade secret or copyright law. -* Dissemination of this information or reproduction of this material -* is strictly forbidden unless prior written permission is obtained -* from Adobe Systems Incorporated. -**************************************************************************/ - +// ================================================================================================= +// Copyright 2020 Adobe +// All Rights Reserved. +// NOTICE: Adobe permits you to use, modify, and distribute this file in +// accordance with the terms of the Adobe license agreement accompanying +// it. +// ================================================================================================= //SafeTypes Version 1.0 @@ -24,6 +13,7 @@ #include /* Include standard ANSI C stuff: size_t, NULL etc */ + /* Integer types The following chart shows signed and unsigned integer types. diff -Nru exempi-2.5.2/source/SuppressSAL.h exempi-2.6.1/source/SuppressSAL.h --- exempi-2.5.2/source/SuppressSAL.h 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/source/SuppressSAL.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,20 +1,10 @@ -/************************************************************************* -* -* ADOBE CONFIDENTIAL -* ___________________ -* -* Copyright 2010 Adobe Systems Incorporated -* All Rights Reserved. -* -* NOTICE: All information contained herein is, and remains -* the property of Adobe Systems Incorporated and its suppliers, -* if any. The intellectual and technical concepts contained -* herein are proprietary to Adobe Systems Incorporated and its -* suppliers and are protected by trade secret or copyright law. -* Dissemination of this information or reproduction of this material -* is strictly forbidden unless prior written permission is obtained -* from Adobe Systems Incorporated. -**************************************************************************/ +// ================================================================================================= +// Copyright 2020 Adobe +// All Rights Reserved. +// NOTICE: Adobe permits you to use, modify, and distribute this file in +// accordance with the terms of the Adobe license agreement accompanying +// it. +// ================================================================================================= //SuppressSAL.h Version 1.0 diff -Nru exempi-2.5.2/source/UnicodeConversions.cpp exempi-2.6.1/source/UnicodeConversions.cpp --- exempi-2.5.2/source/UnicodeConversions.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/source/UnicodeConversions.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2004 Adobe Systems Incorporated +// Copyright 2004 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Const.h" @@ -13,7 +13,7 @@ #include "source/UnicodeConversions.hpp" -#if SUNOS_SPARC || XMP_IOS_ARM +#if SUNOS_SPARC || XMP_IOS_ARM || XMP_ANDROID_ARM #include "string.h" #endif @@ -218,7 +218,7 @@ // ================================================================================================= -#if SUNOS_SPARC || XMP_IOS_ARM +#if SUNOS_SPARC || XMP_IOS_ARM || XMP_ANDROID_ARM #define DefineAndGetValue(type,inPtr) type inUnit; memcpy ( &inUnit, inPtr, sizeof(type) ); #else #define DefineAndGetValue(type,inPtr) type inUnit = *((type *)inPtr); diff -Nru exempi-2.5.2/source/UnicodeConversions.hpp exempi-2.6.1/source/UnicodeConversions.hpp --- exempi-2.5.2/source/UnicodeConversions.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/source/UnicodeConversions.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,11 +2,11 @@ #define __UnicodeConversions_h__ // ================================================================================================= -// Copyright 2004 Adobe Systems Incorporated +// Copyright 2004 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include diff -Nru exempi-2.5.2/source/XIO.cpp exempi-2.6.1/source/XIO.cpp --- exempi-2.5.2/source/XIO.cpp 2016-12-07 05:07:54.000000000 +0000 +++ exempi-2.6.1/source/XIO.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/source/XIO.hpp exempi-2.6.1/source/XIO.hpp --- exempi-2.5.2/source/XIO.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/source/XIO.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __XIO_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/source/XML_Node.cpp exempi-2.6.1/source/XML_Node.cpp --- exempi-2.5.2/source/XML_Node.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/source/XML_Node.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2007 Adobe Systems Incorporated +// Copyright 2007 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! Must be the first #include! diff -Nru exempi-2.5.2/source/XMLParserAdapter.hpp exempi-2.6.1/source/XMLParserAdapter.hpp --- exempi-2.5.2/source/XMLParserAdapter.hpp 2016-12-07 05:07:54.000000000 +0000 +++ exempi-2.6.1/source/XMLParserAdapter.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,11 +2,11 @@ #define __XMLParserAdapter_hpp__ // ================================================================================================= -// Copyright 2005 Adobe Systems Incorporated +// Copyright 2005 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! Must be the first #include! diff -Nru exempi-2.5.2/source/XMPFiles_IO.cpp exempi-2.6.1/source/XMPFiles_IO.cpp --- exempi-2.5.2/source/XMPFiles_IO.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/source/XMPFiles_IO.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/source/XMPFiles_IO.hpp exempi-2.6.1/source/XMPFiles_IO.hpp --- exempi-2.5.2/source/XMPFiles_IO.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/source/XMPFiles_IO.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __XMPFiles_IO_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/source/XMP_LibUtils.cpp exempi-2.6.1/source/XMP_LibUtils.cpp --- exempi-2.5.2/source/XMP_LibUtils.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/source/XMP_LibUtils.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2009 Adobe Systems Incorporated +// Copyright 2009 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" @@ -42,11 +42,16 @@ { #if XMP_DebugBuild && HaveAtomicIncrDecr this->lockCount = 0; + +#if 0 //changing type of XMP_AtomicCounter from int32_t to std::atomic + // Atomic counter must be 32 or 64 bits and naturally aligned. size_t counterSize = sizeof ( XMP_AtomicCounter ); size_t counterOffset = XMP_OffsetOf ( XMP_ReadWriteLock, lockCount ); XMP_Assert ( (counterSize == 4) || (counterSize == 8) ); // Counter must be 32 or 64 bits. XMP_Assert ( (counterOffset & (counterSize-1)) == 0 ); // Counter must be naturally aligned. +#endif + #endif XMP_BasicRWLock_Initialize ( this->lock ); #if TraceThreadLocks @@ -78,6 +83,7 @@ if ( forWriting ) { XMP_BasicRWLock_AcquireForWrite ( this->lock ); + this->beingWritten = forWriting; #if XMP_DebugBuild && HaveAtomicIncrDecr XMP_Assert ( this->lockCount == 0 ); #endif @@ -88,7 +94,7 @@ #if XMP_DebugBuild && HaveAtomicIncrDecr XMP_AtomicIncrement ( this->lockCount ); #endif - this->beingWritten = forWriting; + #if TraceThreadLocks fprintf ( stderr, "Acquired lock %.8X for %s, count %d%s\n", @@ -109,9 +115,9 @@ XMP_AtomicDecrement ( this->lockCount ); // ! Do these before unlocking, that might release a waiting thread. #endif bool forWriting = this->beingWritten; - this->beingWritten = false; if ( forWriting ) { + this->beingWritten = false; XMP_BasicRWLock_ReleaseFromWrite ( this->lock ); } else { XMP_BasicRWLock_ReleaseFromRead ( this->lock ); @@ -126,7 +132,7 @@ #if UseHomeGrownLock - #if XMP_MacBuild | XMP_UNIXBuild | XMP_iOSBuild + #if XMP_MacBuild | XMP_UNIXBuild | XMP_iOSBuild | XMP_AndroidBuild // ----------------------------------------------------------------------------------------- @@ -138,13 +144,13 @@ // until the condition is signaled. When the call returns, the mutex is locked again. #define InitializeBasicMutex(mutex) { int err = pthread_mutex_init ( &mutex, 0 ); XMP_Enforce ( err == 0 ); } - #define TerminateBasicMutex(mutex) { int err = pthread_mutex_destroy ( &mutex ); XMP_Enforce ( err == 0 ); } + #define TerminateBasicMutex(mutex) { int err = pthread_mutex_destroy ( &mutex ); (void)err; XMP_Enforce_NoThrow ( err == 0 ); } #define AcquireBasicMutex(mutex) { int err = pthread_mutex_lock ( &mutex ); XMP_Enforce ( err == 0 ); } #define ReleaseBasicMutex(mutex) { int err = pthread_mutex_unlock ( &mutex ); XMP_Enforce ( err == 0 ); } #define InitializeBasicQueue(queue) { int err = pthread_cond_init ( &queue, 0 ); XMP_Enforce ( err == 0 ); } - #define TerminateBasicQueue(queue) { int err = pthread_cond_destroy ( &queue ); XMP_Enforce ( err == 0 ); } + #define TerminateBasicQueue(queue) { int err = pthread_cond_destroy ( &queue ); (void)err; XMP_Enforce_NoThrow ( err == 0 ); } #define WaitOnBasicQueue(queue,mutex) { int err = pthread_cond_wait ( &queue, &mutex ); XMP_Enforce ( err == 0 ); } #define ReleaseOneBasicQueue(queue) { int err = pthread_cond_signal ( &queue ); XMP_Enforce ( err == 0 ); } diff -Nru exempi-2.5.2/source/XMP_LibUtils.hpp exempi-2.6.1/source/XMP_LibUtils.hpp --- exempi-2.5.2/source/XMP_LibUtils.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/source/XMP_LibUtils.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,11 +2,11 @@ #define __XMP_LibUtils_hpp__ 1 // ================================================================================================= -// Copyright 2009 Adobe Systems Incorporated +// Copyright 2009 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! Must be the first include. @@ -177,6 +177,7 @@ const char * assert_msg = _NotifyMsg ( XMP_Enforce, (c), __FILE__, __LINE__ ); \ XMP_Throw ( assert_msg , kXMPErr_EnforceFailure ); \ } + #define XMP_Enforce_NoThrow(c) // ================================================================================================= // Thread synchronization locks // ============================ @@ -234,22 +235,33 @@ #elif XMP_MacBuild | XMP_iOSBuild #include - #include + + // #include deprecated header + #include #define HaveAtomicIncrDecr 1 - typedef int32_t XMP_AtomicCounter; + //typedef int32_t XMP_AtomicCounter; //Changing XMP_AtomicCounter type to std::atomic + // due to deprecation of mac os APIs + + + typedef std::atomic XMP_AtomicCounter; + + //Both these APIs are deprecated. - #define XMP_AtomicIncrement(x) OSAtomicIncrement32Barrier ( &(x) ) - #define XMP_AtomicDecrement(x) OSAtomicDecrement32Barrier ( &(x) ) + //#define XMP_AtomicIncrement(x) OSAtomicIncrement32Barrier ( &(x) ) + //#define XMP_AtomicDecrement(x) OSAtomicDecrement32Barrier ( &(x) ) + + #define XMP_AtomicIncrement(x) std::atomic_fetch_add ( &(x), 1 ) + #define XMP_AtomicDecrement(x) std::atomic_fetch_sub ( &(x), 1 ) typedef pthread_mutex_t XMP_BasicMutex; #define InitializeBasicMutex(mutex) { int err = pthread_mutex_init ( &mutex, 0 ); XMP_Enforce ( err == 0 ); } - #define TerminateBasicMutex(mutex) { int err = pthread_mutex_destroy ( &mutex ); XMP_Enforce ( err == 0 ); } + #define TerminateBasicMutex(mutex) { int err = pthread_mutex_destroy ( &mutex ); XMP_Enforce_NoThrow ( err == 0 ); } #define AcquireBasicMutex(mutex) { int err = pthread_mutex_lock ( &mutex ); XMP_Enforce ( err == 0 ); } #define ReleaseBasicMutex(mutex) { int err = pthread_mutex_unlock ( &mutex ); XMP_Enforce ( err == 0 ); } -#elif XMP_UNIXBuild +#elif XMP_UNIXBuild || XMP_AndroidBuild #include @@ -266,7 +278,7 @@ typedef pthread_mutex_t XMP_BasicMutex; #define InitializeBasicMutex(mutex) { int err = pthread_mutex_init ( &mutex, 0 ); XMP_Enforce ( err == 0 ); } - #define TerminateBasicMutex(mutex) { int err = pthread_mutex_destroy ( &mutex ); XMP_Enforce ( err == 0 ); } + #define TerminateBasicMutex(mutex) { int err = pthread_mutex_destroy ( &mutex ); (void)err; XMP_Enforce_NoThrow ( err == 0 ); } #define AcquireBasicMutex(mutex) { int err = pthread_mutex_lock ( &mutex ); XMP_Enforce ( err == 0 ); } #define ReleaseBasicMutex(mutex) { int err = pthread_mutex_unlock ( &mutex ); XMP_Enforce ( err == 0 ); } @@ -378,7 +390,7 @@ #define XMP_BasicRWLock_ReleaseFromRead(lck) lck.ReleaseFromRead() #define XMP_BasicRWLock_ReleaseFromWrite(lck) lck.ReleaseFromWrite() - #if XMP_MacBuild | XMP_UNIXBuild | XMP_iOSBuild + #if XMP_MacBuild | XMP_UNIXBuild | XMP_iOSBuild | XMP_AndroidBuild #include @@ -547,6 +559,10 @@ #define RELEASE_NO_THROW throw() #endif + +#define NO_EXCEPT_FALSE noexcept(false) +#define NO_EXCEPT_TRUE noexcept(true) + // ================================================================================================= // Data structure dumping utilities // ================================ diff -Nru exempi-2.5.2/source/XMP_ProgressTracker.cpp exempi-2.6.1/source/XMP_ProgressTracker.cpp --- exempi-2.5.2/source/XMP_ProgressTracker.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/source/XMP_ProgressTracker.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2012 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2012 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -131,7 +131,7 @@ float totalTime = 0.0; if ( this->workDone > 0.0 ) { fractionDone = 1.0; // This is the stop call. - totalTime = PerfUtils::GetElapsedSeconds ( this->startTime, PerfUtils::NoteThisMoment() ); + totalTime = (float)PerfUtils::GetElapsedSeconds ( this->startTime, PerfUtils::NoteThisMoment() ); } ok = (*this->cbInfo.wrapperProc ) ( this->cbInfo.clientProc, this->cbInfo.context, totalTime, fractionDone, 0.0 ); @@ -139,15 +139,15 @@ } else { PerfUtils::MomentValue currentTime = PerfUtils::NoteThisMoment(); - float elapsedTime = PerfUtils::GetElapsedSeconds ( this->prevTime, currentTime ); + float elapsedTime =(float) PerfUtils::GetElapsedSeconds ( this->prevTime, currentTime ); if ( elapsedTime < this->cbInfo.interval ) return; float remainingTime = 0.0; if ( (this->totalWork > 0.0) && (this->workDone > 0.0) ) { fractionDone = this->workDone / this->totalWork; if ( fractionDone > 1.0 ) fractionDone = 1.0; - elapsedTime = PerfUtils::GetElapsedSeconds ( this->startTime, currentTime ); - remainingTime = (elapsedTime / fractionDone) * (1.0 - fractionDone); + elapsedTime =(float) PerfUtils::GetElapsedSeconds ( this->startTime, currentTime ); + remainingTime = (float)((elapsedTime / fractionDone) * (1.0F - fractionDone)); } this->prevTime = currentTime; diff -Nru exempi-2.5.2/source/XMP_ProgressTracker.hpp exempi-2.6.1/source/XMP_ProgressTracker.hpp --- exempi-2.5.2/source/XMP_ProgressTracker.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/source/XMP_ProgressTracker.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __XMP_ProgressTracker_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2012 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2012 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -46,7 +46,8 @@ void AddWorkDone ( float workIncrement ); void WorkComplete(); CallbackInfo * GetCallbackInfo() { - return &cbInfo; + //return ( (&cbInfo) ? (&cbInfo) : NULL); //cbInfo is an object so its address will always be available + return (&cbInfo); } bool WorkInProgress() { return this->workInProgress; }; diff -Nru exempi-2.5.2/third-party/expat/Makefile.in exempi-2.6.1/third-party/expat/Makefile.in --- exempi-2.5.2/third-party/expat/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/third-party/expat/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -260,6 +260,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/third-party/expat/ReadMe.txt exempi-2.6.1/third-party/expat/ReadMe.txt --- exempi-2.5.2/third-party/expat/ReadMe.txt 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/third-party/expat/ReadMe.txt 2021-11-18 03:53:54.000000000 +0000 @@ -1,76 +1,76 @@ -The XMP Toolkit needs an external XML parser. The source from Adobe is written to use Expat, - -although adapters for other parsers can easily be written. The most recent version of Expat used - -with XMP is 2.1.0. To use Expat: - - - -1. Obtain a copy of the Expat distribution. One good place is SourceForge: - - http://sourceforge.net/projects/expat/files/expat/2.1.0/ - - - -2. Place Expat's lib directory within .../third-party/expat. I.e. as a sibling of this file. - - - -For Expat version 2.0.0 the contents of .../third-party/expat/lib are: - - - - amigaconfig.h - - ascii.h - - asciitab.h - - expat.dsp - - expat.h - - expatw.dsp - - expatw_static.dsp - - expat_external.h - - expat_static.dsp - - iasciitab.h - - internal.h - - latin1tab.h - - libexpat.def - - libexpatw.def - - macconfig.h - - Makefile.MPW - - nametab.h - - utf8tab.h - - winconfig.h - - xmlparse.c - - xmlrole.c - - xmlrole.h - - xmltok.c - - xmltok.h - - xmltok_impl.c - - xmltok_impl.h - - xmltok_ns.c - +The XMP Toolkit needs an external XML parser. The source from Adobe is written to use Expat, + +although adapters for other parsers can easily be written. The most recent version of Expat used + +with XMP is 2.1.0. To use Expat: + + + +1. Obtain a copy of the Expat distribution. One good place is SourceForge: + + http://sourceforge.net/projects/expat/files/expat/2.1.0/ + + + +2. Place Expat's lib directory within .../third-party/expat. I.e. as a sibling of this file. + + + +For Expat version 2.0.0 the contents of .../third-party/expat/lib are: + + + + amigaconfig.h + + ascii.h + + asciitab.h + + expat.dsp + + expat.h + + expatw.dsp + + expatw_static.dsp + + expat_external.h + + expat_static.dsp + + iasciitab.h + + internal.h + + latin1tab.h + + libexpat.def + + libexpatw.def + + macconfig.h + + Makefile.MPW + + nametab.h + + utf8tab.h + + winconfig.h + + xmlparse.c + + xmlrole.c + + xmlrole.h + + xmltok.c + + xmltok.h + + xmltok_impl.c + + xmltok_impl.h + + xmltok_ns.c + diff -Nru exempi-2.5.2/third-party/Makefile.in exempi-2.6.1/third-party/Makefile.in --- exempi-2.5.2/third-party/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/third-party/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -319,6 +319,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/third-party/zlib/Makefile.in exempi-2.6.1/third-party/zlib/Makefile.in --- exempi-2.5.2/third-party/zlib/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/third-party/zlib/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -260,6 +260,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/third-party/zlib/ReadMe.txt exempi-2.6.1/third-party/zlib/ReadMe.txt --- exempi-2.5.2/third-party/zlib/ReadMe.txt 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/third-party/zlib/ReadMe.txt 2021-11-18 03:53:54.000000000 +0000 @@ -1,13 +1,37 @@ -The XMP Toolkit SDK needs zlib. -This release uses zlib Version 1.2.8 - - - To get zlib: - - 1. Obtain a copy of the zlib source code (not the compiled dll) - from http://www.zlib.net/ - (download links at the time of writing were at the bottom) - - - 2. Place all top-level .c and .h files of the tar/zip you downloaded - directly in .../third-party/zlib +The XMP Toolkit SDK needs zlib. +This release uses zlib Version 1.2.8 + + + + + + +To get zlib: + + + + + +1. Obtain a copy of the zlib source code (not the compiled dll) + + + from http://www.zlib.net/ + + + (download links at the time of writing were at the bottom) + + + + + + +2. Place all top-level .c and .h files of the tar/zip you downloaded + + + directly in .../third-party/zlib + + + + + + diff -Nru exempi-2.5.2/third-party/zuid/interfaces/Makefile.in exempi-2.6.1/third-party/zuid/interfaces/Makefile.in --- exempi-2.5.2/third-party/zuid/interfaces/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/third-party/zuid/interfaces/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -364,6 +364,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/XMPCore/Makefile.in exempi-2.6.1/XMPCore/Makefile.in --- exempi-2.5.2/XMPCore/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/XMPCore/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -320,6 +320,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/XMPCore/source/ExpatAdapter.cpp exempi-2.6.1/XMPCore/source/ExpatAdapter.cpp --- exempi-2.5.2/XMPCore/source/ExpatAdapter.cpp 2019-07-28 02:00:47.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/ExpatAdapter.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2005 Adobe Systems Incorporated +// Copyright 2005 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! Must be the first #include! diff -Nru exempi-2.5.2/XMPCore/source/Makefile.in exempi-2.6.1/XMPCore/source/Makefile.in --- exempi-2.5.2/XMPCore/source/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -377,6 +377,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/XMPCore/source/ParseRDF.cpp exempi-2.6.1/XMPCore/source/ParseRDF.cpp --- exempi-2.5.2/XMPCore/source/ParseRDF.cpp 2016-12-07 05:07:54.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/ParseRDF.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,21 +1,18 @@ // ================================================================================================= -// Copyright 2004 Adobe Systems Incorporated +// Copyright 2004 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include! -#include "XMPCore/source/XMPCore_Impl.hpp" -#include "XMPCore/source/XMPMeta.hpp" -#include "source/ExpatAdapter.hpp" - -#include - #if DEBUG #include #endif +#include "XMPCore/source/XMPCore_Impl.hpp" +#include "XMPCore/source/XMPMeta.hpp" +#include "source/ExpatAdapter.hpp" using namespace std; diff -Nru exempi-2.5.2/XMPCore/source/WXMPIterator.cpp exempi-2.6.1/XMPCore/source/WXMPIterator.cpp --- exempi-2.5.2/XMPCore/source/WXMPIterator.cpp 2019-07-28 02:00:47.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/WXMPIterator.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2004 Adobe Systems Incorporated +// Copyright 2004 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include! @@ -62,6 +62,7 @@ void WXMPIterator_IncrementRefCount_1 ( XMPIteratorRef xmpObjRef ) { + WXMP_Result void_wResult; WXMP_Result * wResult = &void_wResult; // ! Needed to "fool" the EnterWrapper macro. XMP_ENTER_ObjWrite ( XMPIterator, "WXMPIterator_IncrementRefCount_1" ) @@ -76,6 +77,7 @@ void WXMPIterator_DecrementRefCount_1 ( XMPIteratorRef xmpObjRef ) { + WXMP_Result void_wResult; WXMP_Result * wResult = &void_wResult; // ! Needed to "fool" the EnterWrapper macro. XMP_ENTER_ObjWrite ( XMPIterator, "WXMPIterator_DecrementRefCount_1" ) @@ -111,6 +113,7 @@ XMP_StringPtr valuePtr = 0; XMP_StringLen valueLen = 0; + XMP_OptionBits voidOptionBits = 0; if ( propOptions == 0 ) propOptions = &voidOptionBits; XMP_Assert( thiz->info.xmpObj != NULL ); diff -Nru exempi-2.5.2/XMPCore/source/WXMPMeta.cpp exempi-2.6.1/XMPCore/source/WXMPMeta.cpp --- exempi-2.5.2/XMPCore/source/WXMPMeta.cpp 2019-07-28 02:00:47.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/WXMPMeta.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2004 Adobe Systems Incorporated +// Copyright 2004 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include! @@ -40,6 +40,7 @@ /* class static */ void WXMPMeta_GetVersionInfo_1 ( XMP_VersionInfo * info ) { + WXMP_Result void_wResult; WXMP_Result * wResult = &void_wResult; // ! Needed to "fool" the EnterWrapper macro. XMP_ENTER_NoLock ( "WXMPMeta_GetVersionInfo_1" ) @@ -64,6 +65,7 @@ /* class static */ void WXMPMeta_Terminate_1() { + WXMP_Result void_wResult; WXMP_Result * wResult = &void_wResult; // ! Needed to "fool" the EnterWrapper macro. XMP_ENTER_NoLock ( "WXMPMeta_Terminate_1" ) @@ -106,6 +108,7 @@ void WXMPMeta_IncrementRefCount_1 ( XMPMetaRef xmpObjRef ) { + WXMP_Result void_wResult; WXMP_Result * wResult = &void_wResult; // ! Needed to "fool" the EnterWrapper macro. XMP_ENTER_ObjWrite ( XMPMeta, "WXMPMeta_IncrementRefCount_1" ) @@ -120,6 +123,7 @@ void WXMPMeta_DecrementRefCount_1 ( XMPMetaRef xmpObjRef ) { + WXMP_Result void_wResult; WXMP_Result * wResult = &void_wResult; // ! Needed to "fool" the EnterWrapper macro. XMP_ENTER_ObjWrite ( XMPMeta, "WXMPMeta_DecrementRefCount_1" ) @@ -256,6 +260,8 @@ XMP_StringPtr valuePtr = 0; XMP_StringLen valueSize = 0; + + XMP_OptionBits voidOptionBits = 0; if ( options == 0 ) options = &voidOptionBits; bool found = thiz.GetProperty ( schemaNS, propName, &valuePtr, &valueSize, options ); @@ -285,6 +291,8 @@ XMP_StringPtr valuePtr = 0; XMP_StringLen valueSize = 0; + + XMP_OptionBits voidOptionBits = 0; if ( options == 0 ) options = &voidOptionBits; bool found = thiz.GetArrayItem ( schemaNS, arrayName, itemIndex, &valuePtr, &valueSize, options ); @@ -317,6 +325,8 @@ XMP_StringPtr valuePtr = 0; XMP_StringLen valueSize = 0; + + XMP_OptionBits voidOptionBits = 0; if ( options == 0 ) options = &voidOptionBits; bool found = thiz.GetStructField ( schemaNS, structName, fieldNS, fieldName, &valuePtr, &valueSize, options ); @@ -349,6 +359,8 @@ XMP_StringPtr valuePtr = 0; XMP_StringLen valueSize = 0; + + XMP_OptionBits voidOptionBits = 0; if ( options == 0 ) options = &voidOptionBits; bool found = thiz.GetQualifier ( schemaNS, propName, qualNS, qualName, &valuePtr, &valueSize, options ); @@ -660,6 +672,8 @@ XMP_StringLen langSize = 0; XMP_StringPtr valuePtr = 0; XMP_StringLen valueSize = 0; + + XMP_OptionBits voidOptionBits = 0; if ( options == 0 ) options = &voidOptionBits; bool found = thiz.GetLocalizedText ( schemaNS, arrayName, genericLang, specificLang, @@ -735,6 +749,9 @@ if ( (schemaNS == 0) || (*schemaNS == 0) ) XMP_Throw ( "Empty schema namespace URI", kXMPErr_BadSchema ); if ( (propName == 0) || (*propName == 0) ) XMP_Throw ( "Empty property name", kXMPErr_BadXPath ); + XMP_Bool voidByte = 0; //in case prop value is NULL, inserting dummy object address here, so inner calls does not need to check for NULL. + XMP_OptionBits voidOptionBits = 0; + if ( propValue == 0 ) propValue = &voidByte; if ( options == 0 ) options = &voidOptionBits; @@ -761,6 +778,9 @@ if ( (schemaNS == 0) || (*schemaNS == 0) ) XMP_Throw ( "Empty schema namespace URI", kXMPErr_BadSchema ); if ( (propName == 0) || (*propName == 0) ) XMP_Throw ( "Empty property name", kXMPErr_BadXPath ); + XMP_Int32 voidInt32 = 0; //in case prop value is NULL, inserting dummy object address here, so inner calls does not need to check for NULL. + XMP_OptionBits voidOptionBits = 0; + if ( propValue == 0 ) propValue = &voidInt32; if ( options == 0 ) options = &voidOptionBits; @@ -785,6 +805,9 @@ if ( (schemaNS == 0) || (*schemaNS == 0) ) XMP_Throw ( "Empty schema namespace URI", kXMPErr_BadSchema ); if ( (propName == 0) || (*propName == 0) ) XMP_Throw ( "Empty property name", kXMPErr_BadXPath ); + XMP_Int64 voidInt64 = 0; //in case prop value is NULL, inserting dummy object address here, so inner calls does not need to check for NULL. + XMP_OptionBits voidOptionBits = 0; + if ( propValue == 0 ) propValue = &voidInt64; if ( options == 0 ) options = &voidOptionBits; @@ -809,6 +832,9 @@ if ( (schemaNS == 0) || (*schemaNS == 0) ) XMP_Throw ( "Empty schema namespace URI", kXMPErr_BadSchema ); if ( (propName == 0) || (*propName == 0) ) XMP_Throw ( "Empty property name", kXMPErr_BadXPath ); + double voidDouble = 0.0; //in case prop value is NULL, inserting dummy object address here, so inner calls does not need to check for NULL. + XMP_OptionBits voidOptionBits = 0; + if ( propValue == 0 ) propValue = &voidDouble; if ( options == 0 ) options = &voidOptionBits; @@ -833,6 +859,9 @@ if ( (schemaNS == 0) || (*schemaNS == 0) ) XMP_Throw ( "Empty schema namespace URI", kXMPErr_BadSchema ); if ( (propName == 0) || (*propName == 0) ) XMP_Throw ( "Empty property name", kXMPErr_BadXPath ); + XMP_DateTime voidDateTime; //in case prop value is NULL, inserting dummy object address here, so inner calls does not need to check for NULL. + XMP_OptionBits voidOptionBits = 0; + if ( propValue == 0 ) propValue = &voidDateTime; if ( options == 0 ) options = &voidOptionBits; @@ -1205,6 +1234,7 @@ XMP_EXIT } + void WXMPMeta_Use_CPP_DOM_APIs_1(XMP_Bool useNewCoreAPIs, WXMP_Result * /*wResult*/ ) { @@ -1218,6 +1248,7 @@ } // ================================================================================================= + #if __cplusplus } /* extern "C" */ #endif diff -Nru exempi-2.5.2/XMPCore/source/WXMPUtils.cpp exempi-2.6.1/XMPCore/source/WXMPUtils.cpp --- exempi-2.5.2/XMPCore/source/WXMPUtils.cpp 2019-07-28 02:00:47.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/WXMPUtils.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2004 Adobe Systems Incorporated +// Copyright 2004 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= // *** Should change "type * inParam" to "type & inParam" diff -Nru exempi-2.5.2/XMPCore/source/XMPCore_Impl.cpp exempi-2.6.1/XMPCore/source/XMPCore_Impl.cpp --- exempi-2.5.2/XMPCore/source/XMPCore_Impl.cpp 2019-07-28 02:00:47.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/XMPCore_Impl.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2004 Adobe Systems Incorporated +// Copyright 2004 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include! @@ -30,6 +30,11 @@ #if ! MAC_ENV #error "MAC_ENV must be defined so that \"#if MAC_ENV\" is true" #endif + #if defined(IOS_ENV) + #if ! IOS_ENV + #error "IOS_ENV must be defined so that \"#if IOS_ENV\" is true" + #endif + #endif #elif defined ( WIN_ENV ) #if ! WIN_ENV #error "WIN_ENV must be defined so that \"#if WIN_ENV\" is true" @@ -42,6 +47,14 @@ #if ! IOS_ENV #error "IOS_ENV must be defined so that \"#if IOS_ENV\" is true" #endif +#elif defined(WIN_UNIVERSAL_ENV) + #if !WIN_UNIVERSAL_ENV + #error "WIN_UNIVERSAL_ENV must be defined so that \"#if WIN_UNIVERSAL_ENV\" is true" + #endif +#elif defined ( ANDROID_ENV ) + #if ! ANDROID_ENV + #error "ANDROID_ENV must be defined so that \"#if ANDROID_ENV\" is true" + #endif #endif // ================================================================================================= @@ -56,17 +69,22 @@ XMP_ReadWriteLock * sDefaultNamespacePrefixMapLock = 0; -void * voidVoidPtr = 0; // Used to backfill null output parameters. -XMP_StringPtr voidStringPtr = 0; -XMP_StringLen voidStringLen = 0; -XMP_OptionBits voidOptionBits = 0; -XMP_Uns8 voidByte = 0; -bool voidBool = 0; -XMP_Int32 voidInt32 = 0; -XMP_Int64 voidInt64 = 0; -double voidDouble = 0.0; -XMP_DateTime voidDateTime; -WXMP_Result void_wResult; + +// *** CTECHXMP-4169947 ***// + +//void * voidVoidPtr = 0; // Used to backfill null output parameters. +//XMP_StringPtr voidStringPtr = 0; +//XMP_StringLen voidStringLen = 0; +//XMP_OptionBits voidOptionBits = 0; +//XMP_Uns8 voidByte = 0; +//bool voidBool = 0; +//XMP_Int32 voidInt32 = 0; +//XMP_Int64 voidInt64 = 0; +//double voidDouble = 0.0; +//XMP_DateTime voidDateTime; +//WXMP_Result void_wResult; + + #if ENABLE_CPP_DOM_MODEL XMP_Bool sUseNewCoreAPIs = false; @@ -80,8 +98,12 @@ typedef void(*XMP_DeleteProc) (void * ptr); - XMP_AllocateProc sXMP_MemAlloc = malloc; - XMP_DeleteProc sXMP_MemFree = free; + XMP_AllocateProc sXMP_MemAlloc = malloc; + XMP_DeleteProc sXMP_MemFree = free; + + +//******* SEE : CTECHXMP-4169971 *************// +#if 0 #define malloc(size) (*sXMP_MemAlloc) ( size ) #define free(addr) (*sXMP_MemFree) ( addr ) @@ -92,7 +114,7 @@ return mem; } - void * operator new( std::size_t len, const std::nothrow_t & nothrow ) throw () { + void * operator new( std::size_t len, const std::nothrow_t & _nothrow ) throw () { void * mem = (*sXMP_MemAlloc) ( len ); return mem; } @@ -109,7 +131,7 @@ if ( ptr != 0 ) (*sXMP_MemFree) ( ptr ); } - void operator delete ( void * ptr, const std::nothrow_t & nothrow ) throw () + void operator delete ( void * ptr, const std::nothrow_t & _nothrow ) throw () { return operator delete( ptr ); } @@ -118,7 +140,8 @@ { if ( ptr != 0 ) (*sXMP_MemFree) ( ptr ); } - +#endif + #endif diff -Nru exempi-2.5.2/XMPCore/source/XMPCore_Impl.hpp exempi-2.6.1/XMPCore/source/XMPCore_Impl.hpp --- exempi-2.5.2/XMPCore/source/XMPCore_Impl.hpp 2019-07-28 02:00:47.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/XMPCore_Impl.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,11 +2,11 @@ #define __XMPCore_Impl_hpp__ 1 // ================================================================================================= -// Copyright 2004 Adobe Systems Incorporated +// Copyright 2004 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! Must be the first #include! @@ -85,17 +85,20 @@ #define WtoXMPDocOps_Ptr(docRef) ((XMPDocOps*)(docRef)) -extern void * voidVoidPtr; // Used to backfill null output parameters. -extern XMP_StringPtr voidStringPtr; -extern XMP_StringLen voidStringLen; -extern XMP_OptionBits voidOptionBits; -extern XMP_Bool voidByte; -extern bool voidBool; -extern XMP_Int32 voidInt32; -extern XMP_Int64 voidInt64; -extern double voidDouble; -extern XMP_DateTime voidDateTime; -extern WXMP_Result void_wResult; +// **** see CTECHXMP-4169947 ***// + +//extern void * voidVoidPtr; // Used to backfill null output parameters. +//extern XMP_StringPtr voidStringPtr; +//extern XMP_StringLen voidStringLen; +//extern XMP_OptionBits voidOptionBits; +//extern XMP_Bool voidByte; +//extern bool voidBool; +//extern XMP_Int32 voidInt32; +//extern XMP_Int64 voidInt64; +//extern double voidDouble; +//extern XMP_DateTime voidDateTime; +//extern WXMP_Result void_wResult; + #define kHexDigits "0123456789ABCDEF" @@ -173,6 +176,11 @@ #define FindConstQualifier(p,c) FindQualifierNode ( const_cast(p), c, kXMP_ExistingOnly, 0 ) #define FindConstNode(t,p) ::FindNode ( const_cast(t), p, kXMP_ExistingOnly, 0 ) +void +SplitNameAndValue(const XMP_VarString & selStep, + XMP_VarString * nameStr, + XMP_VarString * valueStr); + extern XMP_OptionBits VerifySetOptions ( XMP_OptionBits options, XMP_StringPtr propValue ); diff -Nru exempi-2.5.2/XMPCore/source/XMPIterator.cpp exempi-2.6.1/XMPCore/source/XMPIterator.cpp --- exempi-2.5.2/XMPCore/source/XMPIterator.cpp 2019-07-28 02:00:47.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/XMPIterator.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,19 +1,20 @@ // ================================================================================================= -// Copyright 2003 Adobe Systems Incorporated +// Copyright 2003 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include! -#include "XMPCore/source/XMPCore_Impl.hpp" - -#include "XMPCore/source/XMPIterator.hpp" #include #include // For snprintf. +#include "XMPCore/source/XMPCore_Impl.hpp" + +#include "XMPCore/source/XMPIterator.hpp" + #if XMP_WinBuild #pragma warning ( disable : 4702 ) // unreachable code #pragma warning ( disable : 4800 ) // forcing value to bool 'true' or 'false' (performance warning) @@ -114,7 +115,7 @@ currPath += xmpChild->name; } else { char buffer [32]; // AUDIT: Using sizeof(buffer) below for snprintf length is safe. - snprintf ( buffer, sizeof(buffer), "[%lu]", childNum+1 ); // ! XPath indices are one-based. + snprintf ( buffer, sizeof(buffer), "[%lu]", (unsigned long)childNum+1 ); // ! XPath indices are one-based. currPath += buffer; } iterParent.children.push_back ( IterNode ( xmpChild->options, currPath, leafOffset ) ); diff -Nru exempi-2.5.2/XMPCore/source/XMPIterator.hpp exempi-2.6.1/XMPCore/source/XMPIterator.hpp --- exempi-2.5.2/XMPCore/source/XMPIterator.hpp 2019-07-28 02:00:47.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/XMPIterator.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,11 +2,11 @@ #define __XMPIterator_hpp__ // ================================================================================================= -// Copyright 2003 Adobe Systems Incorporated +// Copyright 2003 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" diff -Nru exempi-2.5.2/XMPCore/source/XMPMeta2.hpp exempi-2.6.1/XMPCore/source/XMPMeta2.hpp --- exempi-2.5.2/XMPCore/source/XMPMeta2.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/XMPMeta2.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -187,4 +187,4 @@ }; #endif -#endif \ No newline at end of file +#endif diff -Nru exempi-2.5.2/XMPCore/source/XMPMeta.cpp exempi-2.6.1/XMPCore/source/XMPMeta.cpp --- exempi-2.5.2/XMPCore/source/XMPMeta.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/XMPMeta.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,15 +1,23 @@ // ================================================================================================= -// Copyright 2003 Adobe Systems Incorporated +// Copyright 2003 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // // Adobe patent application tracking #P435, entitled 'Unique markers to simplify embedding data of // one format in a file with a different format', inventors: Sean Parent, Greg Gilley. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include! + +#include // For sort and stable_sort. +#include // For snprintf. + +#if XMP_DebugBuild + #include +#endif + #include "XMPCore/source/XMPCore_Impl.hpp" #include "XMPCore/source/XMPMeta.hpp" @@ -31,14 +39,6 @@ #include "XMPCore/Interfaces/IDOMImplementationRegistry_I.h" #endif - -#include // For sort and stable_sort. -#include // For snprintf. - -#if XMP_DebugBuild - #include -#endif - using namespace std; #if XMP_WinBuild diff -Nru exempi-2.5.2/XMPCore/source/XMPMeta-GetSet.cpp exempi-2.6.1/XMPCore/source/XMPMeta-GetSet.cpp --- exempi-2.5.2/XMPCore/source/XMPMeta-GetSet.cpp 2019-07-28 02:00:47.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/XMPMeta-GetSet.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,15 +1,20 @@ // ================================================================================================= -// Copyright 2003 Adobe Systems Incorporated +// Copyright 2003 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // // Adobe patent application tracking #P435, entitled 'Unique markers to simplify embedding data of // one format in a file with a different format', inventors: Sean Parent, Greg Gilley. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include! + +#if XMP_DebugBuild + #include +#endif + #include "XMPCore/source/XMPCore_Impl.hpp" #include "XMPCore/source/XMPMeta.hpp" @@ -41,11 +46,6 @@ #include "XMPCore/Interfaces/INode_I.h" #endif - -#if XMP_DebugBuild - #include -#endif - using namespace std; #if XMP_WinBuild @@ -55,6 +55,7 @@ #endif + // *** Use the XMP_PropIsXyz (Schema, Simple, Struct, Array, ...) macros // *** Add debug codegen checks, e.g. that typical masking operations really work // *** Change all uses of strcmp and strncmp to XMP_LitMatch and XMP_LitNMatch @@ -68,18 +69,21 @@ #if XMP_MARKER_EXTENSIBILITY_BACKWARD_COMPATIBILITY extern "C" { - void ReleaseXMP_Node(void * node) { +#if 0 // UNUSED -- Hub + static void ReleaseXMP_Node(void * node) { if (node) { XMP_Node * ptr = (XMP_Node *)node; delete ptr; ptr = NULL; } } +#endif } #if ENABLE_CPP_DOM_MODEL extern "C" { - void ReleaseIStructureNode(void * node) { + + static void ReleaseIStructureNode(void * node) { if (node) { AdobeXMPCore::pIStructureNode_base ptr = ( AdobeXMPCore::pIStructureNode_base )node; ptr->Release(); @@ -119,16 +123,16 @@ node->SetValue( value ); } //SetNodeValue -void XMP_Node::SetValue( XMP_StringPtr value_ ) +void XMP_Node::SetValue( XMP_StringPtr _value ) { #if XMP_DebugBuild // ! Hack to force an assert. - if ( (this->name == "xmp:TestAssertNotify") && XMP_LitMatch ( value_, "DoIt!" ) ) { + if ( (this->name == "xmp:TestAssertNotify") && XMP_LitMatch ( _value, "DoIt!" ) ) { XMP_Assert ( this->name != "xmp:TestAssertNotify" ); } #endif - std::string newValue = value_; // Need a local copy to tweak and not change node.value for errors. + std::string newValue = _value; // Need a local copy to tweak and not change node.value for errors. XMP_Uns8* chPtr = (XMP_Uns8*) newValue.c_str(); // Check for valid UTF-8, replace ASCII controls with a space. while ( *chPtr != 0 ) { diff -Nru exempi-2.5.2/XMPCore/source/XMPMeta.hpp exempi-2.6.1/XMPCore/source/XMPMeta.hpp --- exempi-2.5.2/XMPCore/source/XMPMeta.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/XMPMeta.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,11 +2,11 @@ #define __XMPMeta_hpp__ // ================================================================================================= -// Copyright 2003 Adobe Systems Incorporated +// Copyright 2003 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" @@ -414,4 +414,21 @@ // ================================================================================================= +void +DumpNodeOptions(XMP_OptionBits options, + XMP_TextOutputProc outProc, + void * refCon); + +void +NormalizeDCArrays(XMP_Node * xmpTree); + +void +MoveExplicitAliases(XMP_Node * tree, + XMP_OptionBits parseOptions, + XMPMeta::ErrorCallbackInfo & errorCallback); + +void +TouchUpDataModel(XMPMeta * xmp, + XMPMeta::ErrorCallbackInfo & errorCallback); + #endif // __XMPMeta_hpp__ diff -Nru exempi-2.5.2/XMPCore/source/XMPMeta-Parse.cpp exempi-2.6.1/XMPCore/source/XMPMeta-Parse.cpp --- exempi-2.5.2/XMPCore/source/XMPMeta-Parse.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/XMPMeta-Parse.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,15 +1,20 @@ // ================================================================================================= -// Copyright 2003 Adobe Systems Incorporated +// Copyright 2003 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // // Adobe patent application tracking #P435, entitled 'Unique markers to simplify embedding data of // one format in a file with a different format', inventors: Sean Parent, Greg Gilley. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include! + +#if XMP_DebugBuild + #include +#endif + #include "XMPCore/source/XMPCore_Impl.hpp" #include "XMPCore/source/XMPMeta.hpp" @@ -21,10 +26,6 @@ #define STATIC_SAFE_API #include "source/SafeStringAPIs.h" -#if XMP_DebugBuild - #include -#endif - using namespace std; #if XMP_WinBuild diff -Nru exempi-2.5.2/XMPCore/source/XMPMeta-Serialize.cpp exempi-2.6.1/XMPCore/source/XMPMeta-Serialize.cpp --- exempi-2.5.2/XMPCore/source/XMPMeta-Serialize.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/XMPMeta-Serialize.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,15 +1,20 @@ // ================================================================================================= -// Copyright 2003-2009 Adobe Systems Incorporated +// Copyright 2003-2009 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // // Adobe patent application tracking #P435, entitled 'Unique markers to simplify embedding data of // one format in a file with a different format', inventors: Sean Parent, Greg Gilley. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include! + +#if XMP_DebugBuild + #include +#endif + #include "XMPCore/source/XMPCore_Impl.hpp" #include "XMPCore/source/XMPMeta.hpp" @@ -19,10 +24,6 @@ #include "source/UnicodeConversions.hpp" #include "third-party/zuid/interfaces/MD5.h" -#if XMP_DebugBuild - #include -#endif - using namespace std; #if XMP_WinBuild diff -Nru exempi-2.5.2/XMPCore/source/XMPUtils.cpp exempi-2.6.1/XMPCore/source/XMPUtils.cpp --- exempi-2.5.2/XMPCore/source/XMPUtils.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/XMPUtils.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2003 Adobe Systems Incorporated +// Copyright 2003 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include! @@ -52,9 +52,7 @@ // ================================================================================================= // Local Utilities // =============== -extern void SplitNameAndValue ( const XMP_VarString & selStep, XMP_VarString * nameStr, XMP_VarString * valueStr ); -extern void DumpNodeOptions ( XMP_OptionBits options,XMP_TextOutputProc outProc,void *refCon ); // ------------------------------------------------------------------------------------------------- // SetINode // -------------- @@ -1214,7 +1212,7 @@ XMP_Index destIdx = -1; if (arrayNode->GetNodeType() != INode::kNTArray) return destIdx; - for (size_t index = 1, indexLim = arrayNode->ChildCount(); index <= indexLim; ++index) { + for (XMP_Index index = 1, indexLim = (XMP_Index)arrayNode->ChildCount(); index <= indexLim; ++index) { spINode childNode = arrayNode->GetNodeAtIndex(index); if (childNode->GetNodeType() != INode::kNTStructure) { @@ -1242,7 +1240,7 @@ // A bit of hackery to use the best available time functions. Mac, UNIX and iOS have thread safe versions // of gmtime and localtime. -#if XMP_MacBuild | XMP_UNIXBuild | XMP_iOSBuild +#if XMP_MacBuild | XMP_UNIXBuild | XMP_iOSBuild | XMP_AndroidBuild typedef time_t ansi_tt; typedef struct tm ansi_tm; @@ -2503,12 +2501,18 @@ ++pos; temp = GatherInt ( strValue, &pos, "Invalid month in date string" ); // Extract the month. if ( (strValue[pos] != 0) && (strValue[pos] != '-') ) XMP_Throw ( "Invalid date string, after month", kXMPErr_BadParam ); + + if ( binValue->year != 0 && temp < 1 ) temp = 1; + if ( temp > 12 ) temp = 12; + binValue->month = temp; if ( strValue[pos] == 0 ) return; ++pos; temp = GatherInt ( strValue, &pos, "Invalid day in date string" ); // Extract the day. if ( (strValue[pos] != 0) && (strValue[pos] != 'T') ) XMP_Throw ( "Invalid date string, after day", kXMPErr_BadParam ); + + if ( temp > 31 ) temp = 31; binValue->day = temp; if ( strValue[pos] == 0 ) return; @@ -2518,9 +2522,9 @@ // if ( (binValue->month < 1) || (binValue->month > 12) ) XMP_Throw ( "Month is out of range", kXMPErr_BadParam ); // if ( (binValue->day < 1) || (binValue->day > 31) ) XMP_Throw ( "Day is out of range", kXMPErr_BadParam ); if ( binValue->month < 1 ) binValue->month = 1; - if ( binValue->month > 12 ) binValue->month = 12; + // if ( binValue->month > 12 ) binValue->month = 12; if ( binValue->day < 1 ) binValue->day = 1; - if ( binValue->day > 31 ) binValue->day = 31; + // if ( binValue->day > 31 ) binValue->day = 31; } } diff -Nru exempi-2.5.2/XMPCore/source/XMPUtils-FileInfo.cpp exempi-2.6.1/XMPCore/source/XMPUtils-FileInfo.cpp --- exempi-2.5.2/XMPCore/source/XMPUtils-FileInfo.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/XMPUtils-FileInfo.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2003 Adobe Systems Incorporated +// Copyright 2003 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include! @@ -782,9 +782,12 @@ for ( size_t sourceNum = 0, sourceLim = sourceNode->children.size(); sourceNum != sourceLim && destNode!= NULL; ++sourceNum ) { const XMP_Node * sourceField = sourceNode->children[sourceNum]; AppendSubtree ( sourceField, destNode, mergeCompound, replaceOld, deleteEmpty ); - if ( deleteEmpty && destNode->children.empty() ) { - delete ( destNode ); - destParent->children.erase ( destPos ); + + if (deleteEmpty && destNode->children.empty()) + { + delete (destNode); + destNode = NULL; + destParent->children.erase(destPos); } } @@ -1004,7 +1007,7 @@ if(sUseNewCoreAPIs) { - dynamic_cast(xmpObj); + //dynamic_cast(xmpObj); CatenateArrayItems_v2(xmpObj, schemaNS, arrayName, separator, quotes, options, catedStr); return; @@ -1163,19 +1166,19 @@ if (!XMPUtils::FindNode(xmpObj->mDOM, arrayPath, kXMP_CreateNodes, options, destNode, &insertIndex, true)) { XMP_Throw("Failure creating array node", kXMPErr_BadXPath); } - std::string arrayNameSpace, arrayName; + std::string arrayNameSpace, arrayNameStr; auto defaultMap = INameSpacePrefixMap::GetDefaultNameSpacePrefixMap(); arrayOptions = options; - XMPUtils::GetNameSpaceAndNameFromStepValue(lastPathSegment.step, defaultMap, arrayNameSpace, arrayName); + XMPUtils::GetNameSpaceAndNameFromStepValue(lastPathSegment.step, defaultMap, arrayNameSpace, arrayNameStr); // Need to check Alternate first if (arrayOptions & kXMP_PropArrayIsAlternate) { - arrayNode = IArrayNode::CreateAlternativeArrayNode( arrayNameSpace.c_str(), arrayNameSpace.size(), arrayName.c_str(), arrayName.size()); + arrayNode = IArrayNode::CreateAlternativeArrayNode( arrayNameSpace.c_str(), arrayNameSpace.size(), arrayNameStr.c_str(), arrayNameStr.size()); } else if (arrayOptions & kXMP_PropArrayIsOrdered) { - arrayNode = IArrayNode::CreateOrderedArrayNode( arrayNameSpace.c_str(), arrayNameSpace.size(), arrayName.c_str(), arrayName.size() ); + arrayNode = IArrayNode::CreateOrderedArrayNode( arrayNameSpace.c_str(), arrayNameSpace.size(), arrayNameStr.c_str(), arrayNameStr.size() ); } else if (arrayOptions & kXMP_PropArrayIsUnordered) { - arrayNode = IArrayNode::CreateUnorderedArrayNode( arrayNameSpace.c_str(), arrayNameSpace.size(), arrayName.c_str(), arrayName.size() ); + arrayNode = IArrayNode::CreateUnorderedArrayNode( arrayNameSpace.c_str(), arrayNameSpace.size(), arrayNameStr.c_str(), arrayNameStr.size() ); } else { diff -Nru exempi-2.5.2/XMPCore/source/XMPUtils.hpp exempi-2.6.1/XMPCore/source/XMPUtils.hpp --- exempi-2.5.2/XMPCore/source/XMPUtils.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPCore/source/XMPUtils.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,11 +2,11 @@ #define __XMPUtils_hpp__ // ================================================================================================= -// Copyright 2003 Adobe Systems Incorporated +// Copyright 2003 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" @@ -30,8 +30,9 @@ - - +bool +IsInternalProperty(const XMP_VarString & schema, + const XMP_VarString & prop); // ------------------------------------------------------------------------------------------------- class XMPUtils { diff -Nru exempi-2.5.2/XMPFiles/Makefile.in exempi-2.6.1/XMPFiles/Makefile.in --- exempi-2.5.2/XMPFiles/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/XMPFiles/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -320,6 +320,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/AIFF_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/AIFF_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/AIFF_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/AIFF_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -111,21 +111,21 @@ // FORM:AIFC/APPL:XMP const ChunkIdentifier AIFF_MetaHandler::kAIFCXMP[2] = { { kChunk_FORM, kType_AIFC }, { kChunk_APPL, kType_XMP } }; // FORM:AIFF/NAME -const ChunkIdentifier AIFF_MetaHandler::kAIFFName[2] = { { kChunk_FORM, kType_AIFF }, { kChunk_NAME, kType_NONE } }; +const ChunkIdentifier AIFF_MetaHandler::kAIFFName[2] = { { static_cast(kChunk_FORM), static_cast(kType_AIFF) }, { static_cast(kChunk_NAME), static_cast(kType_NONE) } }; // FORM:AIFC/NAME -const ChunkIdentifier AIFF_MetaHandler::kAIFCName[2] = { { kChunk_FORM, kType_AIFC }, { kChunk_NAME, kType_NONE } }; +const ChunkIdentifier AIFF_MetaHandler::kAIFCName[2] = { { static_cast(kChunk_FORM), static_cast(kType_AIFC) }, { static_cast(kChunk_NAME), static_cast(kType_NONE) } }; // FORM:AIFF/AUTH -const ChunkIdentifier AIFF_MetaHandler::kAIFFAuth[2] = { { kChunk_FORM, kType_AIFF }, { kChunk_AUTH, kType_NONE } }; +const ChunkIdentifier AIFF_MetaHandler::kAIFFAuth[2] = { { static_cast(kChunk_FORM), static_cast(kType_AIFF) }, { static_cast(kChunk_AUTH), static_cast(kType_NONE) } }; // FORM:AIFC/AUTH -const ChunkIdentifier AIFF_MetaHandler::kAIFCAuth[2] = { { kChunk_FORM, kType_AIFC }, { kChunk_AUTH, kType_NONE } }; +const ChunkIdentifier AIFF_MetaHandler::kAIFCAuth[2] = { { static_cast(kChunk_FORM), static_cast(kType_AIFC) }, { static_cast(kChunk_AUTH), static_cast(kType_NONE) } }; // FORM:AIFF/(c) -const ChunkIdentifier AIFF_MetaHandler::kAIFFCpr[2] = { { kChunk_FORM, kType_AIFF }, { kChunk_CPR, kType_NONE } }; +const ChunkIdentifier AIFF_MetaHandler::kAIFFCpr[2] = { { static_cast(kChunk_FORM), static_cast(kType_AIFF) }, { static_cast(kChunk_CPR), static_cast(kType_NONE) } }; // FORM:AIFC/(c) -const ChunkIdentifier AIFF_MetaHandler::kAIFCCpr[2] = { { kChunk_FORM, kType_AIFC }, { kChunk_CPR, kType_NONE } }; +const ChunkIdentifier AIFF_MetaHandler::kAIFCCpr[2] = { { static_cast(kChunk_FORM), static_cast(kType_AIFC) }, { static_cast(kChunk_CPR), static_cast(kType_NONE) } }; // FORM:AIFF/ANNO -const ChunkIdentifier AIFF_MetaHandler::kAIFFAnno[2] = { { kChunk_FORM, kType_AIFF }, { kChunk_ANNO, kType_NONE } }; +const ChunkIdentifier AIFF_MetaHandler::kAIFFAnno[2] = { { static_cast(kChunk_FORM), static_cast(kType_AIFF) }, { static_cast(kChunk_ANNO), static_cast(kType_NONE) } }; // FORM:AIFC/ANNO -const ChunkIdentifier AIFF_MetaHandler::kAIFCAnno[2] = { { kChunk_FORM, kType_AIFC }, { kChunk_ANNO, kType_NONE } }; +const ChunkIdentifier AIFF_MetaHandler::kAIFCAnno[2] = { { static_cast(kChunk_FORM), static_cast(kType_AIFC) }, { static_cast(kChunk_ANNO), static_cast(kType_NONE) } }; // ================================================================================================= // AIFF_MetaHandler::AIFF_MetaHandler diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/AIFF_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/AIFF_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/AIFF_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/AIFF_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef __AIFF_Handler_hpp__ diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/ASF_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/ASF_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/ASF_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/ASF_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/ASF_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/ASF_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/ASF_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/ASF_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __ASF_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "XMPFiles/source/XMPFiles_Impl.hpp" diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/AVCHD_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/AVCHD_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/AVCHD_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/AVCHD_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2008 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2008 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/AVCHD_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/AVCHD_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/AVCHD_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/AVCHD_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __AVCHD_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2008 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2008 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/Basic_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/Basic_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/Basic_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/Basic_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2004 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2004 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/Basic_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/Basic_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/Basic_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/Basic_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __Basic_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2004 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2004 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/FLV_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/FLV_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/FLV_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/FLV_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2007 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2007 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -210,6 +210,8 @@ static XMP_Uns32 GetASValueLen ( const XMP_Uns8 * asValue, const XMP_Uns8 * asLimit ) { + if (asValue > asLimit) + return 0; XMP_Uns32 valueLen = 0; const XMP_Uns8 * itemPtr; XMP_Uns32 arrayCount; diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/FLV_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/FLV_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/FLV_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/FLV_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __FLV_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2007 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2007 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/GIF_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/GIF_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/GIF_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/GIF_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2008 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2008 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // // This file includes implementation of GIF file metadata, according to GIF89a Specification. // https://www.w3.org/Graphics/GIF/spec-gif89a.txt @@ -244,8 +244,11 @@ this->SeekFile( fileRef, subBlockSize, kXMP_SeekFromCurrent ); fileRef->Read( &subBlockSize, 1 ); } - if ( IsXMPExists ) - XMPPacketLength = static_cast< XMP_Uns32 >( fileRef->Offset() - XMPPacketOffset - MAGIC_TRAILER_LEN ); + if ( IsXMPExists ) { + XMP_Int64 packetLength = fileRef->Offset() - XMPPacketOffset - MAGIC_TRAILER_LEN; + if( packetLength < 0 ) throw XMP_Error(kXMPErr_BadFileFormat, "corrupt GIF File."); + XMPPacketLength = static_cast< XMP_Uns32 >( packetLength ); + } } else { diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/GIF_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/GIF_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/GIF_Handler.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/GIF_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __GIF_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2008 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2008 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // // This file includes implementation of GIF file metadata, according to GIF89a Specification. // https://www.w3.org/Graphics/GIF/spec-gif89a.txt diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/InDesign_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/InDesign_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/InDesign_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/InDesign_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2004 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2004 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/InDesign_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/InDesign_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/InDesign_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/InDesign_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __InDesign_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2004 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2004 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/JPEG_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/JPEG_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/JPEG_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/JPEG_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,13 +1,16 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2004 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2004 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. + +#include + #include "public/include/XMP_Const.h" #include "public/include/XMP_IO.hpp" @@ -24,8 +27,6 @@ #include "third-party/zuid/interfaces/MD5.h" -#include - using namespace std; // ================================================================================================= @@ -336,7 +337,7 @@ size_t psirLen = contentLen - kPSIRSignatureLength; fileRef->Seek ( (contentOrigin + kPSIRSignatureLength), kXMP_SeekFromStart ); - fileRef->ReadAll ( buffer, psirLen ); + fileRef->ReadAll ( buffer, (XMP_Int32)psirLen ); this->psirContents.append( (char *) buffer, psirLen ); continue; // Move on to the next marker. @@ -357,7 +358,7 @@ size_t exifLen = contentLen - kExifSignatureLength; fileRef->Seek ( (contentOrigin + kExifSignatureLength), kXMP_SeekFromStart ); - fileRef->ReadAll ( buffer, exifLen ); + fileRef->ReadAll ( buffer, (XMP_Int32)exifLen ); this->exifContents.append ( (char*)buffer, exifLen ); continue; // Move on to the next marker. @@ -369,7 +370,7 @@ this->containsXMP = true; // Found the standard XMP packet. size_t xmpLen = contentLen - kMainXMPSignatureLength; fileRef->Seek ( (contentOrigin + kMainXMPSignatureLength), kXMP_SeekFromStart ); - fileRef->ReadAll ( buffer, xmpLen ); + fileRef->ReadAll ( buffer, (XMP_Int32)xmpLen ); this->xmpPacket.assign ( (char*)buffer, xmpLen ); this->packetInfo.offset = contentOrigin + kMainXMPSignatureLength; this->packetInfo.length = (XMP_Int32)xmpLen; @@ -481,8 +482,8 @@ TIFF_MemoryReader::TagInfoMap::const_iterator mapEnd = tagMap.end(); for ( ; mapPos != mapEnd; ++mapPos ) { - const TIFF_MemoryReader::TagInfo & value = mapPos->second; - XMP_Uns32 tagEnd = tempMgr.GetValueOffset ( ifd, value.id ) + value.dataLen; + const TIFF_MemoryReader::TagInfo & tagInfoRef = mapPos->second; + XMP_Uns32 tagEnd = tempMgr.GetValueOffset ( ifd, tagInfoRef.id ) + tagInfoRef.dataLen; if ( tagEnd > padOffset ) padOffset = tagEnd; } @@ -511,7 +512,7 @@ size_t nzSize = lastNonZero - padOffset + 1; size_t finalSize = (exifContents->size() - 1) - lastNonZero; if ( (nzSize < 64) && (finalSize > 64) ) { - padOffset = lastNonZero + 64; + padOffset = (XMP_Int32)lastNonZero + 64; assert ( padOffset < exifContents->size() ); ok = true; } diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/JPEG_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/JPEG_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/JPEG_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/JPEG_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __JPEG_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2004 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2004 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! Must be the first #include! diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/Makefile.in exempi-2.6.1/XMPFiles/source/FileHandlers/Makefile.in --- exempi-2.5.2/XMPFiles/source/FileHandlers/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -388,6 +388,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/MP3_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/MP3_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/MP3_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/MP3_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2008 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2008 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -131,7 +131,7 @@ this->tagIsDirty = false; this->mustShift = false; this->majorVersion = 2; - this->minorVersion = 3; + this->minorVersion = 2; this->hasID3Tag = false; this->hasFooter = false; this->extHeaderSize = 0; @@ -207,9 +207,11 @@ // read frames XMP_Uns32 xmpID = XMP_V23_ID; + XMP_Uns16 frameHeaderSize = ID3v2Frame::kV23_FrameHeaderSize; if ( this->majorVersion == 2 ) { xmpID = XMP_V22_ID; + frameHeaderSize = ID3v2Frame::kV22_FrameHeaderSize; } while ( file->Offset() < this->oldTagSize ) { @@ -253,7 +255,7 @@ // No space for another frame? => assume into ID3v2.4 padding. XMP_Int64 newPos = file->Offset(); XMP_Int64 spaceLeft = this->oldTagSize - newPos; // Depends on first check below! - if ( (newPos > this->oldTagSize) || (spaceLeft < (XMP_Int64)ID3Header::kID3_TagHeaderSize) ) break; + if ( (newPos > this->oldTagSize) || (spaceLeft < frameHeaderSize ) ) break; } @@ -317,11 +319,8 @@ //get the frame ID to look for XMP_Uns32 logicalID = GetUns32BE ( reconProps[r].mainID ); XMP_Uns32 storedID = logicalID; - // if the v22ID is empty, skip this. - // See https://gitlab.freedesktop.org/libopenraw/exempi/issues/14 - if ( this->majorVersion == 2 && reconProps[r].v22ID[0] ) { + if ( this->majorVersion == 2 && reconProps[r].v22ID != NULL && *(reconProps[r].v22ID) != '\0') //handling "" value of v22ID storedID = GetUns32BE ( reconProps[r].v22ID ); - } // deal with each such frame in the frameVector // (since there might be several, some of them not applicable, i.e. COMM) @@ -379,7 +378,7 @@ { try { // Don't let wrong dates in id3 stop import. if ( ! hasTDRC ) { - newDateTime.year = SXMPUtils::ConvertToInt ( id3Text ); + newDateTime.year = (XMP_Int32)SXMPUtils::ConvertToInt ( id3Text ); newDateTime.hasDate = true; } } catch ( ... ) { @@ -394,8 +393,8 @@ // only if no TDRC has been found before //&& must have the format DDMM if ( (! hasTDRC) && (id3Text.length() == 4) ) { - newDateTime.day = SXMPUtils::ConvertToInt (id3Text.substr(0,2)); - newDateTime.month = SXMPUtils::ConvertToInt ( id3Text.substr(2,2)); + newDateTime.day = (XMP_Int32)SXMPUtils::ConvertToInt (id3Text.substr(0,2)); + newDateTime.month = (XMP_Int32)SXMPUtils::ConvertToInt ( id3Text.substr(2,2)); newDateTime.hasDate = true; } } catch ( ... ) { @@ -410,8 +409,8 @@ // only if no TDRC has been found before // && must have the format HHMM if ( (! hasTDRC) && (id3Text.length() == 4) ) { - newDateTime.hour = SXMPUtils::ConvertToInt (id3Text.substr(0,2)); - newDateTime.minute = SXMPUtils::ConvertToInt ( id3Text.substr(2,2)); + newDateTime.hour = (XMP_Int32)SXMPUtils::ConvertToInt (id3Text.substr(0,2)); + newDateTime.minute = (XMP_Int32)SXMPUtils::ConvertToInt ( id3Text.substr(2,2)); newDateTime.hasTime = true; } } catch ( ... ) { @@ -506,7 +505,8 @@ XMP_Uns32 logicalID = GetUns32BE ( reconProps[r].mainID ); XMP_Uns32 storedID = logicalID; - if ( this->majorVersion == 2 ) storedID = GetUns32BE ( reconProps[r].v22ID ); + if ( this->majorVersion == 2 && reconProps[r].v22ID != NULL && *(reconProps[r].v22ID) != '\0') //handling "" value of v22ID) + storedID = GetUns32BE ( reconProps[r].v22ID ); ID3v2Frame* frame = framesMap[ storedID ]; // the actual frame (if already existing) diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/MP3_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/MP3_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/MP3_Handler.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/MP3_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __MP3_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2008 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2008 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/MPEG2_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/MPEG2_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/MPEG2_Handler.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/MPEG2_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2005 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2005 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #if XMP_WinBuild diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/MPEG2_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/MPEG2_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/MPEG2_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/MPEG2_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __MPEG2_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2005 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2005 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/MPEG4_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/MPEG4_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/MPEG4_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/MPEG4_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -504,7 +504,7 @@ // ExportMVHDItems // =============== -static void ExportMVHDItems ( const SXMPMeta & xmp, MOOV_Manager * moovMgr ) +static void ExportMVHDItems ( const SXMPMeta & xmp, MOOV_Manager * moovMgr , bool haveISOFile) { XMP_DateTime xmpDate; bool createFound, modifyFound; @@ -532,7 +532,7 @@ XMP_Uns64 oldCreate = GetUns64BE ( mvhdInfo.content + 4 ); XMP_Uns64 oldModify = GetUns64BE ( mvhdInfo.content + 12 ); - if ( createFound ) { + if ( createFound && haveISOFile) { if ( createSeconds != oldCreate ) PutUns64BE ( createSeconds, ((XMP_Uns8*)mvhdInfo.content + 4) ); moovMgr->NoteChange(); } @@ -550,7 +550,7 @@ XMP_Uns32 oldCreate = GetUns32BE ( mvhdInfo.content + 4 ); XMP_Uns32 oldModify = GetUns32BE ( mvhdInfo.content + 8 ); - if ( createFound ) { + if ( createFound && haveISOFile) { if ( (XMP_Uns32)createSeconds != oldCreate ) PutUns32BE ( (XMP_Uns32)createSeconds, ((XMP_Uns8*)mvhdInfo.content + 4) ); moovMgr->NoteChange(); } @@ -589,14 +589,14 @@ XMP_Uns64 temp64; temp64 = (XMP_Uns64) GetUns32BE ( &mvhdV0->creationTime ); - if ( createFound ) temp64 = createSeconds; + if ( createFound && haveISOFile) temp64 = createSeconds; mvhdV1.creationTime = MakeUns64BE ( temp64 ); temp64 = (XMP_Uns64) GetUns32BE ( &mvhdV0->modificationTime ); if ( modifyFound ) temp64 = modifySeconds; mvhdV1.modificationTime = MakeUns64BE ( temp64 ); - moovMgr->SetBox ( mvhdRef, &mvhdV1, sizeof ( MOOV_Manager::Content_mvhd_1 ) ); + moovMgr->ISOBaseMedia_Manager::SetBox( mvhdRef, &mvhdV1, sizeof ( MOOV_Manager::Content_mvhd_1 ) ); } @@ -712,7 +712,7 @@ std::string newContent = "vfffll"; newContent += xmpValue; memcpy ( (char*)newContent.c_str(), cprtInfo.content, 6 ); // Keep old version, flags, and language. - moovMgr->SetBox ( cprtRef, newContent.c_str(), (XMP_Uns32)(newContent.size() + 1) ); + moovMgr->ISOBaseMedia_Manager::SetBox( cprtRef, newContent.c_str(), (XMP_Uns32)(newContent.size() + 1) ); } } @@ -803,7 +803,7 @@ std::string newContent = "vfffll"; newContent += xmpValue; memcpy ( (char*)newContent.c_str(), cprtInfo.content, 6 ); // Keep old version, flags, and language. - moovMgr->SetBox ( cprtRef, newContent.c_str(), (XMP_Uns32)(newContent.size() + 1) ); + moovMgr->ISOBaseMedia_Manager::SetBox( cprtRef, newContent.c_str(), (XMP_Uns32)(newContent.size() + 1) ); } } @@ -834,6 +834,20 @@ } // ExportQuickTimeItems +#if 0 +static bool ExportQTMetaBoxItems(const SXMPMeta & xmp, TradQT_Manager * qtMgr, MOOV_Manager * moovMgr) +{ + MOOV_Manager::BoxInfo moovMetaInfo; + MOOV_Manager::BoxRef moovMetaRef = moovMgr->GetBox("moov/meta", &moovMetaInfo); + + if (moovMetaRef == 0 ) return false; + qtMgr->ExportLocationMetaAtom(xmp, moovMgr); + qtMgr->ExportCreateDateMetaAtom(xmp, moovMgr); + return true; + +} // ExportQTMetaBoxItems +#endif + // ================================================================================================= // SelectTimeFormat // ================ @@ -965,11 +979,11 @@ // Do some drop-frame corrections at this point: If this is drop-frame and the units of minutes // is non-zero, and the seconds are zero, and the frames are zero or one, the time is illegal. - // Perform correction by subtracting 1 from the units of minutes and adding 1798 to the frames.Ê + // Perform correction by subtracting 1 from the units of minutes and adding 1798 to the frames. // For example, 1:00:00 becomes 59:28, and 1:00:01 becomes 59:29. A special case can occur for // when the frameCount just before the minHigh calculation is less than framesPerTenMinutes but // more than 10*framesPerMinute. This happens because of roundoff, and will result in a minHigh - // of 0 and a minLow of 10.ÊThe drop frame correction mustÊalso be performed for this case. + // of 0 and a minLow of 10.The drop frame correction mustalso be performed for this case. if ( tmcdInfo.isDropFrame ) { if ( (minLow == 10) || ((minLow != 0) && (frameCount < dropLimit)) ) { @@ -1055,7 +1069,7 @@ XMP_Assert ( moovRef != 0 ); MOOV_Manager::BoxInfo trakInfo; - MOOV_Manager::BoxRef trakRef; + MOOV_Manager::BoxRef trakRef = NULL; size_t i = 0; for ( ; i < moovInfo.childCount; ++i ) { @@ -1174,7 +1188,7 @@ bool haveItem; bool haveImports = false; - // The QT user data item '©REL' goes into xmpDM:tapeName, and the 'name' box at the end of the + // The QT user data item 'REL' goes into xmpDM:tapeName, and the 'name' box at the end of the // timecode sample description goes into xmpDM:altTapeName. haveImports |= qtInfo.ImportSimpleXMP ( kQTilst_Reel, xmp, kXMP_NS_DM, "tapeName" ); if ( ! tmcdInfo.macName.empty() ) { @@ -1185,7 +1199,7 @@ } } - // The QT user data item '©TSC' goes into xmpDM:startTimeScale. If that isn't present, then + // The QT user data item 'TSC' goes into xmpDM:startTimeScale. If that isn't present, then // the timecode sample description's timeScale is used. haveItem = qtInfo.ImportSimpleXMP ( kQTilst_TimeScale, xmp, kXMP_NS_DM, "startTimeScale" ); if ( tmcdInfo.stsdBoxFound & (! haveItem) ) { @@ -1194,7 +1208,7 @@ } haveImports |= haveItem; - // The QT user data item '©TSZ' goes into xmpDM:startTimeSampleSize. If that isn't present, then + // The QT user data item 'TSZ' goes into xmpDM:startTimeSampleSize. If that isn't present, then // the timecode sample description's frameDuration is used. haveItem = qtInfo.ImportSimpleXMP ( kQTilst_TimeSize, xmp, kXMP_NS_DM, "startTimeSampleSize" ); if ( tmcdInfo.stsdBoxFound & (! haveItem) ) { @@ -1208,7 +1222,7 @@ // The Timecode struct type is used for xmpDM:startTimecode and xmpDM:altTimecode. For both, only // the xmpDM:timeValue and xmpDM:timeFormat fields are set. - // The QT user data item '©TIM' goes into xmpDM:startTimecode/xmpDM:timeValue. This is an already + // The QT user data item 'TIM' goes into xmpDM:startTimecode/xmpDM:timeValue. This is an already // formatted timecode string. The XMP values of xmpDM:startTimeScale, xmpDM:startTimeSampleSize, // and xmpDM:startTimecode/xmpDM:timeValue are used to select the timeFormat value. haveImports |= qtInfo.ImportSimpleXMP ( kQTilst_Timecode, xmp, kXMP_NS_DM, "startTimecode/xmpDM:timeValue" ); @@ -1392,7 +1406,7 @@ memcpy ( &stsdNewContent[stsdPrefixSize+12], tmcdInfo->macName.c_str(), tmcdInfo->macName.size() ); } - moovMgr->SetBox ( stsdRef, &stsdNewContent[0], stsdNewContentSize ); + moovMgr->ISOBaseMedia_Manager::SetBox( stsdRef, &stsdNewContent[0], stsdNewContentSize ); } @@ -1512,32 +1526,32 @@ Flip4 ( &rawCr8r.appleEvent ); } - std::string fieldPath; + std::string fieldPathStr; - SXMPUtils::ComposeStructFieldPath ( kXMP_NS_CreatorAtom, "macAtom", kXMP_NS_CreatorAtom, "applicationCode", &fieldPath ); - if ( (rawCr8r.creatorCode != 0) && (! xmp->DoesPropertyExist ( kXMP_NS_CreatorAtom, fieldPath.c_str() )) ) { + SXMPUtils::ComposeStructFieldPath ( kXMP_NS_CreatorAtom, "macAtom", kXMP_NS_CreatorAtom, "applicationCode", &fieldPathStr ); + if ( (rawCr8r.creatorCode != 0) && (! xmp->DoesPropertyExist ( kXMP_NS_CreatorAtom, fieldPathStr.c_str() )) ) { haveXMP = true; - xmp->SetProperty_Int64 ( kXMP_NS_CreatorAtom, fieldPath.c_str(), (XMP_Int64)rawCr8r.creatorCode ); // ! Unsigned trickery. + xmp->SetProperty_Int64 ( kXMP_NS_CreatorAtom, fieldPathStr.c_str(), (XMP_Int64)rawCr8r.creatorCode ); // ! Unsigned trickery. } - SXMPUtils::ComposeStructFieldPath ( kXMP_NS_CreatorAtom, "macAtom", kXMP_NS_CreatorAtom, "invocationAppleEvent", &fieldPath ); - if ( (rawCr8r.appleEvent != 0) && (! xmp->DoesPropertyExist ( kXMP_NS_CreatorAtom, fieldPath.c_str() )) ) { + SXMPUtils::ComposeStructFieldPath ( kXMP_NS_CreatorAtom, "macAtom", kXMP_NS_CreatorAtom, "invocationAppleEvent", &fieldPathStr ); + if ( (rawCr8r.appleEvent != 0) && (! xmp->DoesPropertyExist ( kXMP_NS_CreatorAtom, fieldPathStr.c_str() )) ) { haveXMP = true; - xmp->SetProperty_Int64 ( kXMP_NS_CreatorAtom, fieldPath.c_str(), (XMP_Int64)rawCr8r.appleEvent ); // ! Unsigned trickery. + xmp->SetProperty_Int64 ( kXMP_NS_CreatorAtom, fieldPathStr.c_str(), (XMP_Int64)rawCr8r.appleEvent ); // ! Unsigned trickery. } rawCr8r.fileExt[15] = 0; // Ensure a terminating nul. - SXMPUtils::ComposeStructFieldPath ( kXMP_NS_CreatorAtom, "windowsAtom", kXMP_NS_CreatorAtom, "extension", &fieldPath ); - if ( (rawCr8r.fileExt[0] != 0) && (! xmp->DoesPropertyExist ( kXMP_NS_CreatorAtom, fieldPath.c_str() )) ) { + SXMPUtils::ComposeStructFieldPath ( kXMP_NS_CreatorAtom, "windowsAtom", kXMP_NS_CreatorAtom, "extension", &fieldPathStr ); + if ( (rawCr8r.fileExt[0] != 0) && (! xmp->DoesPropertyExist ( kXMP_NS_CreatorAtom, fieldPathStr.c_str() )) ) { haveXMP = true; - xmp->SetProperty ( kXMP_NS_CreatorAtom, fieldPath.c_str(), rawCr8r.fileExt ); + xmp->SetProperty ( kXMP_NS_CreatorAtom, fieldPathStr.c_str(), rawCr8r.fileExt ); } rawCr8r.appOptions[15] = 0; // Ensure a terminating nul. - SXMPUtils::ComposeStructFieldPath ( kXMP_NS_CreatorAtom, "windowsAtom", kXMP_NS_CreatorAtom, "invocationFlags", &fieldPath ); - if ( (rawCr8r.appOptions[0] != 0) && (! xmp->DoesPropertyExist ( kXMP_NS_CreatorAtom, fieldPath.c_str() )) ) { + SXMPUtils::ComposeStructFieldPath ( kXMP_NS_CreatorAtom, "windowsAtom", kXMP_NS_CreatorAtom, "invocationFlags", &fieldPathStr ); + if ( (rawCr8r.appOptions[0] != 0) && (! xmp->DoesPropertyExist ( kXMP_NS_CreatorAtom, fieldPathStr.c_str() )) ) { haveXMP = true; - xmp->SetProperty ( kXMP_NS_CreatorAtom, fieldPath.c_str(), rawCr8r.appOptions ); + xmp->SetProperty ( kXMP_NS_CreatorAtom, fieldPathStr.c_str(), rawCr8r.appOptions ); } rawCr8r.appName[31] = 0; // Ensure a terminating nul. @@ -1922,107 +1936,6 @@ } // CheckFinalBox -// ================================================================================================= -// WriteBoxHeader -// ============== - -static void WriteBoxHeader ( XMP_IO* fileRef, XMP_Uns32 boxType, XMP_Uns64 boxSize ) -{ - XMP_Uns32 u32; - XMP_Uns64 u64; - XMP_Enforce ( boxSize >= 8 ); // The size must be the full size, not just the content. - - if ( boxSize <= 0xFFFFFFFF ) { - - u32 = MakeUns32BE ( (XMP_Uns32)boxSize ); - fileRef->Write ( &u32, 4 ); - u32 = MakeUns32BE ( boxType ); - fileRef->Write ( &u32, 4 ); - - } else { - - u32 = MakeUns32BE ( 1 ); - fileRef->Write ( &u32, 4 ); - u32 = MakeUns32BE ( boxType ); - fileRef->Write ( &u32, 4 ); - u64 = MakeUns64BE ( boxSize ); - fileRef->Write ( &u64, 8 ); - - } - -} // WriteBoxHeader - -// ================================================================================================= -// WipeBoxFree -// =========== -// -// Change the box's type to 'free' (or create a 'free' box) and zero the content. - -static XMP_Uns8 kZeroes [64*1024]; // C semantics guarantee zero initialization. - -static void WipeBoxFree ( XMP_IO* fileRef, XMP_Uns64 boxOffset, XMP_Uns32 boxSize ) -{ - if ( boxSize == 0 ) return; - XMP_Enforce ( boxSize >= 8 ); - - fileRef->Seek ( boxOffset, kXMP_SeekFromStart ); - XMP_Uns32 u32; - u32 = MakeUns32BE ( boxSize ); // ! The actual size should not change, but might have had a long header. - fileRef->Write ( &u32, 4 ); - u32 = MakeUns32BE ( ISOMedia::k_free ); - fileRef->Write ( &u32, 4 ); - - XMP_Uns32 ioCount = sizeof ( kZeroes ); - for ( boxSize -= 8; boxSize > 0; boxSize -= ioCount ) { - if ( ioCount > boxSize ) ioCount = boxSize; - fileRef->Write ( &kZeroes[0], ioCount ); - } - -} // WipeBoxFree - -// ================================================================================================= -// CreateFreeSpaceList -// =================== - -struct SpaceInfo { - XMP_Uns64 offset, size; - SpaceInfo() : offset(0), size(0) {}; - SpaceInfo ( XMP_Uns64 _offset, XMP_Uns64 _size ) : offset(_offset), size(_size) {}; -}; - -typedef std::vector FreeSpaceList; - -static void CreateFreeSpaceList ( XMP_IO* fileRef, XMP_Uns64 fileSize, - XMP_Uns64 oldOffset, XMP_Uns32 oldSize, FreeSpaceList * spaceList ) -{ - XMP_Uns64 boxPos=0, boxNext=0, adjacentFree=0; - ISOMedia::BoxInfo currBox; - - fileRef->Rewind(); - spaceList->clear(); - - for ( boxPos = 0; boxPos < fileSize; boxPos = boxNext ) { - - boxNext = ISOMedia::GetBoxInfo ( fileRef, boxPos, fileSize, &currBox, true /* throw errors */ ); - XMP_Uns64 currSize = currBox.headerSize + currBox.contentSize; - - if ( (currBox.boxType == ISOMedia::k_free) || - (currBox.boxType == ISOMedia::k_skip) || - ((boxPos == oldOffset) && (currSize == oldSize)) ) { - - if ( spaceList->empty() || (boxPos != adjacentFree) ) { - spaceList->push_back ( SpaceInfo ( boxPos, currSize ) ); - adjacentFree = boxPos + currSize; - } else { - SpaceInfo * lastSpace = &spaceList->back(); - lastSpace->size += currSize; - } - - } - - } - -} // CreateFreeSpaceList // ================================================================================================= // MPEG4_MetaHandler::CacheFileData @@ -2037,13 +1950,13 @@ { XMP_Assert ( ! this->containsXMP ); - XMPFiles * parent = this->parent; - XMP_OptionBits openFlags = parent->openFlags; + XMPFiles * parent_ = this->parent; + XMP_OptionBits openFlags = parent_->openFlags; - XMP_IO* fileRef = parent->ioRef; + XMP_IO* fileRef = parent_->ioRef; - XMP_AbortProc abortProc = parent->abortProc; - void * abortArg = parent->abortArg; + XMP_AbortProc abortProc = parent_->abortProc; + void * abortArg = parent_->abortArg; const bool checkAbort = (abortProc != 0); // First do some special case repair to QuickTime files, based on bad files in the wild. @@ -2052,7 +1965,7 @@ const bool doRepair = XMP_OptionIsSet ( openFlags, kXMPFiles_OpenRepairFile ); if ( isUpdate ) { - CheckQTFileStructure ( this, doRepair, &parent->errorCallback ); // Will throw for failure. + CheckQTFileStructure ( this, doRepair, &parent_->errorCallback ); // Will throw for failure. } // Cache the top level 'moov' and 'uuid'/XMP boxes. @@ -2068,6 +1981,7 @@ bool xmpUuidFound = (! haveISOFile); // Ignore the XMP 'uuid' box for QuickTime files. bool moovIgnored = (xmpOnly & haveISOFile); // Ignore the 'moov' box for XMP-only ISO files. bool moovFound = moovIgnored; + bool metaFound = !haveISOFile; // Ignore the file level 'meta' box for QuickTime files. for ( boxPos = 0; boxPos < fileSize; boxPos = boxNext ) { @@ -2081,7 +1995,7 @@ if ( (! moovFound) && (currBox.boxType == ISOMedia::k_moov) ) { XMP_Uns64 fullMoovSize = currBox.headerSize + currBox.contentSize; - if ( fullMoovSize > moovBoxSizeLimit ) { // From here on we know 32-bit offsets are safe. + if ( fullMoovSize > TopBoxSizeLimit) { // From here on we know 32-bit offsets are safe. XMP_Throw ( "Oversize 'moov' box", kXMPErr_EnforceFailure ); } @@ -2092,12 +2006,13 @@ this->moovBoxPos = boxPos; this->moovBoxSize = (XMP_Uns32)fullMoovSize; moovFound = true; - if ( xmpUuidFound ) break; // Exit the loop when both are found. + if ( xmpUuidFound && metaFound ) break; // Exit the loop when both are found. - } else if ( (! xmpUuidFound) && (currBox.boxType == ISOMedia::k_uuid) && ( memcmp( currBox.idUUID, ISOMedia::k_xmpUUID, 16 ) == 0 ) ) { + } + else if ( (! xmpUuidFound) && (currBox.boxType == ISOMedia::k_uuid) && ( memcmp( currBox.idUUID, ISOMedia::k_xmpUUID, 16 ) == 0 ) ) { XMP_Uns64 fullUuidSize = currBox.headerSize + currBox.contentSize; - if ( fullUuidSize > moovBoxSizeLimit ) { // From here on we know 32-bit offsets are safe. + if ( fullUuidSize > TopBoxSizeLimit) { // From here on we know 32-bit offsets are safe. XMP_Throw ( "Oversize XMP 'uuid' box", kXMPErr_EnforceFailure ); } @@ -2110,7 +2025,7 @@ this->xmpBoxPos = boxPos; this->xmpBoxSize = (XMP_Uns32)fullUuidSize; xmpUuidFound = true; - if ( moovFound ) break; // Exit the loop when both are found. + if ( moovFound && metaFound ) break; // Exit the loop when both are found. } @@ -2118,7 +2033,7 @@ if ( (! moovFound) && (! moovIgnored) ){ XMP_Error error ( kXMPErr_BadFileFormat,"No 'moov' box" ); - XMPFileHandler::NotifyClient(&parent->errorCallback, kXMPErrSev_FileFatal, error); + XMPFileHandler::NotifyClient(&parent_->errorCallback, kXMPErrSev_FileFatal, error); } } // MPEG4_MetaHandler::CacheFileData @@ -2132,8 +2047,8 @@ if ( this->processedXMP ) return; this->processedXMP = true; // Make sure only called once. - XMPFiles * parent = this->parent; - XMP_OptionBits openFlags = parent->openFlags; + XMPFiles * parent_ = this->parent; + XMP_OptionBits openFlags = parent_->openFlags; bool xmpOnly = XMP_OptionIsSet ( openFlags, kXMPFiles_OpenOnlyXMP ); bool haveISOFile = (this->fileMode == MOOV_Manager::kFileIsNormalISO); @@ -2158,10 +2073,9 @@ if ( this->moovMgr.fullSubtree.empty() ) { XMP_Error error ( kXMPErr_BadFileFormat,"No 'moov' box" ); - XMPFileHandler::NotifyClient(&parent->errorCallback, kXMPErrSev_FileFatal, error); + XMPFileHandler::NotifyClient(&parent_->errorCallback, kXMPErrSev_FileFatal, error); } this->moovMgr.ParseMemoryTree ( this->fileMode ); - if ( (this->xmpBoxPos == 0) || (! haveISOFile) ) { // Look for the QuickTime moov/uuid/XMP_ box. @@ -2191,44 +2105,46 @@ // Import the non-XMP items. Do the imports in reverse priority order, last import wins! - MOOV_Manager::BoxInfo mvhdInfo; - MOOV_Manager::BoxRef mvhdRef = this->moovMgr.GetBox ( "moov/mvhd", &mvhdInfo ); - bool mvhdFound = ((mvhdRef != 0) && (mvhdInfo.contentSize != 0)); - - MOOV_Manager::BoxInfo udtaInfo; - MOOV_Manager::BoxRef udtaRef = this->moovMgr.GetBox ( "moov/udta", &udtaInfo ); - std::vector cprtBoxes; + if ( !xmpOnly ) { + MOOV_Manager::BoxInfo mvhdInfo; + MOOV_Manager::BoxRef mvhdRef = this->moovMgr.GetBox ( "moov/mvhd", &mvhdInfo ); + bool mvhdFound = ((mvhdRef != 0) && (mvhdInfo.contentSize != 0)); - if ( udtaRef != 0 ) { - for ( XMP_Uns32 i = 0; i < udtaInfo.childCount; ++i ) { - MOOV_Manager::BoxInfo currInfo; - MOOV_Manager::BoxRef currRef = this->moovMgr.GetNthChild ( udtaRef, i, &currInfo ); - if ( currRef == 0 ) break; // Sanity check, should not happen. - if ( currInfo.boxType != ISOMedia::k_cprt ) continue; - cprtBoxes.push_back ( currInfo ); + MOOV_Manager::BoxInfo udtaInfo; + MOOV_Manager::BoxRef udtaRef = this->moovMgr.GetBox ( "moov/udta", &udtaInfo ); + std::vector cprtBoxes; + if ( udtaRef != 0 ) { + for ( XMP_Uns32 i = 0; i < udtaInfo.childCount; ++i ) { + MOOV_Manager::BoxInfo currInfo; + MOOV_Manager::BoxRef currRef = this->moovMgr.GetNthChild ( udtaRef, i, &currInfo ); + if ( currRef == 0 ) break; // Sanity check, should not happen. + if ( currInfo.boxType != ISOMedia::k_cprt ) continue; + cprtBoxes.push_back ( currInfo ); + } } - } - bool cprtFound = (! cprtBoxes.empty()); + bool cprtFound = (! cprtBoxes.empty()); - bool tradQTFound = this->tradQTMgr.ParseCachedBoxes ( this->moovMgr ); - bool tmcdFound = this->ParseTimecodeTrack(); - if ( this->fileMode == MOOV_Manager::kFileIsNormalISO ) { + bool tradQTFound = this->tradQTMgr.ParseCachedBoxes ( this->moovMgr ); - if ( mvhdFound ) this->containsXMP |= ImportMVHDItems ( mvhdInfo, &this->xmpObj ); - if ( cprtFound ) this->containsXMP |= ImportISOCopyrights ( cprtBoxes, &this->xmpObj ); - if ( tmcdFound ) this->containsXMP |= ImportTimecodeItems ( this->tmcdInfo, this->tradQTMgr, &this->xmpObj ); - } else { // This is a QuickTime file, either traditional or modern. + bool tmcdFound = this->ParseTimecodeTrack(); - if ( mvhdFound ) this->containsXMP |= ImportMVHDItems ( mvhdInfo, &this->xmpObj ); - if ( cprtFound ) this->containsXMP |= ImportISOCopyrights ( cprtBoxes, &this->xmpObj ); - if ( tmcdFound | tradQTFound ) { - // Some of the timecode items are in the .../udta/©... set but handled by ImportTimecodeItems. - this->containsXMP |= ImportTimecodeItems ( this->tmcdInfo, this->tradQTMgr, &this->xmpObj ); - } + if ( this->fileMode == MOOV_Manager::kFileIsNormalISO ) { - this->containsXMP |= ImportCr8rItems ( this->moovMgr, &this->xmpObj ); + if ( mvhdFound ) this->containsXMP |= ImportMVHDItems ( mvhdInfo, &this->xmpObj ); + if ( cprtFound ) this->containsXMP |= ImportISOCopyrights ( cprtBoxes, &this->xmpObj ); + if ( tmcdFound ) this->containsXMP |= ImportTimecodeItems ( this->tmcdInfo, this->tradQTMgr, &this->xmpObj ); + } else { // This is a QuickTime file, either traditional or modern. + + if ( mvhdFound ) this->containsXMP |= ImportMVHDItems ( mvhdInfo, &this->xmpObj ); + if ( cprtFound ) this->containsXMP |= ImportISOCopyrights ( cprtBoxes, &this->xmpObj ); + if ( tmcdFound | tradQTFound ) { + // Some of the timecode items are in the .../udta/... set but handled by ImportTimecodeItems. + this->containsXMP |= ImportTimecodeItems ( this->tmcdInfo, this->tradQTMgr, &this->xmpObj ); + } + this->containsXMP |= ImportCr8rItems ( this->moovMgr, &this->xmpObj ); + } } } // MPEG4_MetaHandler::ProcessXMP @@ -2459,6 +2375,8 @@ // MPEG4_MetaHandler::UpdateTopLevelBox // ==================================== +static XMP_Uns8 kZeroes[64 * 1024]; // C semantics guarantee zero initialization. + void MPEG4_MetaHandler::UpdateTopLevelBox ( XMP_Uns64 oldOffset, XMP_Uns32 oldSize, const XMP_Uns8 * newBox, XMP_Uns32 newSize ) { @@ -2488,7 +2406,7 @@ // The new size is smaller and there is enough room to create a free box. fileRef->Seek ( oldOffset, kXMP_SeekFromStart ); fileRef->Write ( newBox, newSize ); - WipeBoxFree ( fileRef, (oldOffset + newSize), (oldSize - newSize) ); + this->moovMgr.WipeBoxFree ( fileRef, (oldOffset + newSize), (oldSize - newSize) ); } else { @@ -2511,7 +2429,7 @@ if ( newSize < totalRoom ) { // Don't wipe, at most 7 old bytes left, it will be covered by the free header. - WriteBoxHeader ( fileRef, ISOMedia::k_free, (totalRoom - newSize) ); + this->moovMgr.WriteBoxHeader ( fileRef, ISOMedia::k_free, (totalRoom - newSize) ); } } else { @@ -2519,8 +2437,12 @@ // Create a list of all top level free space, including the old space as free. Use the // earliest space that fits. If none, append. - FreeSpaceList spaceList; - CreateFreeSpaceList ( fileRef, oldFileSize, oldOffset, oldSize, &spaceList ); + /*FreeSpaceList spaceList; + CreateFreeSpaceList ( fileRef, oldFileSize, oldOffset, oldSize, &spaceList );*/ + + ISOBaseMedia_Manager::SpaceList spaceList; + + this->moovMgr.CreateFreeSpaceList(fileRef, oldFileSize, oldOffset, oldSize, &spaceList); size_t freeSlot, limit; for ( freeSlot = 0, limit = spaceList.size(); freeSlot < limit; ++freeSlot ) { @@ -2534,14 +2456,14 @@ CheckFinalBox ( fileRef, abortProc, abortArg ); fileRef->ToEOF(); fileRef->Write ( newBox, newSize ); - WipeBoxFree ( fileRef, oldOffset, oldSize ); + this->moovMgr.WipeBoxFree ( fileRef, oldOffset, oldSize ); } else { // Use the available free space. Wipe non-overlapping parts of the old box. The old // box is either included in the new space, or is fully disjoint. - SpaceInfo & newSpace = spaceList[freeSlot]; + ISOBaseMedia_Manager::SpaceInfo & newSpace = spaceList[freeSlot]; bool oldIsDisjoint = ((oldOffset + oldSize) <= newSpace.offset) || // Old is in front. ((newSpace.offset + newSpace.size) <= oldOffset); // Old is behind. @@ -2559,11 +2481,11 @@ fileRef->Seek ( newSpace.offset, kXMP_SeekFromStart ); fileRef->Write ( newBox, newSize ); - if ( newFreeSize > 0 ) WriteBoxHeader ( fileRef, ISOMedia::k_free, newFreeSize ); + if ( newFreeSize > 0 ) this->moovMgr.WriteBoxHeader ( fileRef, ISOMedia::k_free, newFreeSize ); if ( oldIsDisjoint ) { - WipeBoxFree ( fileRef, oldOffset, oldSize ); + this->moovMgr.WipeBoxFree ( fileRef, oldOffset, oldSize ); } else { @@ -2808,17 +2730,17 @@ LayoutMap::iterator layoutEnd = optLayout.end(); for ( ; layoutPos != layoutEnd; ++layoutPos ) { - LayoutInfo * currBox = layoutPos->second; - XMP_Assert ( (XMP_Int64)currBox->newOffset == tempFile->Length() ); - originalFile->Seek ( currBox->oldOffset, kXMP_SeekFromStart ); - XIO::Copy ( originalFile, tempFile, currBox->boxSize, abortProc, abortArg ); + LayoutInfo * pCurrBox = layoutPos->second; + XMP_Assert ( (XMP_Int64)pCurrBox->newOffset == tempFile->Length() ); + originalFile->Seek ( pCurrBox->oldOffset, kXMP_SeekFromStart ); + XIO::Copy ( originalFile, tempFile, pCurrBox->boxSize, abortProc, abortArg ); } // Update the offset tables in the temp file. Create a layout map ordered by the last actual // offset of the old box's content to enable fast lookup within AdjustOffset. LayoutMap oldEndMap; - for ( size_t i = 0, limit = fileBoxes.size(); i < limit; ++i ) { + for ( size_t i = 0, nlimit = fileBoxes.size(); i < nlimit; ++i ) { XMP_Uns64 oldEnd = fileBoxes[i].oldOffset + fileBoxes[i].boxSize - 1; // ! Want the last actual offset! oldEndMap.insert ( oldEndMap.end(), LayoutMap::value_type ( oldEnd, &fileBoxes[i] ) ); } @@ -2829,9 +2751,9 @@ moovRef = this->moovMgr.GetBox ( "moov", &boxInfo ); XMP_Enforce ( moovRef != 0 ); - for ( size_t i1 = 0, limit = boxInfo.childCount; i1 < limit; ++i1 ) { + for ( size_t i = 0, nlimit = boxInfo.childCount; i < nlimit; ++i ) { - trakRef = this->moovMgr.GetNthChild ( moovRef, i1, &boxInfo ); + trakRef = this->moovMgr.GetNthChild ( moovRef, i, &boxInfo ); if ( boxInfo.boxType != ISOMedia::k_trak ) continue; tempRef = this->moovMgr.GetTypeChild ( trakRef, ISOMedia::k_mdia, 0 ); @@ -2864,7 +2786,7 @@ tempFile->Seek ( stcoTableOffset, kXMP_SeekFromStart ); XMP_Uns32 * rawOldU32 = (XMP_Uns32*) (boxInfo.content + 4+4); - for ( XMP_Uns32 i = 0; i < offsetCount; ++i, ++rawOldU32 ) { + for ( XMP_Uns32 j = 0; j < offsetCount; ++j, ++rawOldU32 ) { XMP_Uns64 newOffset = AdjustOffset ( (XMP_Uns64)GetUns32BE(rawOldU32), oldEndMap,&parent->errorCallback ); XMP_Uns32 u32 = MakeUns32BE ( (XMP_Uns32)newOffset ); tempFile->Write ( &u32, 4 ); @@ -2878,7 +2800,7 @@ tempFile->Seek ( co64TableOffset, kXMP_SeekFromStart ); XMP_Uns64 * rawOldU64 = (XMP_Uns64*) (boxInfo.content + 4+4); - for ( XMP_Uns32 i = 0; i < offsetCount; ++i, ++rawOldU64 ) { + for ( XMP_Uns32 j = 0; j < offsetCount; ++j, ++rawOldU64 ) { XMP_Uns64 newOffset = AdjustOffset ( GetUns64BE(rawOldU64), oldEndMap,&parent->errorCallback ); XMP_Uns64 u64 = MakeUns64BE ( newOffset ); tempFile->Write ( &u64, 8 ); @@ -2934,16 +2856,55 @@ // Update the 'moov' subtree with exports from the XMP, but not the XMP itself (for QT files). - ExportMVHDItems ( this->xmpObj, &this->moovMgr ); + ExportMVHDItems ( this->xmpObj, &this->moovMgr , haveISOFile); ExportISOCopyrights ( this->xmpObj, &this->moovMgr ); ExportQuickTimeItems ( this->xmpObj, &this->tradQTMgr, &this->moovMgr ); - ExportTimecodeItems ( this->xmpObj, &this->tmcdInfo, &this->tradQTMgr, &this->moovMgr ); +#if 0 + ExportQTMetaBoxItems (this->xmpObj, &this->tradQTMgr, &this->moovMgr); //to export metadata present in moov/meta box(currently on CreationDate) +#endif + ExportTimecodeItems ( this->xmpObj, &this->tmcdInfo, &this->tradQTMgr, &this->moovMgr ); if ( ! haveISOFile ) ExportCr8rItems ( this->xmpObj, &this->moovMgr ); + bool updateXMPPacket = false; + + if (!haveISOFile) { + std::string propValue; + + MOOV_Manager::BoxInfo mvhdInfo; + MOOV_Manager::BoxRef mvhdRef = this->moovMgr.GetBox("moov/mvhd", &mvhdInfo); + bool mvhdFound = ((mvhdRef != 0) && (mvhdInfo.contentSize >= 4)); + + if (mvhdFound) { + this->xmpObj.DeleteProperty(kXMP_NS_XMP, "CreateDate"); + updateXMPPacket = true; + } + + } + else { + } + + if (updateXMPPacket) { + XMP_Int32 oldPacketLength = this->packetInfo.length; + XMP_Int64 oldPacketOffset = this->packetInfo.offset; + + if (oldPacketOffset == kXMPFiles_UnknownOffset) oldPacketOffset = 0; + if (oldPacketLength == kXMPFiles_UnknownLength) oldPacketLength = 0; + + bool fileHadXMP = ((oldPacketOffset != 0) && (oldPacketLength != 0)); + + try { + XMP_OptionBits options = kXMP_UseCompactFormat; + if (fileHadXMP) options |= kXMP_ExactPacketLength; + this->xmpObj.SerializeToBuffer(&this->xmpPacket, options, oldPacketLength); + } + catch (...) { + this->xmpObj.SerializeToBuffer(&this->xmpPacket, kXMP_UseCompactFormat); + } + } + // Set up progress tracking if necessary. At this point just include the XMP size, we don't // know the 'moov' box size until later. - bool localProgressTracking = false; XMP_ProgressTracker* progressTracker = this->parent->progressTracker; if ( progressTracker != 0 ) { @@ -2981,7 +2942,7 @@ // Don't leave an old uuid XMP around (if we know about it). if ( (! havePreferredXMP) && (this->xmpBoxSize != 0) ) { - WipeBoxFree ( fileRef, this->xmpBoxPos, this->xmpBoxSize ); + this->moovMgr.WipeBoxFree ( fileRef, this->xmpBoxPos, this->xmpBoxSize ); } // The udta form of XMP has just the XMP packet. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/MPEG4_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/MPEG4_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/MPEG4_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/MPEG4_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,18 +2,20 @@ #define __MPEG4_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "XMPFiles/source/XMPFiles_Impl.hpp" #include "XMPFiles/source/FormatSupport/MOOV_Support.hpp" #include "XMPFiles/source/FormatSupport/QuickTime_Support.hpp" +#include "XMPFiles/source/FormatSupport/META_Support.hpp" + // ================================================================================================ /// \file MPEG4_Handler.hpp @@ -72,10 +74,10 @@ private: MPEG4_MetaHandler() : fileMode(0), havePreferredXMP(false), - xmpBoxPos(0), moovBoxPos(0), xmpBoxSize(0), moovBoxSize(0) {}; // Hidden on purpose. + xmpBoxPos(0), moovBoxPos(0), xmpBoxSize(0), moovBoxSize(0) + {}; // Hidden on purpose. bool ParseTimecodeTrack(); - void UpdateTopLevelBox ( XMP_Uns64 oldOffset, XMP_Uns32 oldSize, const XMP_Uns8 * newBox, XMP_Uns32 newSize ); void OptimizeFileLayout(); @@ -85,8 +87,9 @@ XMP_Uns64 xmpBoxPos; // The file offset of the XMP box (the size field, not the content). XMP_Uns64 moovBoxPos; // The file offset of the 'moov' box (the size field, not the content). XMP_Uns32 xmpBoxSize, moovBoxSize; // The full size of the boxes, not just the content. - + MOOV_Manager moovMgr; + TradQT_Manager tradQTMgr; TimecodeTrackInfo tmcdInfo; diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/P2_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/P2_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/P2_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/P2_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,14 +1,17 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2007 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2007 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. +#include +#include + #include "public/include/XMP_Const.h" #include "public/include/XMP_IO.hpp" @@ -21,9 +24,6 @@ #include "XMPFiles/source/FormatSupport/P2_Support.hpp" #include "XMPFiles/source/FormatSupport/PackageFormat_Support.hpp" -#include -#include - using namespace std; // ================================================================================================= @@ -920,27 +920,28 @@ // P2_MetaHandler::ForceChildElement // ================================= -XML_Node * P2_MetaHandler::ForceChildElement ( XML_Node * parent, XMP_StringPtr localName, XMP_Int32 indent , XMP_Bool insertAtFront ) +XML_Node * P2_MetaHandler::ForceChildElement ( XML_Node * parent_, XMP_StringPtr localName, XMP_Int32 indent , XMP_Bool insertAtFront ) { XML_Node * wsNodeBefore, * wsNodeAfter; + wsNodeBefore = wsNodeAfter = NULL; P2_Clip* p2Clip = this->p2ClipManager.GetManagedClip() ; XMP_StringPtr p2NS = p2Clip->GetP2RootNode()->ns.c_str(); - XML_Node * childNode = parent->GetNamedElement ( p2NS, localName ); + XML_Node * childNode = parent_->GetNamedElement ( p2NS, localName ); // if ( childNode == 0 ) { // The indenting is a hack, assuming existing 2 spaces per level. try { - wsNodeBefore = new XML_Node ( parent, "", kCDataNode ); + wsNodeBefore = new XML_Node ( parent_, "", kCDataNode ); wsNodeBefore->value = " "; // Add 2 spaces to the existing WS before the parent's close tag. - childNode = new XML_Node ( parent, localName, kElemNode ); - childNode->ns = parent->ns; - childNode->nsPrefixLen = parent->nsPrefixLen; - childNode->name.insert ( 0, parent->name, 0, parent->nsPrefixLen ); + childNode = new XML_Node ( parent_, localName, kElemNode ); + childNode->ns = parent_->ns; + childNode->nsPrefixLen = parent_->nsPrefixLen; + childNode->name.insert ( 0, parent_->name, 0, parent_->nsPrefixLen ); - wsNodeAfter = new XML_Node ( parent, "", kCDataNode ); + wsNodeAfter = new XML_Node ( parent_, "", kCDataNode ); } catch (...) { if (wsNodeBefore) delete wsNodeBefore; @@ -964,12 +965,12 @@ indentedNode.push_back(wsNodeAfter); indentedNode.push_back(wsNodeBefore); indentedNode.push_back(childNode); - parent->content.insert(parent->content.begin(), indentedNode.begin(), indentedNode.end()); + parent_->content.insert(parent_->content.begin(), indentedNode.begin(), indentedNode.end()); } else{ - parent->content.push_back(wsNodeBefore); - parent->content.push_back(childNode); - parent->content.push_back(wsNodeAfter); + parent_->content.push_back(wsNodeBefore); + parent_->content.push_back(childNode); + parent_->content.push_back(wsNodeAfter); } } @@ -1027,9 +1028,9 @@ std::vector clipNameList; p2SpanClip->GetAllClipNames ( clipNameList ); std::vector::iterator iter = clipNameList.begin(); - for(; iter!=clipNameList.end(); iter++) + XMP_StringVector regExpStringVecAudio, regExpStringVecVoice; + for (; iter != clipNameList.end(); iter++) { - std::string clipPathNoExt = contentsPath + "CLIP" + kDirChar + *iter; // Get the files present inside CLIP folder. path = clipPathNoExt + ".XML"; @@ -1041,20 +1042,21 @@ path = contentsPath + "VIDEO" + kDirChar + *iter + ".MXF"; PackageFormat_Support::AddResourceIfExists(resourceList, path); - // Get the files present inside AUDIO folder. + // Gather Regex exp for Audio resources of all spanned clip. path = contentsPath + "AUDIO" + kDirChar; XMP_VarString regExp; regExp = "^" + *iter + "\\d\\d.MXF$"; - IOUtils::GetMatchingChildren ( *resourceList, path, regExp, false, true, true ); + regExpStringVecAudio.push_back(regExp); // Get the files present inside ICON folder. path = contentsPath + "ICON" + kDirChar + *iter + ".BMP"; PackageFormat_Support::AddResourceIfExists(resourceList, path); - // Get the files present inside VOICE folder. + // Gather Regex exp for Audio resources of all spanned clip. path = contentsPath + "VOICE" + kDirChar; regExp = "^" + *iter + "\\d\\d.WAV$"; - IOUtils::GetMatchingChildren ( *resourceList, path, regExp, false, true, true ); + //IOUtils::GetMatchingChildren ( *resourceList, path, regExp, false, true, true ); + regExpStringVecVoice.push_back(regExp);; // Get the files present inside PROXY folder. std::string proxyPathNoExt = contentsPath + "PROXY" + kDirChar + *iter; @@ -1064,6 +1066,11 @@ path = proxyPathNoExt + ".BIN"; PackageFormat_Support::AddResourceIfExists(resourceList, path); } + // Get the files present inside AUDIO folder. + IOUtils::GetMatchingChildren(*resourceList, contentsPath + "AUDIO" + kDirChar, regExpStringVecAudio, false, true, true); + // Get the files present inside VOICE folder. + IOUtils::GetMatchingChildren(*resourceList, contentsPath + "VOICE" + kDirChar, regExpStringVecVoice, false, true, true); + } // P2_MetaHandler::FillAssociatedResources // ================================================================================================= @@ -1129,6 +1136,7 @@ XML_NodePtr legacyContext, clipMetadata, legacyProp; if ( ! this->p2ClipManager.IsValidP2() ) return; P2_Clip* p2Clip=this->p2ClipManager.GetManagedClip(); + if( p2Clip->GetP2RootNode() == 0) return; XMP_StringPtr p2NS = p2Clip->GetP2RootNode()->ns.c_str(); std::string oldDigest, newDigest; bool digestFound = this->xmpObj.GetStructField ( kXMP_NS_XMP, "NativeDigests", kXMP_NS_XMP, "P2", &oldDigest, 0 ); @@ -1299,24 +1307,27 @@ if (frameFormat == "50Timecode" || frameFormat == "5994DropTimecode" || frameFormat == "5994NonDropTimecode") { p2Clip = this->p2ClipManager.GetManagedClip(); - XMP_StringPtr p2NS = p2Clip->GetP2RootNode()->ns.c_str(); - XML_NodePtr legacyVideoContext = p2Clip->GetEssenceListNode(); - if (legacyVideoContext != 0) + if( p2Clip->GetP2RootNode() != 0 ) { - legacyVideoContext = legacyVideoContext->GetNamedElement(p2NS, "Video"); - XML_NodePtr legacyProp = legacyVideoContext->GetNamedElement(p2NS, "StartTimecode"); - if ((legacyProp != 0) && legacyProp->IsLeafContentNode()) - { - AdjustTimeCode( xmpStartTimeCode, true ); - if (xmpStartTimeCode != legacyProp->GetLeafContentValue()) - { - legacyProp->SetLeafContentValue(xmpStartTimeCode.c_str()); - updateLegacyXML = true; - } - } - } - } - } + XMP_StringPtr p2NS = p2Clip->GetP2RootNode()->ns.c_str(); + XML_NodePtr legacyVideoContext = p2Clip->GetEssenceListNode(); + if (legacyVideoContext != 0) + { + legacyVideoContext = legacyVideoContext->GetNamedElement(p2NS, "Video"); + XML_NodePtr legacyProp = legacyVideoContext->GetNamedElement(p2NS, "StartTimecode"); + if ((legacyProp != 0) && legacyProp->IsLeafContentNode()) + { + AdjustTimeCode( xmpStartTimeCode, true ); + if (xmpStartTimeCode != legacyProp->GetLeafContentValue()) + { + legacyProp->SetLeafContentValue(xmpStartTimeCode.c_str()); + updateLegacyXML = true; + } + } + } + } + } + } std::string newDigest; this->p2ClipManager.GetManagedClip()->CreateDigest ( &newDigest ); diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/P2_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/P2_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/P2_Handler.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/P2_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __P2_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2007 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2007 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/PNG_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/PNG_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/PNG_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/PNG_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -84,34 +84,30 @@ void PNG_MetaHandler::CacheFileData() { - this->containsXMP = false; XMP_IO* fileRef ( this->parent->ioRef ); if ( fileRef == 0) return; - PNG_Support::ChunkState chunkState; - long numChunks = PNG_Support::OpenPNG ( fileRef, chunkState ); - if ( numChunks == 0 ) return; - - if (chunkState.xmpLen != 0) - { - // XMP present - - this->xmpPacket.reserve(chunkState.xmpLen); - this->xmpPacket.assign(chunkState.xmpLen, ' '); - - if (PNG_Support::ReadBuffer ( fileRef, chunkState.xmpPos, chunkState.xmpLen, const_cast(this->xmpPacket.data()) )) - { - this->packetInfo.offset = chunkState.xmpPos; - this->packetInfo.length = chunkState.xmpLen; - this->containsXMP = true; - } - } - else - { - // no XMP - } + /* + CacheFileData is not using OpenPNG API to find the XMP packet because OpenPNG required + multiple file read calls which is very expensive in case of file present on n/w. + see bug [CTECHXMP-4169872]. + + if PNG is opened with kXMPFiles_OpenForRead, it will not read chunks after IEND chunk + encounters but if it opened with kXMPFiles_OpenForUpdate, then it will throw exception if + garbage data present after IEND chunk. + see bug [CTAIDS-4119487] + */ + if(PNG_Support::FindAndReadXMPChunk ( fileRef, this->xmpPacket, this->packetInfo.offset, XMP_OptionIsSet(this->parent->openFlags, kXMPFiles_OpenForRead))) + { + this->packetInfo.length = static_cast(this->xmpPacket.size()); + this->containsXMP = true; + } + else + { + // no XMP + } } // PNG_MetaHandler::CacheFileData @@ -214,7 +210,9 @@ continue; // copy any other chunk - PNG_Support::CopyChunk(originalRef, tempRef, chunk); + bool ret = PNG_Support::CopyChunk(originalRef, tempRef, chunk); + if(!ret) + XMP_Throw("PNG chunk copy failed.", kXMPErr_InternalFailure); // place XMP chunk immediately after IHDR-chunk if (PNG_Support::CheckIHDRChunkHeader(chunk)) diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/PNG_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/PNG_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/PNG_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/PNG_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __PNG_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/PostScript_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/PostScript_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/PostScript_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/PostScript_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2004 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2004 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -232,7 +232,7 @@ XMP_IO* fileRef = this->parent->ioRef; XMP_Int64 fileLen = fileRef->Length(); - XMP_PacketInfo & packetInfo = this->packetInfo; + XMP_PacketInfo & packetInfo_ = this->packetInfo; XMPScanner scanner ( fileLen ); XMPScanner::SnipInfoVector snips; @@ -263,7 +263,7 @@ if ( bufLen == 0 ) return firstfound; // Must be at EoF, no packets found. scanner.Scan ( buffer, bufPos, bufLen ); - snipCount = scanner.GetSnipCount(); + snipCount = (int)scanner.GetSnipCount(); scanner.Report ( snips ); for ( int i = 0; i < snipCount; ++i ) { @@ -272,12 +272,12 @@ if (!firstfound) { if ( snips[i].fLength > 0x7FFFFFFF ) XMP_Throw ( "PostScript_MetaHandler::FindFirstPacket: Oversize packet", kXMPErr_BadXMP ); - packetInfo.offset = snips[i].fOffset; - packetInfo.length = (XMP_Int32)snips[i].fLength; - packetInfo.charForm = snips[i].fCharForm; - packetInfo.writeable = (snips[i].fAccess == 'w'); - firstPacketInfo=packetInfo; - lastPacketInfo=packetInfo; + packetInfo_.offset = snips[i].fOffset; + packetInfo_.length = (XMP_Int32)snips[i].fLength; + packetInfo_.charForm = snips[i].fCharForm; + packetInfo_.writeable = (snips[i].fAccess == 'w'); + firstPacketInfo=packetInfo_; + lastPacketInfo=packetInfo_; firstfound=true; } else @@ -311,7 +311,7 @@ XMP_IO* fileRef = this->parent->ioRef; XMP_Int64 fileLen = fileRef->Length(); - XMP_PacketInfo & packetInfo = this->packetInfo; + XMP_PacketInfo & packetInfo_ = this->packetInfo; // ------------------------------------------------------ // Scan the entire file to find all of the valid packets. @@ -341,7 +341,7 @@ // ------------------------------- // Pick the last the valid packet. - int snipCount = scanner.GetSnipCount(); + int snipCount = (int)scanner.GetSnipCount(); XMPScanner::SnipInfoVector snips ( snipCount ); scanner.Report ( snips ); @@ -354,12 +354,12 @@ if (!lastfound) { if ( snips[i].fLength > 0x7FFFFFFF ) XMP_Throw ( "PostScript_MetaHandler::FindLastPacket: Oversize packet", kXMPErr_BadXMP ); - packetInfo.offset = snips[i].fOffset; - packetInfo.length = (XMP_Int32)snips[i].fLength; - packetInfo.charForm = snips[i].fCharForm; - packetInfo.writeable = (snips[i].fAccess == 'w'); - firstPacketInfo=packetInfo; - lastPacketInfo=packetInfo; + packetInfo_.offset = snips[i].fOffset; + packetInfo_.length = (XMP_Int32)snips[i].fLength; + packetInfo_.charForm = snips[i].fCharForm; + packetInfo_.writeable = (snips[i].fAccess == 'w'); + firstPacketInfo=packetInfo_; + lastPacketInfo=packetInfo_; lastfound=true; } else @@ -368,7 +368,7 @@ lastPacketInfo.length = (XMP_Int32)snips[i].fLength; lastPacketInfo.charForm = snips[i].fCharForm; lastPacketInfo.writeable = (snips[i].fAccess == 'w'); - packetInfo=lastPacketInfo; + packetInfo_=lastPacketInfo; } } } @@ -962,15 +962,15 @@ // ===================================== // // Helper method read the raw xmp into a string from a file -void PostScript_MetaHandler::ReadXMPPacket (std::string & xmpPacket ) +void PostScript_MetaHandler::ReadXMPPacket (std::string & xmpPacket_ ) { if ( packetInfo.length == 0 ) XMP_Throw ( "ReadXMPPacket - No XMP packet", kXMPErr_BadXMP ); - xmpPacket.erase(); - xmpPacket.reserve ( packetInfo.length ); - xmpPacket.append ( packetInfo.length, ' ' ); + xmpPacket_.erase(); + xmpPacket_.reserve ( packetInfo.length ); + xmpPacket_.append ( packetInfo.length, ' ' ); - XMP_StringPtr packetStr = XMP_StringPtr ( xmpPacket.c_str() ); // Don't set until after reserving the space! + XMP_StringPtr packetStr = XMP_StringPtr ( xmpPacket_.c_str() ); // Don't set until after reserving the space! this->parent->ioRef->Seek ( packetInfo.offset, kXMP_SeekFromStart ); this->parent->ioRef->ReadAll ( (char*)packetStr, packetInfo.length ); @@ -1082,7 +1082,7 @@ void PostScript_MetaHandler::ReconcileXMP( const std::string &xmpStr, std::string *outStr ) { SXMPMeta xmp; - xmp.ParseFromBuffer( xmpStr.c_str(), xmpStr.length() ); + xmp.ParseFromBuffer( xmpStr.c_str(), (XMP_Uns32)xmpStr.length() ); // Adding creator Toll if any if (!xmp.DoesPropertyExist ( kXMP_NS_XMP,"CreatorTool" )) { @@ -1259,7 +1259,7 @@ XMP_Uns32 psLength = GetUns32LE ( temp.ptr+8 ); // PostScript length. if (psLength>0) { - psLength+=extrabytes; + psLength+=(XMP_Uns32)extrabytes; PutUns32LE ( psLength, buffLE); fileRef->Seek ( 8, kXMP_SeekFromStart ); fileRef->Write(buffLE,4); @@ -1267,7 +1267,7 @@ XMP_Uns32 wmfOffset = GetUns32LE ( temp.ptr+12 ); // WMF offset. if (wmfOffset>0 && wmfOffset>offset) { - wmfOffset+=extrabytes; + wmfOffset+=(XMP_Uns32)extrabytes; PutUns32LE ( wmfOffset, buffLE); fileRef->Seek ( 12, kXMP_SeekFromStart ); fileRef->Write(buffLE,4); @@ -1276,7 +1276,7 @@ XMP_Uns32 tiffOffset = GetUns32LE ( temp.ptr+20 ); // Tiff offset. if (tiffOffset>0 && tiffOffset>offset) { - tiffOffset+=extrabytes; + tiffOffset+=(XMP_Uns32)extrabytes; PutUns32LE ( tiffOffset, buffLE); fileRef->Seek ( 20, kXMP_SeekFromStart ); fileRef->Write(buffLE,4); @@ -1306,16 +1306,16 @@ UpdateMethod PostScript_MetaHandler::DetermineUpdateMethod(std::string & outStr) { SXMPMeta xmp; - std::string & xmpPacket = this->xmpPacket; - XMP_PacketInfo & packetInfo = this->packetInfo; - xmp.ParseFromBuffer( xmpPacket.c_str(), xmpPacket.length() ); - if (packetInfo.length>0) + std::string & xmpPacket_ = this->xmpPacket; + XMP_PacketInfo & packetInfo_ = this->packetInfo; + xmp.ParseFromBuffer( xmpPacket_.c_str(), (XMP_Uns32)xmpPacket_.length() ); + if (packetInfo_.length>0) { try { //First try to fit the modified XMP data into existing XMP packet length //prefers Inplace - xmp.SerializeToBuffer( &outStr, kXMP_ExactPacketLength|kXMP_UseCompactFormat,packetInfo.length); + xmp.SerializeToBuffer( &outStr, kXMP_ExactPacketLength|kXMP_UseCompactFormat,packetInfo_.length); } catch(...) { @@ -1328,11 +1328,11 @@ // this will be the case for Injecting new metadata xmp.SerializeToBuffer( &outStr, kXMP_UseCompactFormat,0); } - if ( this->containsXMPHint && (outStr.size() == (size_t)packetInfo.length) ) + if ( this->containsXMPHint && (outStr.size() == (size_t)packetInfo_.length) ) { return kPS_Inplace; } - else if (this->containsXMPHint && PostScript_Support::IsSFDFilterUsed(this->parent->ioRef,packetInfo.offset)) + else if (this->containsXMPHint && PostScript_Support::IsSFDFilterUsed(this->parent->ioRef,packetInfo_.offset)) { return kPS_ExpandSFDFilter; } @@ -1392,7 +1392,7 @@ XMP_IO* fileRef = this->parent->ioRef; XMP_Int64 pos = 0; - XMP_Int32 extrapacketlength=outStr.length()-packetInfo.length; + XMP_Int64 extrapacketlength=outStr.length()-packetInfo.length; XMP_ProgressTracker* progressTracker = this->parent->progressTracker; if ( progressTracker != 0 ) progressTracker->AddTotalWork ((float) (extrapacketlength + fileRef->Length() -packetInfo.offset+14) ); if (!doSafeUpdate) @@ -1424,7 +1424,7 @@ readpoint+=temp.len; } fileRef->Seek ( writepoint, kXMP_SeekFromStart ); - fileRef->Write(tempfilebuffer1[y].data,tempfilebuffer1[y].len); + fileRef->Write(tempfilebuffer1[y].data,(XMP_Uns32)tempfilebuffer1[y].len); writepoint+=tempfilebuffer1[y].len; if (continueread) tempfilebuffer1[y]=temp; @@ -1685,12 +1685,12 @@ if (fileformat==kXMP_EPSFile || kXMPFiles_UnknownLength==packetInfo.offset) { if ( progressTracker != 0 ) progressTracker->AddTotalWork ((float) ( kPS_XMPHintMainFirst.length()) ); - tempRef->Write(kPS_XMPHintMainFirst.c_str(),kPS_XMPHintMainFirst.length()); + tempRef->Write(kPS_XMPHintMainFirst.c_str(),(XMP_Uns32)kPS_XMPHintMainFirst.length()); } else { if ( progressTracker != 0 ) progressTracker->AddTotalWork ((float) ( kPS_XMPHintMainLast.length()) ); - tempRef->Write(kPS_XMPHintMainLast.c_str(),kPS_XMPHintMainLast.length()); + tempRef->Write(kPS_XMPHintMainLast.c_str(),(XMP_Uns32)kPS_XMPHintMainLast.length()); } } InjectData1Offset-=totalReadLength; @@ -1698,15 +1698,15 @@ totalReadLength+=InjectData1Offset; if (fileformat==kXMP_EPSFile) { - tempRef->Write(kEPS_Injectdata1.c_str(),kEPS_Injectdata1.length()); + tempRef->Write(kEPS_Injectdata1.c_str(),(XMP_Uns32)kEPS_Injectdata1.length()); tempRef->Write((void *)outStr.c_str(), static_cast(outStr.length())); - tempRef->Write(kEPS_Injectdata2.c_str(),kEPS_Injectdata2.length()); + tempRef->Write(kEPS_Injectdata2.c_str(),(XMP_Uns32)kEPS_Injectdata2.length()); } else { - tempRef->Write(kPS_Injectdata1.c_str(),kPS_Injectdata1.length()); + tempRef->Write(kPS_Injectdata1.c_str(),(XMP_Uns32)kPS_Injectdata1.length()); tempRef->Write((void *)outStr.c_str(), static_cast(outStr.length())); - tempRef->Write(kPS_Injectdata2.c_str(),kPS_Injectdata2.length()); + tempRef->Write(kPS_Injectdata2.c_str(),(XMP_Uns32)kPS_Injectdata2.length()); } if (InjectData3Offset!=-1) { @@ -1715,7 +1715,7 @@ totalReadLength+=InjectData3Offset; if (fileformat==kXMP_EPSFile) { - tempRef->Write(kEPS_Injectdata3.c_str(),kEPS_Injectdata3.length()); + tempRef->Write(kEPS_Injectdata3.c_str(),(XMP_Uns32)kEPS_Injectdata3.length()); } XMP_Int64 remlength=fileRef->Length()-totalReadLength; XIO::Copy(fileRef,tempRef,remlength,this->parent->abortProc,this->parent->abortArg); @@ -1728,7 +1728,7 @@ totalReadLength+=remlength; if (fileformat==kXMP_EPSFile) { - tempRef->Write(kEPS_Injectdata3.c_str(),kEPS_Injectdata3.length()); + tempRef->Write(kEPS_Injectdata3.c_str(),(XMP_Uns32)kEPS_Injectdata3.length()); } } XMP_Int64 extraBytes; diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/PostScript_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/PostScript_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/PostScript_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/PostScript_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __PostScript_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2004 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2004 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/PSD_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/PSD_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/PSD_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/PSD_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. @@ -140,7 +140,13 @@ cmLen = GetUns32BE ( &psdHeader[26] ); - XMP_Int64 psirOrigin = 26 + 4 + cmLen; + XMP_Int64 psirOrigin = 26 + 4 + static_cast(cmLen); + XMP_Int64 fileLength = fileRef->Length(); + + if (psirOrigin > fileLength) + { + XMP_Throw("Invalid PSD chunk length", kXMPErr_BadPSD); + } filePos = fileRef->Seek ( psirOrigin, kXMP_SeekFromStart ); if ( filePos != psirOrigin ) return; // Throw? @@ -151,7 +157,9 @@ this->psirMgr.ParseFileResources ( fileRef, psirLen ); PSIR_Manager::ImgRsrcInfo xmpInfo; - bool found = this->psirMgr.GetImgRsrc ( kPSIR_XMP, &xmpInfo ); + bool found = this->psirMgr.GetImgRsrc(kPSIR_XMP, &xmpInfo); + if (psirLen < xmpInfo.dataLen) + return; if ( found ) { @@ -262,6 +270,7 @@ void PSD_MetaHandler::UpdateFile ( bool doSafeUpdate ) { + (void)doSafeUpdate; // UNUSED beside assert -- Hub XMP_Assert ( ! doSafeUpdate ); // This should only be called for "unsafe" updates. XMP_Int64 oldPacketOffset = this->packetInfo.offset; @@ -310,7 +319,7 @@ XMP_Assert ( this->xmpPacket.size() == (size_t)oldPacketLength ); // ! Done by common PutXMP logic. - if ( progressTracker != 0 ) progressTracker->BeginWork ( this->xmpPacket.size() ); + if ( progressTracker != 0 ) progressTracker->BeginWork ( ((float)(this->xmpPacket.size())) ); liveFile->Seek ( oldPacketOffset, kXMP_SeekFromStart ); liveFile->Write ( this->xmpPacket.c_str(), (XMP_StringLen)this->xmpPacket.size() ); if ( progressTracker != 0 ) progressTracker->WorkComplete(); diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/PSD_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/PSD_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/PSD_Handler.hpp 2016-12-07 05:07:54.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/PSD_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __PSD_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "XMPFiles/source/FormatSupport/TIFF_Support.hpp" diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/RIFF_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/RIFF_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/RIFF_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/RIFF_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2009 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2009 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -181,7 +181,7 @@ // RIFF_MetaHandler::UpdateFile // =========================== -void RIFF_MetaHandler::UpdateFile ( bool doSafeUpdate ) +void RIFF_MetaHandler::UpdateFile ( bool /*doSafeUpdate*/ ) { XMP_Validate( this->needsUpdate, "nothing to update", kXMPErr_InternalFailure ); @@ -297,9 +297,9 @@ file->Rewind(); } - RIFF::Chunk* mainChunk = rc->at(0); + RIFF::Chunk* mainChunkPtr = rc->at(0); - XMP_Int64 mainGrowth = mainChunk->newSize - mainChunk->oldSize; + XMP_Int64 mainGrowth = mainChunkPtr->newSize - mainChunkPtr->oldSize; XMP_Enforce( mainGrowth >= 0 ); // main always stays or grows //temptemp diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/RIFF_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/RIFF_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/RIFF_Handler.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/RIFF_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2009 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2009 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef __RIFF_Handler_hpp__ #define __RIFF_Handler_hpp__ 1 diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/Scanner_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/Scanner_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/Scanner_Handler.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/Scanner_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2004 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2004 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -282,15 +282,15 @@ if ( snips[pkt].fState != XMPScanner::eValidPacketSnip ) continue; fileRef->Seek ( snips[pkt].fOffset, kXMP_SeekFromStart ); newMeta = new SXMPMeta(); - std::string xmpPacket; - xmpPacket.reserve ( (size_t)snips[pkt].fLength ); + std::string xmpPacket_; + xmpPacket_.reserve ( (size_t)snips[pkt].fLength ); try { for ( bufPos = 0; bufPos < snips[pkt].fLength; bufPos += bufLen ) { bufLen = kBufferSize; if ( (bufPos + bufLen) > (size_t)snips[pkt].fLength ) bufLen = size_t ( snips[pkt].fLength - bufPos ); (void) fileRef->ReadAll ( buffer, (XMP_Int32)bufLen ); - xmpPacket.append ( (const char *)buffer, bufLen ); + xmpPacket_.append ( (const char *)buffer, bufLen ); newMeta->ParseFromBuffer ( (char *)buffer, (XMP_StringLen)bufLen, kXMP_ParseMoreBuffers ); } newMeta->ParseFromBuffer ( 0, 0, kXMP_NoOptions ); @@ -305,7 +305,7 @@ candidates.push_back ( CandidateInfo() ); CandidateInfo & newInfo = candidates.back(); newInfo.xmpObj = newMeta; - newInfo.xmpPacket.swap ( xmpPacket ); + newInfo.xmpPacket.swap ( xmpPacket_ ); newInfo.packetInfo.offset = snips[pkt].fOffset; newInfo.packetInfo.length = (XMP_Int32)snips[pkt].fLength; newInfo.packetInfo.charForm = snips[pkt].fCharForm; diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/Scanner_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/Scanner_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/Scanner_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/Scanner_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __Scanner_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2004 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2004 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "XMPFiles/source/FileHandlers/Trivial_Handler.hpp" diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/SonyHDV_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/SonyHDV_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/SonyHDV_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/SonyHDV_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2007 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2007 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -604,10 +604,10 @@ // SonyHDV_MetaHandler::MakeIndexFilePath // ====================================== -bool SonyHDV_MetaHandler::MakeIndexFilePath ( std::string& idxPath, const std::string& rootPath_, const std::string& leafName ) +bool SonyHDV_MetaHandler::MakeIndexFilePath ( std::string& idxPath, const std::string& _rootPath, const std::string& leafName ) { std::string tempPath; - tempPath = rootPath_; + tempPath = _rootPath; tempPath += kDirChar; tempPath += "VIDEO"; tempPath += kDirChar; @@ -626,8 +626,8 @@ // Scanning code taken from SonyHDV_CheckFormat // Can be isolated to a separate function. - std::string clipName_ = leafName; - RemoveTimeStampFromClipName(clipName_); + std::string clipNameStr = leafName; + RemoveTimeStampFromClipName(clipNameStr); Host_IO::AutoFolder aFolder; std::string childName; @@ -639,10 +639,10 @@ if ( childLen < 4 ) continue; MakeUpperCase ( &childName ); if ( childName.compare ( childLen-4, 4, ".IDX" ) != 0 ) continue; - if ( childName.compare ( 0, clipName_.size(), clipName_ ) == 0 ) { + if ( childName.compare ( 0, clipNameStr.size(), clipNameStr ) == 0 ) { found = true; - clipName_ = childName; - clipName_.erase ( childLen-4 ); + clipNameStr = childName; + clipNameStr.erase ( childLen-4 ); } } aFolder.Close(); @@ -650,7 +650,7 @@ idxPath = tempPath; idxPath += kDirChar; - idxPath += clipName_; + idxPath += clipNameStr; idxPath += ".IDX"; return true; diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/SonyHDV_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/SonyHDV_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/SonyHDV_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/SonyHDV_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __SonyHDV_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2007 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2007 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/SVG_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/SVG_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/SVG_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/SVG_Handler.cpp 2022-02-12 23:39:28.000000000 +0000 @@ -1,14 +1,14 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2015 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2015 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // // This file includes implementation of SVG metadata, according to Scalable Vector Graphics (SVG) 1.1 Specification. // "https://www.w3.org/TR/2003/REC-SVG11-20030114/" -// Copyright © 1994-2002 World Wide Web Consortium, (Massachusetts Institute of Technology, +// Copyright © 1994-2002 World Wide Web Consortium, (Massachusetts Institute of Technology, // Institut National de Recherche en Informatique et en Automatique, Keio University). // All Rights Reserved . http://www.w3.org/Consortium/Legal // @@ -32,6 +32,328 @@ */ // ================================================================================================= +// AppendData +// =============== + +static inline void AppendData(RawDataBlock * dataOut, XMP_Uns8 * buffer, size_t count) { + + size_t prevSize = dataOut->size(); // ! Don't save a pointer, there might be a reallocation. + dataOut->insert(dataOut->end(), count, 0); // Add space to the RawDataBlock. + memcpy(&( ( *dataOut ) [prevSize] ), buffer, count); + +} // AppendData + +// ================================================================================================= +// ReplaceData +// =============== + +static inline void ReplaceData(RawDataBlock * dataOut, size_t pos, size_t deleteCount, const XMP_Uns8 * buffer, size_t count) { + + RawDataBlock::iterator iter = dataOut->begin() + pos; + iter = dataOut->erase(iter, iter + deleteCount); + dataOut->insert(iter, count, 0); + memcpy(&( ( *dataOut ) [pos] ), buffer, count); + +} // ReplaceData + +// ================================================================================================= +//DecompressBuffer +// ============================== +// This function will decompress the buffer contents +static XMP_Uns64 DecompressBuffer(XMP_Uns8 * buffer, const XMP_Uns32 ioCount, RawDataBlock * dataOut) +{ + // Provided buffer is of size 1024 and contains compressed bytes, therefore buffer size is doubled + // do that decompressing can be done in single step. + + const size_t bufferSize = 2 * 1024; + XMP_Uns8 bufferOut [bufferSize]; + + z_stream zipState; + memset(&zipState, 0, sizeof(zipState)); + + // To decompress a gzip format file use windowBits as 16 + MAX_WBITS with inflateInit2 + int err = inflateInit2(&zipState, 16 + MAX_WBITS); + if(err != Z_OK) + return 0; + + // Initial input and output conditions. + zipState.next_out = &bufferOut [0]; + zipState.avail_out = bufferSize; + zipState.next_in = &buffer [0]; + zipState.avail_in = ioCount; + + // Process all of this input, writing as needed. + while(zipState.avail_in > 0) + { + XMP_Assert(zipState.avail_out > 0); // Sanity check for output buffer space. pppp + + err = inflate(&zipState, Z_NO_FLUSH); + if(err != Z_OK && err != Z_STREAM_END) + return 0; + if(zipState.avail_out == 0) { + AppendData(dataOut, bufferOut, bufferSize); + zipState.next_out = &bufferOut [0]; + zipState.avail_out = bufferSize; + } + } + + // Write the final output if any remaining. + XMP_Uns32 remainingSize = bufferSize - zipState.avail_out; + if(remainingSize > 0) + { + AppendData(dataOut, bufferOut, remainingSize); + zipState.next_out = &bufferOut [0]; + zipState.avail_out = bufferSize; + } + + // Finish the decompression + inflateEnd(&zipState); + return zipState.total_out; +} // DecompressBuffer + +// ================================================================================================= +// SVG_MetaHandler::DecompressFileToMemory +// ============================== +// This function will decompress gzip contents of a file into a buffer +XMP_Int64 SVG_MetaHandler::DecompressFileToMemory(XMP_IO * fileIn, RawDataBlock * dataOut) +{ + fileIn->Rewind(); + dataOut->clear(); + + // Buffer size of 64K is efficient for faster compression and decompression + static const size_t bufferSize = 64 * 1024; + XMP_Uns8 bufferIn [bufferSize]; + XMP_Uns8 bufferOut [bufferSize]; + + int err; + z_stream zipState; + memset(&zipState, 0, sizeof(zipState)); + + // To decompress a gzip format file use windowBits as 16 + MAX_WBITS with inflateInit2 + err = inflateInit2(&zipState, 16 + MAX_WBITS); + + // Any information contained in the gzip header is not retained unless inflateGetHeader() is used. + // Saving header for writing back compressed file + inflateGetHeader(&zipState, &compressedHeader); + XMP_Enforce(err == Z_OK); + + XMP_Int32 ioCount; + XMP_Int64 offsetIn = 0; + const XMP_Int64 lengthIn = fileIn->Length(); + + // Initial output conditions. Must be set before the input loop! + zipState.next_out = &bufferOut [0]; + zipState.avail_out = bufferSize; + + while(offsetIn < lengthIn) { + + // Read the next chunk of input. + ioCount = fileIn->Read(bufferIn, bufferSize); + XMP_Enforce(ioCount > 0); + offsetIn += ioCount; + zipState.next_in = &bufferIn [0]; + zipState.avail_in = ioCount; + + // Process all of this input, writing as needed. + + err = Z_OK; + while(( zipState.avail_in > 0 ) && ( err == Z_OK )) { + + XMP_Assert(zipState.avail_out > 0); // Sanity check for output buffer space. + err = inflate(&zipState, Z_NO_FLUSH); + XMP_Enforce(( err == Z_OK ) || ( err == Z_STREAM_END )); + + if(zipState.avail_out == 0) { + AppendData(dataOut, bufferOut, bufferSize); + zipState.next_out = &bufferOut [0]; + zipState.avail_out = bufferSize; + } + } + } + + // Finish the decompression and write the final output. + + do { + + ioCount = bufferSize - zipState.avail_out; // Make sure there is room for inflate to do more. + if(ioCount > 0) { + AppendData(dataOut, bufferOut, ioCount); + zipState.next_out = &bufferOut [0]; + zipState.avail_out = bufferSize; + } + + err = inflate(&zipState, Z_NO_FLUSH); + XMP_Enforce(( err == Z_OK ) || ( err == Z_STREAM_END ) || ( err == Z_BUF_ERROR )); + + } while(err == Z_OK); + + ioCount = bufferSize - zipState.avail_out; // Write any final output. + if(ioCount > 0) { + AppendData(dataOut, bufferOut, ioCount); + zipState.next_out = &bufferOut [0]; + zipState.avail_out = bufferSize; + } + + // Done. Make sure the file header has the true decompressed size. + XMP_Int64 lengthOut = zipState.total_out; + inflateEnd(&zipState); + return lengthOut; + +} // SVG_MetaHandler::DecompressFileToMemory + +// ================================================================================================= +// SVG_MetaHandler::CompressMemoryToFile +// ============================== +// This function will compress gzip contents of a buffer into a file +XMP_Int64 SVG_MetaHandler::CompressMemoryToFile(const RawDataBlock & dataIn, XMP_IO * fileOut) +{ + fileOut->Rewind(); + fileOut->Truncate(0); + + // 64K buffer is ideal for faster compression + static const size_t bufferSize = 64 * 1024; + XMP_Uns8 bufferOut [bufferSize]; + + int err; + z_stream zipState; + memset(&zipState, 0, sizeof(zipState)); + err = deflateInit2(&zipState, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 16 + MAX_WBITS, 8, Z_DEFAULT_STRATEGY); + XMP_Enforce(err == Z_OK); + + // It provides gzip header information for when a gzip stream is requested by deflateInit2(). + // The gz_header structure are written to the gzip header which would have been saved during decompressing. + err = deflateSetHeader(&zipState, &compressedHeader); + XMP_Enforce(err == Z_OK); + + XMP_Int32 ioCount; + const size_t lengthIn = dataIn.size(); + + // Feed the input to the compression engine in one step, write the output as available. + + zipState.next_in = (Bytef*) &dataIn [0]; + zipState.avail_in = static_cast(lengthIn); + zipState.next_out = &bufferOut [0]; + zipState.avail_out = bufferSize; + + while(zipState.avail_in > 0) { + + XMP_Assert(zipState.avail_out > 0); // Sanity check for output buffer space. + err = deflate(&zipState, Z_NO_FLUSH); + XMP_Enforce(err == Z_OK); + + if(zipState.avail_out == 0) { + fileOut->Write(bufferOut, bufferSize); + zipState.next_out = &bufferOut [0]; + zipState.avail_out = bufferSize; + } + + } + + // Finish the compression and write the final output. + do { + + err = deflate(&zipState, Z_FINISH); + XMP_Enforce(( err == Z_OK ) || ( err == Z_STREAM_END )); + ioCount = bufferSize - zipState.avail_out; // See if there is output to write. + + if(ioCount > 0) { + fileOut->Write(bufferOut, ioCount); + zipState.next_out = &bufferOut [0]; + zipState.avail_out = bufferSize; + } + + } while(err != Z_STREAM_END); + + // Done. + XMP_Int64 lengthOut = zipState.total_out; + + deflateEnd(&zipState); + return lengthOut; +} // SVG_MetaHandler::CompressMemoryToFile + +// ================================================================================================= +// SVG_MetaHandler::CompressFileToFile +// ============================== +// This function will compress gzip contents of a file into another file +XMP_Int64 SVG_MetaHandler::CompressFileToFile(XMP_IO * fileIn, XMP_IO * fileOut) +{ + fileIn->Rewind(); + fileOut->Truncate(0); + + // 64K buffer is ideal for faster compression + static const size_t bufferSize = 64 * 1024; + XMP_Uns8 bufferIn [bufferSize]; + XMP_Uns8 bufferOut [bufferSize]; + + int err; + z_stream zipState; + memset(&zipState, 0, sizeof(zipState)); + err = deflateInit2(&zipState, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 16 + MAX_WBITS, 8, Z_DEFAULT_STRATEGY); + XMP_Enforce(err == Z_OK); + // Setting the header which would have been saved during decompressing + err = deflateSetHeader(&zipState, &compressedHeader); + XMP_Enforce(err == Z_OK); + + XMP_Int32 ioCount; + XMP_Int64 offsetIn = 0; + const XMP_Int64 lengthIn = fileIn->Length(); + + // Read the input file, feed it to the compression engine, writing as needed. + // Initial output conditions. Must be set before the input loop! + zipState.next_out = &bufferOut [0]; + zipState.avail_out = bufferSize; + + while(offsetIn < lengthIn) { + + // Read the next chunk of input. + ioCount = fileIn->Read(bufferIn, bufferSize); + XMP_Enforce(ioCount > 0); + offsetIn += ioCount; + zipState.next_in = &bufferIn [0]; + zipState.avail_in = ioCount; + + // Process all of this input, writing as needed. Yes, we need a loop. Compression means less + // output than input, but a previous read has probably left partial compression results. + + while(zipState.avail_in > 0) { + + XMP_Assert(zipState.avail_out > 0); // Sanity check for output buffer space. + err = deflate(&zipState, Z_NO_FLUSH); + XMP_Enforce(err == Z_OK); + + if(zipState.avail_out == 0) { + fileOut->Write(bufferOut, bufferSize); + zipState.next_out = &bufferOut [0]; + zipState.avail_out = bufferSize; + } + } + } + + // Finish the compression and write the final output. + + do { + + err = deflate(&zipState, Z_FINISH); + XMP_Enforce(( err == Z_OK ) || ( err == Z_STREAM_END )); + ioCount = bufferSize - zipState.avail_out; // See if there is output to write. + + if(ioCount > 0) { + fileOut->Write(bufferOut, ioCount); + zipState.next_out = &bufferOut [0]; + zipState.avail_out = bufferSize; + } + + } while(err != Z_STREAM_END); + + // Done. + + XMP_Int64 lengthOut = zipState.total_out; + deflateEnd(&zipState); + return lengthOut; +} // SVG_MetaHandler::CompressFileToFile + + +// ================================================================================================= // SVG_CheckFormat // =============== @@ -62,23 +384,43 @@ } // Initially we are intersted only in "svg" element. - SVG_Adapter * svgChecker = new SVG_Adapter(); + SVG_Adapter * svgChecker = new ( std::nothrow ) SVG_Adapter(); if ( svgChecker == 0 ) return false; + svgChecker->SetErrorCallback(&parent->errorCallback); + bool isSVG = false; + bool isCompressed = false; + + // Checking for compressed header of gzip i.e. ID1 = (0x1F) , ID2 = (0x8B) & CM = (0x08) + if(buffer [0] == 0x1f && buffer [1] == 0x8b && buffer [2] == 0x08) + isCompressed = true; fileRef->Rewind(); for ( XMP_Uns8 index = 0; index < 8; ++index ) { - XMP_Int32 ioCount = fileRef->Read( buffer, sizeof( buffer ) ); + XMP_Uns64 ioCount = fileRef->Read( buffer, sizeof( buffer ) ); if ( ioCount == 0 ) break; - // Checking for well formed XML - if ( !svgChecker->ParseBufferNoThrow( buffer, ioCount, false /* not the end */ ) ) - break; + // If compressed then first decompress 1024 bytes. + if(isCompressed) + { + RawDataBlock block; + ioCount = DecompressBuffer(buffer, static_cast(ioCount), &block); + if(ioCount == 0) + break; + if(!svgChecker->ParseBufferNoThrow(block.data(), ioCount, false /* not the end */)) + break; + } + else + { + // Checking for well formed XML + if(!svgChecker->ParseBufferNoThrow(buffer, ioCount, false /* not the end */)) + break; + } - if ( svgChecker->tree.GetNamedElement( "http://www.w3.org/2000/svg", "svg" ) ) + if ( svgChecker->tree.GetNamedElement( kURI_SVG , "svg" ) ) { isSVG = true; break; @@ -106,7 +448,7 @@ // SVG_MetaHandler::SVG_MetaHandler // ================================ -SVG_MetaHandler::SVG_MetaHandler( XMPFiles * _parent ) : svgAdapter( 0 ), svgNode( 0 ), isTitleUpdateReq( false ), isDescUpdateReq( false ) +SVG_MetaHandler::SVG_MetaHandler(XMPFiles * _parent) : svgAdapter(0), svgNode(0), isTitleUpdateReq(false), isDescUpdateReq(false), isCompressed(false), compressedHeader() { this->parent = _parent; this->handlerFlags = kSVG_HandlerFlags; @@ -163,12 +505,13 @@ } // Creating a new SVG Parser - svgAdapter = new SVG_Adapter(); + svgAdapter = new ( std::nothrow ) SVG_Adapter(); if ( svgAdapter == 0 ) XMP_Throw( "SVG_MetaHandler: Can't create SVG adapter", kXMPErr_NoMemory ); svgAdapter->SetErrorCallback( &this->parent->errorCallback ); // Registering all the required tags to SVG Parser + svgAdapter->RegisterElement("svg", ""); svgAdapter->RegisterPI( "xpacket" ); svgAdapter->RegisterElement( "metadata", "svg" ); svgAdapter->RegisterElement( "xmpmeta", "metadata" ); @@ -176,15 +519,41 @@ svgAdapter->RegisterElement( "title", "svg" ); svgAdapter->RegisterElement( "desc", "svg" ); - // Parsing the whole buffer - fileRef->Rewind(); - XMP_Uns8 buffer[ 64 * 1024 ]; - while ( true ) { - XMP_Int32 ioCount = fileRef->Read( buffer, sizeof( buffer ) ); - if ( ioCount == 0 || !svgAdapter->IsParsingRequire() ) break; - svgAdapter->ParseBuffer( buffer, ioCount, false /* not the end */ ); + + // Checking for compressed header of gzip i.e. ID1 = (0x1F) , ID2 = (0x8B) & CM = (0x08) + if(marker [0] == 0x1f && marker [1] == 0x8b && marker [2] == 0x08) { + + isCompressed = true; + + //Acc. to rfc1952 ISIZE (last 4 bytes) contains the size of the original(uncompressed) input data modulo 2 ^ 32. + const XMP_Int64 maxSize = 0xFFFFFFFFUL; + fileRef->Seek(-4, kXMP_SeekFromEnd); + fileRef->Read(marker, 4); + XMP_Uns32 expectedFullSize = GetUns32LE(marker); + XMP_Enforce(expectedFullSize <= maxSize); + + svgContents.reserve(expectedFullSize); // Try to avoid reallocations. + + fileRef->Rewind(); // Read the input file from start. + + // Filling svgContents with decompressed data + this->DecompressFileToMemory(fileRef, &svgContents); + + // Parsing the whole buffer + svgAdapter->ParseBuffer(this->svgContents.data(), this->svgContents.size(), true); // End the parse. + + } + else { + // Parsing the whole file + fileRef->Rewind(); + XMP_Uns8 buffer [64 * 1024]; + while(true) { + XMP_Int32 ioCount = fileRef->Read(buffer, sizeof(buffer)); + if(ioCount == 0 || !svgAdapter->IsParsingRequire()) break; + svgAdapter->ParseBuffer(buffer, ioCount, false /* not the end */); + } + svgAdapter->ParseBuffer(0, 0, true); // End the parse. } - svgAdapter->ParseBuffer( 0, 0, true ); // End the parse. XML_Node & xmlTree = this->svgAdapter->tree; XML_NodePtr rootElem = 0; @@ -229,7 +598,7 @@ { XMP_Int64 trailerOffset = svgAdapter->GetPIOffset( "xpacket", 2 ); XML_NodePtr trailerNode = metadataNode->GetNamedElement( "", "xpacket", 1 ); - if ( trailerOffset != -1 || trailerNode != 0 ) + if (trailerOffset != -1 && trailerNode != 0) { packetLength = 2; // "name.length(); // Node's name @@ -269,9 +638,14 @@ { this->packetInfo.offset = packetOffset; this->packetInfo.length = ( XMP_Int32 ) packetLength; - this->xmpPacket.assign( this->packetInfo.length, ' ' ); - fileRef->Seek( packetOffset, kXMP_SeekFromStart ); - fileRef->ReadAll( ( void* )this->xmpPacket.data(), this->packetInfo.length ); + this->xmpPacket.assign(this->packetInfo.length, ' '); + + if(isCompressed) + this->xmpPacket.assign((const char *) ( &this->svgContents.at(packetOffset) ), packetLength); + else { + fileRef->Seek(packetOffset, kXMP_SeekFromStart); + fileRef->ReadAll(( void* )this->xmpPacket.data(), this->packetInfo.length); + } FillPacketInfo( this->xmpPacket, &this->packetInfo ); this->containsXMP = true; return; @@ -324,19 +698,43 @@ // It is handling the updation and deletion case void SVG_MetaHandler::ProcessTitle( XMP_IO* sourceRef, XMP_IO * destRef, const std::string &value, XMP_Int64 ¤tOffset, const OffsetStruct & titleOffset ) { + //sourceRef will be NULL in case read from svgContents i.e compressed case if ( value.empty() ) { - XIO::Copy( sourceRef, destRef, titleOffset.startOffset - currentOffset ); - sourceRef->Seek( titleOffset.nextOffset, kXMP_SeekFromStart ); + if(sourceRef != NULL) { + XIO::Copy(sourceRef, destRef, titleOffset.startOffset - currentOffset); + sourceRef->Seek(titleOffset.nextOffset, kXMP_SeekFromStart); + } + else + destRef->Write(&( this->svgContents.data() [currentOffset] ), static_cast(titleOffset.startOffset - currentOffset)); + currentOffset = titleOffset.nextOffset; } else { - std::string titleElement = ""; - XIO::Copy( sourceRef, destRef, titleOffset.startOffset - currentOffset + titleElement.length() ); + char *tempStr = new char[titleOffset.endOffset - titleOffset.startOffset + 1]; + + tempStr [titleOffset.endOffset - titleOffset.startOffset] = '\0'; + + if(sourceRef != NULL) { + sourceRef->Seek(titleOffset.startOffset, kXMP_SeekFromStart); + sourceRef->Read(tempStr, static_cast(titleOffset.endOffset - titleOffset.startOffset)); + sourceRef->Seek(currentOffset, kXMP_SeekFromStart); + const char *pos = strchr(tempStr, '>'); + XIO::Copy(sourceRef, destRef, titleOffset.startOffset - currentOffset + ( pos - tempStr + 1 )); + sourceRef->Seek(titleOffset.endOffset, kXMP_SeekFromStart); + } + else{ + memcpy( tempStr, &( this->svgContents.data() [titleOffset.startOffset] ), titleOffset.endOffset - titleOffset.startOffset); + tempStr [titleOffset.endOffset - titleOffset.startOffset] = '\0'; + const char *pos = strchr(tempStr, '>'); + destRef->Write(&( this->svgContents.data() [currentOffset] ), static_cast(titleOffset.startOffset - currentOffset + ( pos - tempStr + 1 ))); + } + destRef->Write( value.c_str(), static_cast< int >( value.length() ) ); - sourceRef->Seek( titleOffset.endOffset, kXMP_SeekFromStart ); currentOffset = titleOffset.endOffset; + delete[] tempStr; + tempStr = NULL; } } // SVG_MetaHandler::ProcessTitle @@ -348,17 +746,34 @@ { if ( value.empty() ) { - XIO::Copy( sourceRef, destRef, descOffset.startOffset - currentOffset ); - sourceRef->Seek( descOffset.nextOffset, kXMP_SeekFromStart ); + if(sourceRef != NULL) { + XIO::Copy(sourceRef, destRef, descOffset.startOffset - currentOffset); + sourceRef->Seek(descOffset.nextOffset, kXMP_SeekFromStart); + } currentOffset = descOffset.nextOffset; } else { - std::string descElement = ""; - XIO::Copy( sourceRef, destRef, descOffset.startOffset - currentOffset + descElement.length() ); + char *tempStr = new char[descOffset.endOffset - descOffset.startOffset + 1]; + + tempStr [descOffset.endOffset - descOffset.startOffset] = '\0'; + if(sourceRef != NULL) { + sourceRef->Seek(descOffset.startOffset, kXMP_SeekFromStart); + sourceRef->Read(tempStr, static_cast(descOffset.endOffset - descOffset.startOffset)); + sourceRef->Seek(currentOffset, kXMP_SeekFromStart); + const char *pos = strchr(tempStr, '>'); + XIO::Copy(sourceRef, destRef, descOffset.startOffset - currentOffset + ( pos - tempStr + 1 )); + sourceRef->Seek(descOffset.endOffset, kXMP_SeekFromStart); + } + else{ + memcpy( tempStr, &( this->svgContents.data() [descOffset.startOffset] ), descOffset.endOffset - descOffset.startOffset); + const char *pos = strchr(tempStr, '>'); + destRef->Write(&( this->svgContents.data() [currentOffset] ), static_cast(descOffset.startOffset - currentOffset + ( pos - tempStr + 1 ))); + } destRef->Write( value.c_str(), static_cast< int >( value.length() ) ); - sourceRef->Seek( descOffset.endOffset, kXMP_SeekFromStart ); currentOffset = descOffset.endOffset; + delete[] tempStr; + tempStr = NULL; } } // SVG_MetaHandler::ProcessDescription @@ -367,12 +782,12 @@ // SVG_MetaHandler::InsertNewTitle // =========================== // It is handling the insertion case -void SVG_MetaHandler::InsertNewTitle( XMP_IO * destRef, const std::string &value ) +void SVG_MetaHandler::InsertNewTitle( XMP_IO * destRef, const std::string &value, const std::string &prefix ) { - std::string titleElement = ""; + std::string titleElement = "<" + prefix + "title>"; destRef->Write( titleElement.c_str(), static_cast< int >( titleElement.length() ) ); destRef->Write( value.c_str(), static_cast< int >( value.length() ) ); - titleElement = "\n"; + titleElement = "\n"; destRef->Write( titleElement.c_str(), static_cast< int >( titleElement.length() ) ); } // SVG_MetaHandler::InsertNewTitle @@ -381,12 +796,12 @@ // SVG_MetaHandler::InsertNewDescription // =========================== // It is handling the insertion case -void SVG_MetaHandler::InsertNewDescription( XMP_IO * destRef, const std::string &value ) +void SVG_MetaHandler::InsertNewDescription( XMP_IO * destRef, const std::string &value, const std::string &prefix ) { - std::string descElement = ""; + std::string descElement = "<" + prefix + "desc>"; destRef->Write( descElement.c_str(), static_cast< int >( descElement.length() ) ); destRef->Write( value.c_str(), static_cast< int >( value.length() ) ); - descElement = "\n"; + descElement = "\n"; destRef->Write( descElement.c_str(), static_cast< int >( descElement.length() ) ); } // SVG_MetaHandler::InsertNewDescription @@ -395,13 +810,13 @@ // SVG_MetaHandler::InsertNewMetadata // =========================== // It is handling the insertion case -void SVG_MetaHandler::InsertNewMetadata( XMP_IO * destRef, const std::string &value ) +void SVG_MetaHandler::InsertNewMetadata( XMP_IO * destRef, const std::string &value, const std::string &prefix ) { - std::string metadataElement = ""; + std::string metadataElement = "<" + prefix + "metadata>"; destRef->Write( metadataElement.c_str(), static_cast< int >( metadataElement.length() ) ); destRef->Write( value.c_str(), static_cast< int >( value.length() ) ); - metadataElement = "\n"; + metadataElement = "\n"; destRef->Write( metadataElement.c_str(), static_cast< int >( metadataElement.length() ) ); } // SVG_MetaHandler::InsertNewMetadata @@ -448,20 +863,28 @@ bool isUpdateRequire = isTitleUpdateReq | isDescUpdateReq | (this->packetInfo.offset == kXMPFiles_UnknownOffset); // Inplace Updation of XMP - if ( !isUpdateRequire && ((XMP_Int32)(this->xmpPacket.size()) == this->packetInfo.length) ) + if ( !isUpdateRequire && ((XMP_Int32)this->xmpPacket.size() == this->packetInfo.length) ) { - sourceRef->Seek( this->packetInfo.offset, kXMP_SeekFromStart ); - sourceRef->Write( this->xmpPacket.c_str(), static_cast< int >( this->xmpPacket.size() ) ); + if(this->isCompressed) + { + ReplaceData(&this->svgContents, this->packetInfo.offset, this->packetInfo.length, ( const XMP_Uns8 * )this->xmpPacket.data(), this->packetInfo.length); + CompressMemoryToFile(this->svgContents, sourceRef); + } + else { + sourceRef->Seek(this->packetInfo.offset, kXMP_SeekFromStart); + sourceRef->Write(this->xmpPacket.c_str(), static_cast( this->xmpPacket.size() )); + } } else { + // Inplace is not possibe, So perform full updation try { XMP_IO* tempRef = sourceRef->DeriveTemp(); - this->WriteTempFile( tempRef ); + this->WriteTempFile(tempRef); } - catch ( ... ) + catch(...) { sourceRef->DeleteTemp(); throw; @@ -489,8 +912,14 @@ tempRef->Rewind(); sourceRef->Rewind(); + if(isCompressed) + sourceRef = NULL; + XMP_Int64 currentOffset = svgAdapter->firstSVGElementOffset; - XIO::Copy( sourceRef, tempRef, currentOffset ); + if(currentOffset == -1) { + currentOffset = svgAdapter->GetElementOffsets("svg").endOffset; + } + Write(sourceRef, tempRef, currentOffset, 0); OffsetStruct titleOffset = svgAdapter->GetElementOffsets( "title" ); OffsetStruct descOffset = svgAdapter->GetElementOffsets( "desc" ); @@ -531,6 +960,22 @@ // Initial Insertion/Updation + //Find the prefix of URI "http://www.w3.org/2000/svg" + //It is not possible that this uri is not present , as it is checked in checkFileFormat + + XMP_StringPtr prefix; + XMP_StringLen prefixLen; + + std::string nameSpacePrefix = ""; + bool found = svgAdapter->registeredNamespaces->GetPrefix ( kURI_SVG , &prefix , &prefixLen ); + if( !found ) { + XMP_Error error ( kXMPErr_ExternalFailure , "SVG URI not present in svg file" ); + svgAdapter->NotifyClient ( kXMPErrSev_OperationFatal , error ); + } + + if( strcmp(prefix,"_dflt_:") != 0 ) + nameSpacePrefix.assign ( prefix, prefixLen ); + // Insert/Update Title if requires // Don't insert/update it if Metadata or desc child comes before title child bool isTitleWritten = !isTitleUpdateReq; @@ -539,7 +984,7 @@ // Insertion Case if ( titleNode == NULL ) { - InsertNewTitle( tempRef, title ); + InsertNewTitle( tempRef, title, nameSpacePrefix ); isTitleWritten = true; } else if ( ( descOffset.startOffset == -1 || titleOffset.startOffset < descOffset.startOffset ) // Updation/Deletion Case @@ -559,10 +1004,10 @@ { if ( titleOffset.nextOffset != -1 ) { - XIO::Copy( sourceRef, tempRef, titleOffset.nextOffset - currentOffset ); + Write(sourceRef, tempRef, titleOffset.nextOffset - currentOffset, currentOffset); currentOffset = titleOffset.nextOffset; } - InsertNewDescription( tempRef, description ); + InsertNewDescription( tempRef, description, nameSpacePrefix ); isDescWritten = true; } else if ( metadataOffset.startOffset == -1 || descOffset.startOffset < metadataOffset.startOffset ) @@ -579,15 +1024,15 @@ { if ( descOffset.nextOffset != -1 ) { - XIO::Copy( sourceRef, tempRef, descOffset.nextOffset - currentOffset ); + Write(sourceRef, tempRef, descOffset.nextOffset - currentOffset, currentOffset); currentOffset = descOffset.nextOffset; } else if ( titleOffset.nextOffset != -1 ) { - XIO::Copy( sourceRef, tempRef, titleOffset.nextOffset - currentOffset ); + Write(sourceRef, tempRef, titleOffset.nextOffset - currentOffset, currentOffset); currentOffset = titleOffset.nextOffset; } - InsertNewMetadata( tempRef, this->xmpPacket ); + InsertNewMetadata( tempRef, this->xmpPacket, nameSpacePrefix ); isMetadataWritten = true; } else if ( !( !isTitleWritten && isDescWritten && titleOffset.startOffset < metadataOffset.startOffset ) ) // Not DTM @@ -595,17 +1040,28 @@ // No XMP packet was present in the file if ( this->packetInfo.offset == kXMPFiles_UnknownOffset ) { - std::string metadataElement = ""; + /* + std::string metadataElement = "<" + nameSpacePrefix+ "metadata>"; XIO::Copy( sourceRef, tempRef, metadataOffset.startOffset - currentOffset + metadataElement.length() ); currentOffset = sourceRef->Offset(); tempRef->Write( this->xmpPacket.c_str(), static_cast< int >( this->xmpPacket.length() ) ); + */ + + Write(sourceRef, tempRef, metadataOffset.startOffset - currentOffset, currentOffset); + InsertNewMetadata(tempRef, this->xmpPacket.c_str(), nameSpacePrefix); + if(sourceRef != NULL){ + sourceRef->Seek(metadataOffset.nextOffset, kXMP_SeekFromStart); + } + currentOffset = metadataOffset.nextOffset; } else // Replace XMP Packet { - XIO::Copy( sourceRef, tempRef, this->packetInfo.offset - currentOffset ); - tempRef->Write( this->xmpPacket.c_str(), static_cast< int >( this->xmpPacket.length() ) ); - sourceRef->Seek( this->packetInfo.offset + this->packetInfo.length, kXMP_SeekFromStart ); - currentOffset = sourceRef->Offset(); + Write(sourceRef, tempRef, this->packetInfo.offset - currentOffset, currentOffset); + if(sourceRef != NULL) { + sourceRef->Seek(this->packetInfo.offset + this->packetInfo.length, kXMP_SeekFromStart); + } + tempRef->Write(this->xmpPacket.c_str(), static_cast< int >( this->xmpPacket.length() )); + currentOffset = this->packetInfo.offset + this->packetInfo.length; } isMetadataWritten = true; } @@ -613,7 +1069,7 @@ // If simple cases was followed then copy rest file if ( isTitleWritten && isDescWritten && isMetadataWritten ) { - XIO::Copy( sourceRef, tempRef, ( sourceRef->Length() - currentOffset ) ); + Write(sourceRef, tempRef, ( (sourceRef ? sourceRef->Length() : this->svgContents.size() ) - currentOffset ), currentOffset); return; } @@ -629,17 +1085,18 @@ if ( this->packetInfo.offset == kXMPFiles_UnknownOffset ) { - std::string metadataElement = ""; - XIO::Copy( sourceRef, tempRef, metadataOffset.startOffset - currentOffset + metadataElement.length() ); - currentOffset = sourceRef->Offset(); - tempRef->Write( this->xmpPacket.c_str(), static_cast< int >( this->xmpPacket.length() ) ); + std::string metadataElement = "<" + nameSpacePrefix + "metadata>"; + Write(sourceRef, tempRef, metadataOffset.startOffset - currentOffset + metadataElement.length(), currentOffset); + currentOffset = metadataOffset.startOffset + metadataElement.length(); + tempRef->Write(this->xmpPacket.c_str(), static_cast< int >( this->xmpPacket.length() )); } else { - XIO::Copy( sourceRef, tempRef, this->packetInfo.offset - currentOffset ); - tempRef->Write( this->xmpPacket.c_str(), static_cast< int >( this->xmpPacket.length() ) ); - sourceRef->Seek( this->packetInfo.offset + this->packetInfo.length, kXMP_SeekFromStart ); - currentOffset = sourceRef->Offset(); + Write(sourceRef, tempRef, this->packetInfo.offset - currentOffset, currentOffset); + tempRef->Write(this->xmpPacket.c_str(), static_cast< int >( this->xmpPacket.length() )); + if(sourceRef != NULL) + sourceRef->Seek(this->packetInfo.offset + this->packetInfo.length, kXMP_SeekFromStart); + currentOffset = this->packetInfo.offset + this->packetInfo.length; } isMetadataWritten = true; @@ -683,8 +1140,40 @@ } // Finally Everything would have been written - XMP_Enforce( isTitleWritten && isDescWritten && isMetadataWritten ); - XIO::Copy( sourceRef, tempRef, ( sourceRef->Length() - currentOffset ) ); + XMP_Enforce(isTitleWritten && isDescWritten && isMetadataWritten); + Write(sourceRef, tempRef, ( ( sourceRef ? sourceRef->Length() : this->svgContents.size() ) - currentOffset ), currentOffset); this->needsUpdate = false; + if(this->isCompressed) + { + try + { + XMP_IO* tempCompressedRef = tempRef->DeriveTemp(); + this->CompressFileToFile(tempRef, tempCompressedRef); + } + catch(...) + { + tempRef->DeleteTemp(); + throw; + } + tempRef->AbsorbTemp(); + } } // SVG_MetaHandler::WriteTempFile + +// ================================================================================================= +// SVG_MetaHandler::Write +// ============================== +// This function will write from buffer(svgContents i.e uncompressed contents) to destFile if sourceFile is NULL , +// otherwise from sourceFile to DestFile. +void SVG_MetaHandler::Write(XMP_IO* sourceFile, XMP_IO* destFile, XMP_Int64 length, XMP_Int64 currentOffset) { + + if(sourceFile != NULL) { + XIO::Copy(sourceFile, destFile, length); + } + else { + //assuming currentOffset and length will never be negative + if(this->svgContents.capacity() - static_castsvgContents.capacity())>(currentOffset) < static_castsvgContents.capacity())>(length)) + this->svgContents.reserve(currentOffset + length); + destFile->Write(&( this->svgContents.data() [currentOffset] ), static_cast(length)); + } +} //SVG_MetaHandler::Write diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/SVG_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/SVG_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/SVG_Handler.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/SVG_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,16 +2,16 @@ #define __SVG_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2015 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2015 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // // This file includes implementation of SVG metadata, according to Scalable Vector Graphics (SVG) 1.1 Specification. // "https://www.w3.org/TR/2003/REC-SVG11-20030114/" -// Copyright © 1994-2002 World Wide Web Consortium, (Massachusetts Institute of Technology, +// Copyright 1994-2002 World Wide Web Consortium, (Massachusetts Institute of Technology, // Institut National de Recherche en Informatique et en Automatique, Keio University). // All Rights Reserved . http://www.w3.org/Consortium/Legal // @@ -25,6 +25,8 @@ #include "XMPFiles/source/XMPFiles_Impl.hpp" #include "XMPFiles/source/FormatSupport/SVG_Adapter.hpp" +#include "third-party/zlib/zlib.h" + extern XMPFileHandler* SVG_MetaHandlerCTor( XMPFiles* parent ); extern bool SVG_CheckFormat( XMP_FileFormat format, @@ -63,12 +65,22 @@ bool isTitleUpdateReq; bool isDescUpdateReq; + RawDataBlock svgContents; + bool isCompressed; + gz_header compressedHeader; + void ProcessTitle( XMP_IO* sourceRef, XMP_IO * destRef, const std::string &value, XMP_Int64 ¤tOffset, const OffsetStruct & titleOffset ); void ProcessDescription( XMP_IO* sourceRef, XMP_IO * destRef, const std::string &value, XMP_Int64 ¤tOffset, const OffsetStruct & descOffset ); - void InsertNewTitle( XMP_IO * destRef, const std::string &value ); - void InsertNewDescription( XMP_IO * destRef, const std::string &value ); - void InsertNewMetadata( XMP_IO * destRef, const std::string &value ); - + void InsertNewTitle( XMP_IO * destRef, const std::string &value, const std::string &prefix ); + void InsertNewDescription( XMP_IO * destRef, const std::string &value, const std::string &prefix ); + void InsertNewMetadata( XMP_IO * destRef, const std::string &value, const std::string &prefix ); + + void Write(XMP_IO* sourceFile, XMP_IO* destFile, XMP_Int64 length, XMP_Int64 currentOffset); + + XMP_Int64 CompressMemoryToFile(const RawDataBlock & dataOut, XMP_IO * fileIn); + XMP_Int64 DecompressFileToMemory(XMP_IO * fileIn, RawDataBlock * dataOut); + XMP_Int64 CompressFileToFile(XMP_IO * fileIn, XMP_IO * fileOut); + }; // SVG_MetaHandler // ================================================================================================= diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/SWF_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/SWF_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/SWF_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/SWF_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -125,7 +125,7 @@ // Expand the SWF file into memory. this->expandedSWF.reserve ( this->expandedSize ); // Try to avoid reallocations. SWF_IO::DecompressFileToMemory ( fileRef, &this->expandedSWF ); - this->expandedSize = this->expandedSWF.size(); // Use the true length. + this->expandedSize = (XMP_Uns32)this->expandedSWF.size(); // Use the true length. } else { @@ -139,6 +139,7 @@ // Look for the FileAttributes and Metadata tags. + if(this->expandedSize <= SWF_IO::HeaderPrefixSize ) return; // Throw? this->firstTagOffset = SWF_IO::FileHeaderSize ( this->expandedSWF[SWF_IO::HeaderPrefixSize] ); XMP_Uns32 currOffset = this->firstTagOffset; @@ -235,6 +236,9 @@ PutUns16LE ( ((SWF_IO::FileAttributesTagID << 6) | 4), &buffer[0] ); PutUns32LE ( SWF_IO::HasMetadataMask, &buffer[2] ); + if(this->expandedSWF.size() < this->firstTagOffset ){ + XMP_Throw ( "Index not valid.Invalid SWF, can't update.", kXMPErr_BadIndex ); + } this->expandedSWF.insert ( (this->expandedSWF.begin() + this->firstTagOffset), 6, 0 ); memcpy ( &this->expandedSWF[this->firstTagOffset], &buffer[0], 6 ); @@ -271,6 +275,9 @@ this->metadataTag.tagOffset += attrTagLength; // The FileAttributes tag will become in front. } + if(this->expandedSWF.size() < this->firstTagOffset ){ + XMP_Throw ( "Index not valid.Invalid SWF, can't update.", kXMPErr_BadIndex ); + } this->expandedSWF.insert ( (this->expandedSWF.begin() + this->firstTagOffset), attrTagLength, 0 ); memcpy ( &this->expandedSWF[this->firstTagOffset], &attrTag[0], attrTagLength ); @@ -298,9 +305,12 @@ this->metadataTag.hasLongHeader = true; this->metadataTag.tagID = SWF_IO::MetadataTagID; this->metadataTag.tagOffset = SWF_IO::NextTagOffset ( this->fileAttributesTag ); - this->metadataTag.contentLength = this->xmpPacket.size(); + this->metadataTag.contentLength = (XMP_Uns32)this->xmpPacket.size(); XMP_Uns32 newMetaLength = 6 + this->metadataTag.contentLength; // Always use a long tag header. + if(this->expandedSWF.size() < this->metadataTag.tagOffset ){ + XMP_Throw ( "Index not valid.Invalid SWF, can't update.", kXMPErr_BadIndex ); + } this->expandedSWF.insert ( (this->expandedSWF.begin() + this->metadataTag.tagOffset), newMetaLength, 0 ); PutUns16LE ( ((SWF_IO::MetadataTagID << 6) | SWF_IO::TagLengthMask), &this->expandedSWF[this->metadataTag.tagOffset] ); @@ -311,7 +321,7 @@ // Update the uncompressed file length and rewrite the file. - PutUns32LE ( this->expandedSWF.size(), &this->expandedSWF[4] ); + PutUns32LE ( (XMP_Uns32)this->expandedSWF.size(), &this->expandedSWF[4] ); XMP_IO * fileRef = this->parent->ioRef; fileRef->Rewind(); @@ -320,7 +330,7 @@ if ( this->isCompressed ) { SWF_IO::CompressMemoryToFile ( this->expandedSWF, fileRef ); } else { - fileRef->Write ( &this->expandedSWF[0], this->expandedSWF.size() ); + fileRef->Write ( &this->expandedSWF[0], (XMP_Uns32)this->expandedSWF.size() ); } } // SWF_MetaHandler::UpdateFile diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/SWF_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/SWF_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/SWF_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/SWF_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __SWF_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/TIFF_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/TIFF_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/TIFF_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/TIFF_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. @@ -235,9 +235,7 @@ // zero padding for the IPTC digest. If the full digest differs, recheck without the padding. iptcDigestState = PhotoDataUtils::CheckIPTCDigest ( iptcInfo.dataPtr, iptcInfo.dataLen, digestInfo.dataPtr ); - // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105205 - // if iptcInfo.dataLen is 0, then there is no digest. - if ( (iptcDigestState == kDigestDiffers) && (kTIFF_TypeSizes[iptcInfo.type] > 1) && iptcInfo.dataLen > 0 ) { + if ( (iptcDigestState == kDigestDiffers) && (kTIFF_TypeSizes[iptcInfo.type] > 1) && iptcInfo.dataLen > 0) { XMP_Uns8 * endPtr = (XMP_Uns8*)iptcInfo.dataPtr + iptcInfo.dataLen - 1; XMP_Uns8 * minPtr = endPtr - kTIFF_TypeSizes[iptcInfo.type] + 1; while ( (endPtr >= minPtr) && (*endPtr == 0) ) --endPtr; @@ -363,10 +361,10 @@ if ( progressTracker != 0 ) { if ( progressTracker->WorkInProgress() ) { - progressTracker->AddTotalWork ( this->xmpPacket.size() ); + progressTracker->AddTotalWork ( (float(this->xmpPacket.size())) ); } else { localProgressTracking = true; - progressTracker->BeginWork ( this->xmpPacket.size() ); + progressTracker->BeginWork ( (float(this->xmpPacket.size())) ); } } diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/TIFF_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/TIFF_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/TIFF_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/TIFF_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __TIFF_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "XMPFiles/source/FormatSupport/TIFF_Support.hpp" diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/Trivial_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/Trivial_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/Trivial_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/Trivial_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2004 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2004 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/Trivial_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/Trivial_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/Trivial_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/Trivial_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __Trivial_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2004 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2004 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "XMPFiles/source/XMPFiles_Impl.hpp" diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/UCF_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/UCF_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/UCF_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/UCF_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2007 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2007 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // =============================================================================================== #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -131,6 +131,8 @@ XMP_LitMatch( mimetype, "application/vnd.adobe.collage" ) || //Adobe Collage XMP_LitMatch( mimetype, "application/vnd.adobe.ideas" ) || //Adobe Ideas XMP_LitMatch( mimetype, "application/vnd.adobe.proto" ) || //Adobe Proto + XMP_LitMatch( mimetype, "application/vnd.adobe.sparkler.project+dcxucf" ) || //Adobe DCX + XMP_LitMatch( mimetype, "3d/vnd.adobe.dn+dcxucf" ) || //Adobe Dimensions false ) // "sentinel" // *** ==> unknown are also treated as not acceptable @@ -486,6 +488,9 @@ } have = CHUNK - strm.avail_out; + if ((bytesWritten + have) > sizeUncompressed){ + XMP_Throw("UCF Bad XMP block", kXMPErr_BadBlockFormat); + } memcpy( (unsigned char*) packetStr + bytesWritten , out , have ); bytesWritten += have; @@ -547,7 +552,6 @@ uncomprPacketLen = (XMP_StringLen) xmpPacket.size(); finalPacketStr = uncomprPacketStr; // will be overriden if compressedXMP==true finalPacketLen = uncomprPacketLen; - std::string compressedPacket; // moot if non-compressed, still here for scope reasons (having to keep a .c_str() alive) if ( !x ) // if new XMP... { @@ -584,6 +588,9 @@ unsigned int have; z_stream strm; unsigned char out[CHUNK]; + /* initilalisation for fix to CTECHXMP-4170441*/ + strm.total_out = 0; + strm.total_in = 0; /* allocate deflate state */ strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; @@ -621,7 +628,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////// // CRC (always of uncompressed data) - XMP_Uns32 crc = crc32( 0 , (Bytef*)uncomprPacketStr, uncomprPacketLen ); + XMP_Uns32 crc = (XMP_Uns32)crc32( 0 , (Bytef*)uncomprPacketStr, uncomprPacketLen ); PutUns32LE( crc, &xmpFileHeader.fields[FileHeader::o_crc32] ); //////////////////////////////////////////////////////////////////////////////////////////////// diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/UCF_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/UCF_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/UCF_Handler.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/UCF_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __UCF_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2007 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2007 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -710,6 +710,7 @@ XMP_StringLen uncomprPacketLen; XMP_StringPtr finalPacketStr; XMP_StringLen finalPacketLen; + std::string compressedPacket; std::vector cdEntries; EndOfCD endOfCD; void writeOut( XMP_IO* sourceFile, XMP_IO* targetFile, bool isRewrite, bool isInPlace); diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/WAVE_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/WAVE_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/WAVE_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/WAVE_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -106,34 +106,34 @@ // ChunkIdentifier // RIFF:WAVE/PMX_ -const ChunkIdentifier WAVE_MetaHandler::kRIFFXMP[2] = { { kChunk_RIFF, kType_WAVE }, { kChunk_XMP, kType_NONE} }; +const ChunkIdentifier WAVE_MetaHandler::kRIFFXMP[2] = { { (static_cast(kChunk_RIFF)), (static_cast(kType_WAVE)) }, { (static_cast(kChunk_XMP)),(static_cast(kType_NONE))} }; // RIFF:WAVE/LIST:INFO -const ChunkIdentifier WAVE_MetaHandler::kRIFFInfo[2] = { { kChunk_RIFF, kType_WAVE }, { kChunk_LIST, kType_INFO } }; +const ChunkIdentifier WAVE_MetaHandler::kRIFFInfo[2] = { { static_cast(kChunk_RIFF), static_cast(kType_WAVE) }, { static_cast(kChunk_LIST), static_cast(kType_INFO) } }; // RIFF:WAVE/DISP -const ChunkIdentifier WAVE_MetaHandler::kRIFFDisp[2] = { { kChunk_RIFF, kType_WAVE }, { kChunk_DISP, kType_NONE } }; +const ChunkIdentifier WAVE_MetaHandler::kRIFFDisp[2] = { { static_cast(kChunk_RIFF), static_cast(kType_WAVE) }, { static_cast(kChunk_DISP), (static_cast(kType_NONE)) } }; // RIFF:WAVE/BEXT -const ChunkIdentifier WAVE_MetaHandler::kRIFFBext[2] = { { kChunk_RIFF, kType_WAVE }, { kChunk_bext, kType_NONE } }; +const ChunkIdentifier WAVE_MetaHandler::kRIFFBext[2] = { { static_cast(kChunk_RIFF), static_cast(kType_WAVE) }, { static_cast(kChunk_bext), (static_cast(kType_NONE)) } }; // RIFF:WAVE/cart -const ChunkIdentifier WAVE_MetaHandler::kRIFFCart[2] = { { kChunk_RIFF, kType_WAVE }, { kChunk_cart, kType_NONE } }; +const ChunkIdentifier WAVE_MetaHandler::kRIFFCart[2] = { { static_cast(kChunk_RIFF), static_cast(kType_WAVE) }, { static_cast(kChunk_cart), (static_cast(kType_NONE)) } }; // cr8r is not yet required for WAVE // RIFF:WAVE/Cr8r // const ChunkIdentifier WAVE_MetaHandler::kWAVECr8r[2] = { { kChunk_RIFF, kType_WAVE }, { kChunk_Cr8r, kType_NONE } }; // RIFF:WAVE/iXML -const ChunkIdentifier WAVE_MetaHandler::kRIFFiXML[2] = { { kChunk_RIFF, kType_WAVE }, { kChunk_iXML, kType_NONE } }; +const ChunkIdentifier WAVE_MetaHandler::kRIFFiXML[2] = { { static_cast(kChunk_RIFF), static_cast(kType_WAVE) }, { static_cast(kChunk_iXML), (static_cast(kType_NONE)) } }; // RF64:WAVE/PMX_ -const ChunkIdentifier WAVE_MetaHandler::kRF64XMP[2] = { { kChunk_RF64, kType_WAVE }, { kChunk_XMP, kType_NONE} }; +const ChunkIdentifier WAVE_MetaHandler::kRF64XMP[2] = { { static_cast(kChunk_RF64), static_cast(kType_WAVE) }, { static_cast(kChunk_XMP), (static_cast(kType_NONE)) } }; // RF64:WAVE/LIST:INFO -const ChunkIdentifier WAVE_MetaHandler::kRF64Info[2] = { { kChunk_RF64, kType_WAVE }, { kChunk_LIST, kType_INFO } }; +const ChunkIdentifier WAVE_MetaHandler::kRF64Info[2] = { { static_cast(kChunk_RF64), static_cast(kType_WAVE) }, { static_cast(kChunk_LIST), static_cast(kType_INFO) } }; // RF64:WAVE/DISP -const ChunkIdentifier WAVE_MetaHandler::kRF64Disp[2] = { { kChunk_RF64, kType_WAVE }, { kChunk_DISP, kType_NONE } }; +const ChunkIdentifier WAVE_MetaHandler::kRF64Disp[2] = { { static_cast(kChunk_RF64), static_cast(kType_WAVE) }, { static_cast(kChunk_DISP), (static_cast(kType_NONE)) } }; // RF64:WAVE/BEXT -const ChunkIdentifier WAVE_MetaHandler::kRF64Bext[2] = { { kChunk_RF64, kType_WAVE }, { kChunk_bext, kType_NONE } }; +const ChunkIdentifier WAVE_MetaHandler::kRF64Bext[2] = { { static_cast(kChunk_RF64), static_cast(kType_WAVE) }, { static_cast(kChunk_bext), (static_cast(kType_NONE)) } }; // RF64:WAVE/cart -const ChunkIdentifier WAVE_MetaHandler::kRF64Cart[2] = { { kChunk_RF64, kType_WAVE }, { kChunk_cart, kType_NONE } }; +const ChunkIdentifier WAVE_MetaHandler::kRF64Cart[2] = { { static_cast(kChunk_RF64), static_cast(kType_WAVE) }, { static_cast(kChunk_cart), (static_cast(kType_NONE)) } }; // cr8r is not yet required for WAVE // RF64:WAVE/Cr8r // const ChunkIdentifier WAVE_MetaHandler::kRF64Cr8r[2] = { { kChunk_RF64, kType_WAVE }, { kChunk_Cr8r, kType_NONE } }; -const ChunkIdentifier WAVE_MetaHandler::kRF64iXML[2] = { { kChunk_RF64, kType_WAVE }, { kChunk_iXML, kType_NONE } }; +const ChunkIdentifier WAVE_MetaHandler::kRF64iXML[2] = { { static_cast(kChunk_RF64), static_cast(kType_WAVE) }, { static_cast(kChunk_iXML), static_cast(kType_NONE) } }; // ================================================================================================= // WAVE_MetaHandler::WAVE_MetaHandler diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/WAVE_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/WAVE_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/WAVE_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/WAVE_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef __WAVE_Handler_hpp__ diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/XDCAMEX_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/XDCAMEX_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/XDCAMEX_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/XDCAMEX_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2008 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2008 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -305,29 +305,29 @@ if ( this->clipMetadata == 0 ) return; // Bail if we don't have any legacy XML. XMP_Assert ( this->expat != 0 ); - XMP_StringPtr xdcNS_ = this->xdcNS.c_str(); + XMP_StringPtr xdcNSptr = this->xdcNS.c_str(); XML_NodePtr legacyContext, legacyProp; - legacyContext = this->clipMetadata->GetNamedElement ( xdcNS_, "Access" ); + legacyContext = this->clipMetadata->GetNamedElement ( xdcNSptr, "Access" ); if ( legacyContext == 0 ) return; MD5_CTX context; unsigned char digestBin [16]; MD5Init ( &context ); - legacyProp = legacyContext->GetNamedElement ( xdcNS_, "Creator" ); + legacyProp = legacyContext->GetNamedElement ( xdcNSptr, "Creator" ); if ( (legacyProp != 0) && legacyProp->IsLeafContentNode() && (! legacyProp->content.empty()) ) { const XML_Node * xmlValue = legacyProp->content[0]; MD5Update ( &context, (XMP_Uns8*)xmlValue->value.c_str(), (unsigned int)xmlValue->value.size() ); } - legacyProp = legacyContext->GetNamedElement ( xdcNS_, "CreationDate" ); + legacyProp = legacyContext->GetNamedElement ( xdcNSptr, "CreationDate" ); if ( (legacyProp != 0) && legacyProp->IsLeafContentNode() && (! legacyProp->content.empty()) ) { const XML_Node * xmlValue = legacyProp->content[0]; MD5Update ( &context, (XMP_Uns8*)xmlValue->value.c_str(), (unsigned int)xmlValue->value.size() ); } - legacyProp = legacyContext->GetNamedElement ( xdcNS_, "LastUpdateDate" ); + legacyProp = legacyContext->GetNamedElement ( xdcNSptr, "LastUpdateDate" ); if ( (legacyProp != 0) && legacyProp->IsLeafContentNode() && (! legacyProp->content.empty()) ) { const XML_Node * xmlValue = legacyProp->content[0]; MD5Update ( &context, (XMP_Uns8*)xmlValue->value.c_str(), (unsigned int)xmlValue->value.size() ); @@ -700,14 +700,14 @@ // ======================================== bool XDCAMEX_MetaHandler::GetMediaProMetadata ( SXMPMeta * xmpObjPtr, - const std::string& clipUMID_, + const std::string& _clipUMID, bool digestFound ) { // Build a directory string to the MEDIAPRO file. std::string mediaproPath; this->MakeMediaproPath ( &mediaproPath ); - return XDCAM_Support::GetMediaProLegacyMetadata ( xmpObjPtr, clipUMID_, mediaproPath, digestFound ); + return XDCAM_Support::GetMediaProLegacyMetadata ( xmpObjPtr, _clipUMID, mediaproPath, digestFound ); } // XDCAMEX_MetaHandler::GetMediaProMetadata @@ -715,7 +715,7 @@ // XDCAMEX_MetaHandler::GetTakeUMID // ================================ -void XDCAMEX_MetaHandler::GetTakeUMID ( const std::string& clipUMID_, +void XDCAMEX_MetaHandler::GetTakeUMID ( const std::string& _clipUMID, std::string& takeUMID, std::string& takeXMLURI ) { @@ -804,7 +804,7 @@ XMP_StringPtr compUMID = componentElement->GetAttrValue ( "umid" ); - if ( (compUMID != 0) && (compUMID == clipUMID_) ) { + if ( (compUMID != 0) && (compUMID == _clipUMID) ) { takeUMID = umid; takeXMLURI = uri; break; @@ -886,7 +886,7 @@ // Check the legacy digest. - XMP_StringPtr legacyNS_ = this->legacyNS.c_str(); + XMP_StringPtr legacyNSPtr = this->legacyNS.c_str(); this->clipMetadata = rootElem; // ! Save the NonRealTimeMeta pointer for other use. std::string oldDigest, newDigest; @@ -899,7 +899,7 @@ // If we get here we need find and import the actual legacy elements using the current namespace. // Either there is no old digest in the XMP, or the digests differ. In the former case keep any // existing XMP, in the latter case take new legacy values. - this->containsXMP = XDCAM_Support::GetLegacyMetadata ( &this->xmpObj, rootElem, legacyNS_, digestFound, thisUMID ); + this->containsXMP = XDCAM_Support::GetLegacyMetadata ( &this->xmpObj, rootElem, legacyNSPtr, digestFound, thisUMID ); // If this clip is part of a take, add the take number to the relation field, and get the // duration from the take metadata. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/XDCAMEX_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/XDCAMEX_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/XDCAMEX_Handler.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/XDCAMEX_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __XDCAMEX_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2008 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2008 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/XDCAMFAM_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/XDCAMFAM_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/XDCAMFAM_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/XDCAMFAM_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2015 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2015 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= // ================================================================================================= @@ -333,9 +333,9 @@ XMP_VarString fileName; size_t pos = editNRTFile.find_last_of ( kDirChar ); fileName = editNRTFile.substr ( pos + 1 ); - XMP_VarString regExp = "^" + fileName + "M\\d\\d.XML$"; + XMP_VarString regExpStr = "^" + fileName + "M\\d\\d.XML$"; oldCount = resourceList->size(); - IOUtils::GetMatchingChildren ( *resourceList, clipPath, regExp, false, true, true ); + IOUtils::GetMatchingChildren ( *resourceList, clipPath, regExpStr, false, true, true ); atLeastOneFileAdded = resourceList->size() > oldCount; } @@ -376,9 +376,9 @@ XMP_VarString fileName; size_t pos = takeNRTFile.find_last_of ( kDirChar ); fileName = takeNRTFile.substr ( pos + 1 ); - XMP_VarString regExp = "^" + fileName + "M\\d\\d.XML$"; + XMP_VarString regExpStr = "^" + fileName + "M\\d\\d.XML$"; oldCount = resourceList->size(); - IOUtils::GetMatchingChildren ( *resourceList, clipPath, regExp, false, true, true ); + IOUtils::GetMatchingChildren ( *resourceList, clipPath, regExpStr, false, true, true ); atLeastOneFileAdded = resourceList->size() > oldCount; } } diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/XDCAMFAM_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/XDCAMFAM_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/XDCAMFAM_Handler.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/XDCAMFAM_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __XDCAMFAM_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2015 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2015 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/XDCAM_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/XDCAM_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/XDCAM_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/XDCAM_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2007 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2007 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -254,29 +254,29 @@ if ( this->clipMetadata == 0 ) return; // Bail if we don't have any legacy XML. XMP_Assert ( this->expat != 0 ); - XMP_StringPtr xdcNS_ = this->xdcNS.c_str(); + XMP_StringPtr xdcNSptr = this->xdcNS.c_str(); XML_NodePtr legacyContext, legacyProp; - legacyContext = this->clipMetadata->GetNamedElement ( xdcNS_, "Access" ); + legacyContext = this->clipMetadata->GetNamedElement ( xdcNSptr, "Access" ); if ( legacyContext == 0 ) return; MD5_CTX context; unsigned char digestBin [16]; MD5Init ( &context ); - legacyProp = legacyContext->GetNamedElement ( xdcNS_, "Creator" ); + legacyProp = legacyContext->GetNamedElement ( xdcNSptr, "Creator" ); if ( (legacyProp != 0) && legacyProp->IsLeafContentNode() && (! legacyProp->content.empty()) ) { const XML_Node * xmlValue = legacyProp->content[0]; MD5Update ( &context, (XMP_Uns8*)xmlValue->value.c_str(), (unsigned int)xmlValue->value.size() ); } - legacyProp = legacyContext->GetNamedElement ( xdcNS_, "CreationDate" ); + legacyProp = legacyContext->GetNamedElement ( xdcNSptr, "CreationDate" ); if ( (legacyProp != 0) && legacyProp->IsLeafContentNode() && (! legacyProp->content.empty()) ) { const XML_Node * xmlValue = legacyProp->content[0]; MD5Update ( &context, (XMP_Uns8*)xmlValue->value.c_str(), (unsigned int)xmlValue->value.size() ); } - legacyProp = legacyContext->GetNamedElement ( xdcNS_, "LastUpdateDate" ); + legacyProp = legacyContext->GetNamedElement ( xdcNSptr, "LastUpdateDate" ); if ( (legacyProp != 0) && legacyProp->IsLeafContentNode() && (! legacyProp->content.empty()) ) { const XML_Node * xmlValue = legacyProp->content[0]; MD5Update ( &context, (XMP_Uns8*)xmlValue->value.c_str(), (unsigned int)xmlValue->value.size() ); @@ -312,22 +312,22 @@ // XDCAM_MetaHandler::readXMLFile // ================================ -void XDCAM_MetaHandler::readXMLFile( XMP_StringPtr filePath, ExpatAdapter* &expat_ ) +void XDCAM_MetaHandler::readXMLFile( XMP_StringPtr filePath, ExpatAdapter* &_expat ) { Host_IO::FileRef hostRef = Host_IO::Open ( filePath, Host_IO::openReadOnly ); if ( hostRef == Host_IO::noFileRef ) return; // The open failed. XMPFiles_IO xmlFile ( hostRef, filePath, Host_IO::openReadOnly ); - expat_ = XMP_NewExpatAdapter ( ExpatAdapter::kUseLocalNamespaces ); - if ( expat_ == 0 ) XMP_Throw ( "XDCAM_MetaHandler: Can't create Expat adapter", kXMPErr_NoMemory ); + _expat = XMP_NewExpatAdapter ( ExpatAdapter::kUseLocalNamespaces ); + if ( _expat == 0 ) XMP_Throw ( "XDCAM_MetaHandler: Can't create Expat adapter", kXMPErr_NoMemory ); XMP_Uns8 buffer [64*1024]; while ( true ) { XMP_Int32 ioCount = xmlFile.Read ( buffer, sizeof(buffer) ); if ( ioCount == 0 ) break; - expat_->ParseBuffer ( buffer, ioCount, false /* not the end */ ); + _expat->ParseBuffer ( buffer, ioCount, false /* not the end */ ); } - expat_->ParseBuffer ( 0, 0, true ); // End the parse. + _expat->ParseBuffer ( 0, 0, true ); // End the parse. xmlFile.Close(); } @@ -574,7 +574,7 @@ // Check the legacy digest. - XMP_StringPtr legacyNS_ = this->legacyNS.c_str(); + XMP_StringPtr legacyNSPtr = this->legacyNS.c_str(); this->clipMetadata = rootElem; // ! Save the NonRealTimeMeta pointer for other use. @@ -589,7 +589,7 @@ // Either there is no old digest in the XMP, or the digests differ. In the former case keep any // existing XMP, in the latter case take new legacy values. - this->containsXMP = XDCAM_Support::GetLegacyMetadata ( &this->xmpObj, rootElem, legacyNS_, digestFound, umid ); + this->containsXMP = XDCAM_Support::GetLegacyMetadata ( &this->xmpObj, rootElem, legacyNSPtr, digestFound, umid ); this->containsXMP |= GetMediaProMetadata ( &this->xmpObj, umid, digestFound ); CleanupAndExit diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/XDCAM_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/XDCAM_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/XDCAM_Handler.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/XDCAM_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __XDCAM_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2007 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2007 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/XDCAMSAM_Handler.cpp exempi-2.6.1/XMPFiles/source/FileHandlers/XDCAMSAM_Handler.cpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/XDCAMSAM_Handler.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/XDCAMSAM_Handler.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2015 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2015 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FileHandlers/XDCAMSAM_Handler.hpp exempi-2.6.1/XMPFiles/source/FileHandlers/XDCAMSAM_Handler.hpp --- exempi-2.5.2/XMPFiles/source/FileHandlers/XDCAMSAM_Handler.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FileHandlers/XDCAMSAM_Handler.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __XDCAMSAM_Handler_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2015 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2015 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/AIFF/AIFFBehavior.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/AIFF/AIFFBehavior.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/AIFF/AIFFBehavior.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/AIFF/AIFFBehavior.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -174,7 +174,7 @@ XMP_Validate( (formChunk->getType() == kType_AIFF) || (formChunk->getType() == kType_AIFC), "Invalid type for AIFF/AIFC top level chunk (FORM)", kXMPErr_BadFileFormat); - XMP_Uns32 i = std::find( formChunk->firstChild(), formChunk->lastChild(), &chunk ) - formChunk->firstChild(); + XMP_Uns32 i = (XMP_Uns32) (std::find( formChunk->firstChild(), formChunk->lastChild(), &chunk ) - formChunk->firstChild()); XMP_Validate( i < formChunk->numChildren(), "Invalid chunk in tree", kXMPErr_InternalFailure ); diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/AIFF/AIFFBehavior.h exempi-2.6.1/XMPFiles/source/FormatSupport/AIFF/AIFFBehavior.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/AIFF/AIFFBehavior.h 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/AIFF/AIFFBehavior.h 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _AIFFBEHAVIOR_h_ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/AIFF/AIFFMetadata.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/AIFF/AIFFMetadata.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/AIFF/AIFFMetadata.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/AIFF/AIFFMetadata.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/AIFF/AIFFMetadata.h exempi-2.6.1/XMPFiles/source/FormatSupport/AIFF/AIFFMetadata.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/AIFF/AIFFMetadata.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/AIFF/AIFFMetadata.h 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _AIFFMetadata_h_ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/AIFF/AIFFReconcile.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/AIFF/AIFFReconcile.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/AIFF/AIFFReconcile.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/AIFF/AIFFReconcile.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/AIFF/AIFFReconcile.h exempi-2.6.1/XMPFiles/source/FormatSupport/AIFF/AIFFReconcile.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/AIFF/AIFFReconcile.h 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/AIFF/AIFFReconcile.h 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _AIFFReconcile_h_ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/ASF_Support.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/ASF_Support.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/ASF_Support.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/ASF_Support.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -145,10 +145,11 @@ pos += bufferSize; // read contained header objects - /*XMP_Uns32 numberOfHeaders = GetUns32LE ( &buffer[24] );*/ + XMP_Uns32 numberOfHeaders = GetUns32LE ( &buffer[24] ); ASF_ObjectBase objectBase; - while ( read < newObject.len ) { + while (read < newObject.len && numberOfHeaders > 0) + { fileRef->Seek ( pos, kXMP_SeekFromStart ); if ( kASF_ObjectBaseLen != fileRef->Read ( &objectBase, kASF_ObjectBaseLen, true ) ) break; @@ -156,6 +157,11 @@ fileRef->Seek ( pos, kXMP_SeekFromStart ); objectBase.size = GetUns64LE ( &objectBase.size ); + if (XMP_Uns32(objectBase.size) <= 0) /* as ASF_ObjectBase has size in XMP_Uns64 , XMP_Uns32 would give 0 for very large files exceeding UINT32_MAX */ + { + XMP_Throw("Failure reading ASF header object", kXMPErr_InternalFailure); + } + if ( IsEqualGUID ( ASF_File_Properties_Object, objectBase.guid) && (objectBase.size >= 104 ) ) { buffer.clear(); @@ -226,7 +232,7 @@ XMP_Uns32 fieldPos = 28; // copyright URL is 3. element with variable size - for ( int i = 1; i <= 3 ; ++i ) { + for ( int i = 1; i <= 3 && fieldPos < buffer.size() ; ++i ) { XMP_Uns32 len = GetUns32LE ( &buffer[fieldPos] ); if ( i == 3 ) { std::string copyrightURLStr = buffer.substr ( fieldPos + 4, len ); @@ -276,8 +282,8 @@ pos += objectBase.size; read += objectBase.size; + numberOfHeaders--; } - } catch ( ... ) { return false; @@ -316,7 +322,7 @@ pos += bufferSize; // read contained header objects - /*XMP_Uns32 numberOfHeaders = GetUns32LE ( &buffer[24] );*/ + XMP_Uns32 numberOfHeaders = GetUns32LE ( &buffer[24] ); ASF_ObjectBase objectBase; // prepare new header in memory @@ -328,7 +334,7 @@ header.append ( buffer.c_str(), bufferSize ); - while ( read < object.len ) { + while ( read < object.len && numberOfHeaders > 0 ) { sourceRef->Seek ( pos, kXMP_SeekFromStart ); if ( kASF_ObjectBaseLen != sourceRef->Read ( &objectBase, kASF_ObjectBaseLen, true ) ) break; @@ -336,7 +342,7 @@ sourceRef->Seek ( pos, kXMP_SeekFromStart ); objectBase.size = GetUns64LE ( &objectBase.size ); - int headerStartPos = header.size(); + int headerStartPos = (int)header.size(); // save position of filesize-information if ( IsEqualGUID ( ASF_File_Properties_Object, objectBase.guid ) ) { @@ -431,7 +437,7 @@ header.append ( buffer, 0, length ); // copyright URL - length = _legacyManager.GetField ( ASF_LegacyManager::fieldCopyrightURL).size( ); + length = (XMP_Uns32)_legacyManager.GetField ( ASF_LegacyManager::fieldCopyrightURL).size( ); valueUns32LE = MakeUns32LE ( length ); header.append ( (const char*)&valueUns32LE, 4 ); header.append ( _legacyManager.GetField ( ASF_LegacyManager::fieldCopyrightURL ) ); @@ -503,7 +509,7 @@ pos += objectBase.size; read += objectBase.size; - + numberOfHeaders--; writtenObjects ++; } @@ -520,7 +526,7 @@ if ( newObjects & ASF_LegacyManager::objectContentDescription ) { - headerStartPos = header.size(); + headerStartPos = (int)header.size(); newObjectBase.guid = ASF_Content_Description_Object; newObjectBase.size = 0; @@ -567,7 +573,7 @@ if ( newObjects & ASF_LegacyManager::objectContentBranding ) { - headerStartPos = header.size(); + headerStartPos = (int)header.size(); newObjectBase.guid = ASF_Content_Branding_Object; newObjectBase.size = 0; @@ -578,7 +584,7 @@ header.append ( 12, '\0' ); // copyright URL - length = _legacyManager.GetField ( ASF_LegacyManager::fieldCopyrightURL).size( ); + length = (XMP_Uns32)_legacyManager.GetField ( ASF_LegacyManager::fieldCopyrightURL).size( ); valueUns32LE = MakeUns32LE ( length ); header.append ( (const char*)&valueUns32LE, 4 ); header.append ( _legacyManager.GetField ( ASF_LegacyManager::fieldCopyrightURL ) ); @@ -653,7 +659,7 @@ this->progressTracker->AddTotalWork ( (float)header.size() ); } // write header - destRef->Write ( header.c_str(), header.size() ); + destRef->Write ( header.c_str(), (XMP_Uns32)header.size() ); } catch ( ... ) { @@ -777,7 +783,7 @@ if ( ! IsEqualGUID ( ASF_Header_Extension_Object, _objectBase.guid ) || (! header) || (buffer.size() < 46) ) return false; const XMP_Uns64 offset = 46; - int startPos = header->size(); + int startPos = (int)header->size(); // copy header base header->append ( buffer, 0, offset ); @@ -807,7 +813,7 @@ } // update header extension data size - XMP_Uns32 valueUns32LE = MakeUns32LE ( header->size() - startPos - offset ); + XMP_Uns32 valueUns32LE = MakeUns32LE ( (XMP_Uns32)header->size() - startPos - offset ); std::string newDataSize ( (const char*)&valueUns32LE, 4 ); ReplaceString ( *header, newDataSize, (startPos + 42), 4 ); @@ -1069,7 +1075,7 @@ if (fields[type].size ( ) > 0 ) { snprintf ( buffer, sizeof(buffer), "%d,", type ); digestStr.append ( buffer ); - MD5Update ( &context, (XMP_Uns8*)fields[type].data(), fields[type].size() ); + MD5Update ( &context, (XMP_Uns8*)fields[type].data(), (XMP_Uns32)fields[type].size() ); } } @@ -1256,7 +1262,7 @@ #endif // find objects, that would need to be created on legacy export - int newObjects = (objectsToExport & !objectsExisting); + int newObjects = (objectsToExport & ~objectsExisting); // calculate minimum storage for new objects, that might be created on export if ( newObjects & objectContentDescription ) diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/ASF_Support.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/ASF_Support.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/ASF_Support.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/ASF_Support.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __ASF_Support_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/ID3_Support.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/ID3_Support.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/ID3_Support.cpp 2019-07-28 14:14:08.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/ID3_Support.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2008 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2008 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. @@ -451,18 +451,18 @@ // ================================================================================================= -ID3v2Frame::ID3v2Frame ( XMP_Uns32 id_ ) : frameDefaults +ID3v2Frame::ID3v2Frame ( XMP_Uns32 _id ) : frameDefaults { memset ( this->fields, 0, kV23_FrameHeaderSize ); - this->id = id_; - PutUns32BE ( id_, &this->fields[o_id] ); + this->id = _id; + PutUns32BE ( _id, &this->fields[o_id] ); } // ================================================================================================= void ID3v2Frame::release() { - if ( this->content != 0 ) delete [] this->content; + if ( this->content != 0 ) delete [] content; this->content = 0; this->contentSize = 0; } @@ -627,7 +627,7 @@ } if ( pos > 4 ) { - std::string descriptor = std::string ( &this->content[4], pos-1 ); + std::string descriptor = std::string ( &this->content[4], pos-4 ); //changing pos-1 to pos-4, incorporating the size of .eng if ( 0 == descriptor.substr(0,4).compare( "iTun" ) ) { // begins with engiTun ? return false; // leave alone, then } @@ -793,10 +793,10 @@ if ( genreNo < numberedGenreCount ) { meta->SetProperty ( kXMP_NS_DM, "genre", kNumberedGenres[genreNo].name ); } else { - char buffer[4]; // AUDIT: Big enough for UInt8. - snprintf ( buffer, 4, "%d", genreNo ); - XMP_Assert ( strlen(buffer) == 3 ); // Should be in the range 126..255. - meta->SetProperty ( kXMP_NS_DM, "genre", buffer ); + char lBuffer[4]; // AUDIT: Big enough for UInt8. + snprintf ( lBuffer, 4, "%d", genreNo ); + XMP_Assert ( strlen(lBuffer) == 3 ); // Should be in the range 126..255. + meta->SetProperty ( kXMP_NS_DM, "genre", lBuffer ); } return true; // ID3Tag found diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/ID3_Support.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/ID3_Support.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/ID3_Support.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/ID3_Support.hpp 2021-11-18 03:53:53.000000000 +0000 @@ -2,12 +2,12 @@ #define __ID3_Support_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2008 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2008 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/ChunkController.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/ChunkController.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/ChunkController.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/ChunkController.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -48,7 +48,7 @@ mChunkBehavior->setMovablePaths( &mChunkPaths ); } -ChunkController::~ChunkController() noexcept(false) +ChunkController::~ChunkController() NO_EXCEPT_FALSE { XMP_Validate( mRoot != NULL, "ERROR inserting Chunk. mRoot is NULL.", kXMPErr_InternalFailure ); XMP_Assert(dynamic_cast(mRoot) == static_cast(mRoot)); @@ -195,20 +195,40 @@ // // check size if value exceeds 4GB border // - if( chunk->getSize() >= 0x00000000FFFFFFFFLL ) + if(chunk->getSize() >= kMaxRIFFChunkSize || chunk->getID() == kChunk_RF64) { // remember file position XMP_Int64 currentFilePos = stream->Offset(); - - // ask for the "real" size value - XMP_Uns64 realSize = mChunkBehavior->getRealSize( chunk->getSize(), + + if(chunk->getID() == kChunk_RF64) + { + // get riff size present in ds64 , parse ds64 as it a mandatory chunk + XMP_Uns64 ds64RF64Size = mChunkBehavior->getRealSize( kMaxRIFFChunkSize, + chunk->getIdentifier(), + *mRoot, stream ); + + if(chunk->getSize() >= kMaxRIFFChunkSize || + ((mFileSize - Chunk::HEADER_SIZE) >= kMaxRIFFChunkSize && + (mFileSize - Chunk::HEADER_SIZE) == ds64RF64Size)) + { + // to provide backward compatibilty, we read size from ds64 block when + // file size is greater than 4GB, set new size of rf64 chunk + chunk->setSize( ds64RF64Size, true ); + } + } + + else + { + // ask for the "real" size value + XMP_Uns64 realSize = mChunkBehavior->getRealSize( chunk->getSize(), chunk->getIdentifier(), *mRoot, stream ); - - // set new size at chunk - chunk->setSize( realSize, true ); - + + // set new size at chunk + chunk->setSize( realSize, true ); + } + // set flag if the file position changed chunkJump = currentFilePos < stream->Offset(); } diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/ChunkController.h exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/ChunkController.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/ChunkController.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/ChunkController.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _ChunkController_h_ @@ -51,7 +51,7 @@ */ ChunkController( IChunkBehavior* chunkBehavior, XMP_Bool bigEndian ); - ~ChunkController() noexcept(false); + ~ChunkController () NO_EXCEPT_FALSE; /** * Adds the given path to the array of "Chunk's of interest", @@ -243,6 +243,8 @@ std::vector mSearchResults; }; // ChunkController + static const XMP_Uns64 kMaxRIFFChunkSize = 0x00000000FFFFFFFFLL; + } // namespace #endif diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/Chunk.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/Chunk.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/Chunk.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/Chunk.cpp 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -843,16 +843,15 @@ XIO::WriteInt32_BE( file, mChunkId.id ); // writes size, which is always 32bit - // XXX for some reason this is unused -- Hub - /*XMP_Uns32 outSize = ( mSize >= 0x00000000FFFFFFFF ? 0xFFFFFFFF : static_cast( mSize & 0x00000000FFFFFFFF ) );*/ + XMP_Uns32 outSize = ( mSize >= 0x00000000FFFFFFFF ? 0xFFFFFFFF : static_cast( mSize & 0x00000000FFFFFFFF ) ); if (typeid(mEndian) == typeid(LittleEndian)) { - XIO::WriteUns32_LE( file, static_cast(mSize) ); + XIO::WriteUns32_LE( file, static_cast(outSize) ); } else { - XIO::WriteUns32_BE( file, static_cast(mSize) ); + XIO::WriteUns32_BE( file, static_cast(outSize) ); } @@ -1209,7 +1208,7 @@ mSize = mBufferSize; // if the difference is odd, the corrected even size has be incremented by 1 - sizeChange += std::abs(sizeChange % 2); + sizeChange += abs((XMP_Int32)sizeChange % 2); } else // mChunkMode == CHUNK_NODE/CHUNK_UNKNOWN { diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/Chunk.h exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/Chunk.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/Chunk.h 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/Chunk.h 2021-11-18 03:53:53.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _Chunk_h_ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/ChunkPath.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/ChunkPath.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/ChunkPath.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/ChunkPath.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "XMPFiles/source/FormatSupport/IFF/ChunkPath.h" diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/ChunkPath.h exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/ChunkPath.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/ChunkPath.h 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/ChunkPath.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _ChunkPath_h_ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/IChunkBehavior.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/IChunkBehavior.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/IChunkBehavior.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/IChunkBehavior.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -29,7 +29,7 @@ { const Chunk& parent = dynamic_cast( tree ); - return std::find( parent.firstChild(), parent.lastChild(), &chunk ) - parent.firstChild(); + return (XMP_Uns32)(std::find( parent.firstChild(), parent.lastChild(), &chunk ) - parent.firstChild()); } //----------------------------------------------------------------------------- diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/IChunkBehavior.h exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/IChunkBehavior.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/IChunkBehavior.h 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/IChunkBehavior.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _IChunkBehavior_h_ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/IChunkContainer.h exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/IChunkContainer.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/IChunkContainer.h 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/IChunkContainer.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _IChunkContainer_h_ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/IChunkData.h exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/IChunkData.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/IFF/IChunkData.h 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/IFF/IChunkData.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _IChunkData_h_ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/IPTC_Support.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/IPTC_Support.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/IPTC_Support.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/IPTC_Support.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -254,7 +254,7 @@ DataSetInfo dsInfo( recNum, dsNum, dsLen ); if ( dsLen != 0 ) dsInfo.dataPtr = iptcPtr; - DataSetMap::iterator dsPos = this->dataSets.find ( mapID ); + DataSetMap::iterator dsPosn = this->dataSets.find ( mapID ); bool repeatable = false; @@ -266,12 +266,12 @@ repeatable = true; } - if ( repeatable || (dsPos == this->dataSets.end()) ) { + if ( repeatable || (dsPosn == this->dataSets.end()) ) { DataSetMap::value_type mapValue ( mapID, dsInfo ); (void) this->dataSets.insert ( this->dataSets.upper_bound ( mapID ), mapValue ); } else { - this->DisposeLooseValue ( dsPos->second ); - dsPos->second = dsInfo; // Keep the last copy of illegal repeats. + this->DisposeLooseValue ( dsPosn->second ); + dsPosn->second = dsInfo; // Keep the last copy of illegal repeats. } } @@ -311,7 +311,7 @@ DataSetInfo dsInfo; size_t dsCount = GetDataSet ( dsNum, &dsInfo, which ); - if ( dsCount == 0 ) return 0; + if ( dsCount == 0 || dsInfo.dataLen == 0 || dsInfo.dataPtr == NULL) return 0; if ( utf8Str != 0 ) { if ( this->utf8Encoding ) { diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/IPTC_Support.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/IPTC_Support.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/IPTC_Support.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/IPTC_Support.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __IPTC_Support_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/ISOBaseMedia_Support.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/ISOBaseMedia_Support.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/ISOBaseMedia_Support.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/ISOBaseMedia_Support.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,13 +1,15 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2007 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2007 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. +#include + #include "public/include/XMP_Const.h" #include "XMPFiles/source/FormatSupport/ISOBaseMedia_Support.hpp" @@ -198,5 +200,327 @@ } // namespace ISO_Media +// ================================================================================================= +// ISOBaseMedia_Manager::GetBoxInfo +// =========================== +void ISOBaseMedia_Manager::GetBoxInfo(const BoxRef ref, BoxInfo * info) const +{ + + this->FillBoxInfo(*((BoxNode*)ref), info); + +} // MOOV_Manager::GetBoxInfo + +// ================================================================================================= +// ISOBaseMedia_Manager::FillBoxInfo +// =========================== +void ISOBaseMedia_Manager::FillBoxInfo(const BoxNode & node, BoxInfo * info) const +{ + if (info == 0) return; + + info->boxType = node.boxType; + info->childCount = (XMP_Uns32)node.children.size(); + info->contentSize = node.contentSize; + info->content = PickContentPtr(node); + if (node.boxType == ISOMedia::k_uuid) + memcpy(info->idUUID, node.idUUID, 16); + +} // ISOBaseMedia_Manager::FillBoxInfo +// ================================================================================================= // ================================================================================================= +// ISOBaseMedia_Manager::PickContentPtr +// =========================== +XMP_Uns8 * ISOBaseMedia_Manager::PickContentPtr(const BoxNode & node) const +{ + if (node.contentSize == 0) { + return 0; + } + else if (node.changed && node.changedContent.size()>0) { + + return (XMP_Uns8*)&node.changedContent[0]; + } + else { + return (XMP_Uns8*) &this->fullSubtree[0] + node.offset + node.headerSize; + } +} // ISOBaseMedia_Manager::PickContentPtr + +// ================================================================================================= +// ISOBaseMedia_Manager::GetNthChild +// =========================== +ISOBaseMedia_Manager::BoxRef ISOBaseMedia_Manager::GetNthChild(BoxRef parentRef, size_t childIndex, BoxInfo * info) const +{ + XMP_Assert(parentRef != 0); + const BoxNode & parent = *((BoxNode*)parentRef); + if (info != 0) memset(info, 0, sizeof(BoxInfo)); + + if (childIndex >= parent.children.size()) return 0; + + const BoxNode & currNode = parent.children[childIndex]; + + this->FillBoxInfo(currNode, info); + return &currNode; + +} // ISOBaseMedia_Manager::GetNthChild + +// ================================================================================================= +// ISOBaseMedia_Manager::GetTypeChild +// =========================== +ISOBaseMedia_Manager::BoxRef ISOBaseMedia_Manager::GetTypeChild(BoxRef parentRef, XMP_Uns32 childType, BoxInfo * info) const +{ + XMP_Assert(parentRef != 0); + const BoxNode & parent = *((BoxNode*)parentRef); + if (info != 0) memset(info, 0, sizeof(BoxInfo)); + if (parent.children.empty()) return 0; + + size_t i = 0, limit = parent.children.size(); + for (; i < limit; ++i) { + const BoxNode & currNode = parent.children[i]; + if (currNode.boxType == childType) { + this->FillBoxInfo(currNode, info); + return &currNode; + } + } + + return 0; + +} // ISOBaseMedia_Manager::GetTypeChild + +// ================================================================================================= +// ISOBaseMedia_Manager::GetParsedOffset +// =========================== +XMP_Uns32 ISOBaseMedia_Manager::GetParsedOffset(BoxRef ref) const +{ + XMP_Assert(ref != 0); + const BoxNode & node = *((BoxNode*)ref); + + if (node.changed) return 0; + return node.offset; + +} // ISOBaseMedia_Manager::GetParsedOffset + +// ================================================================================================= +// ISOBaseMedia_Manager::GetHeaderSize +// =========================== + +XMP_Uns32 ISOBaseMedia_Manager::GetHeaderSize(BoxRef ref) const +{ + XMP_Assert(ref != 0); + const BoxNode & node = *((BoxNode*)ref); + + if (node.changed) return 0; + return node.headerSize; + +} // ISOBaseMedia_Manager::GetHeaderSize + +// ================================================================================================= +// ISOBaseMedia_Manager::NoteChange +// ======================== + +void ISOBaseMedia_Manager::NoteChange() +{ + + this->subtreeRootNode.changed = true; + +} // ISOBaseMedia_Manager::NoteChange + +// ================================================================================================= +// ISOBaseMedia_Manager::SetBox +// ==================== +// +// Save the new data, set this box's changed flag, and set the top changed flag. + +void ISOBaseMedia_Manager::SetBox(BoxRef theBox, const void* dataPtr, XMP_Uns32 size, const XMP_Uns8 * idUUID) +{ + XMP_Enforce(size < TopBoxSizeLimit); + BoxNode * node = (BoxNode*)theBox; + + if (node->contentSize == size) { + if (node->boxType == ISOMedia::k_uuid && idUUID != 0) + { + memcpy(node->idUUID, idUUID, 16); + this->subtreeRootNode.changed = true; + } + XMP_Uns8 * oldContent = PickContentPtr(*node); + if (memcmp(oldContent, dataPtr, size) == 0) return; // No change. + memcpy(oldContent, dataPtr, size); // Update the old content in-place + this->subtreeRootNode.changed = true; + +#if TraceUpdateMoovTree + XMP_Uns32 be32 = MakeUns32BE(node->boxType); + fprintf(stderr, "Updated '%.4s', parse offset 0x%X, same size\n", &be32, node->offset); +#endif + + } + else { + + node->changedContent.assign(size, 0); // Fill with 0's first to get the storage. + memcpy(&node->changedContent[0], dataPtr, size); + node->contentSize = size; + node->changed = true; + if (node->boxType == ISOMedia::k_uuid && idUUID != 0) + memcpy(node->idUUID, idUUID, 16); + this->subtreeRootNode.changed = true; + +#if TraceUpdateMoovTree + XMP_Uns32 be32 = MakeUns32BE(node->boxType); + XMP_Uns32 addr32 = (XMP_Uns32) this->PickContentPtr(*node); + fprintf(stderr, "Updated '%.4s', parse offset 0x%X, new size %d, new content @ 0x%X\n", + &be32, node->offset, node->contentSize, addr32); +#endif + + } + +} // MOOV_Manager::SetBox + +// ================================================================================================= +// ISOBaseMedia_Manager::DeleteNthChild +// ============================ + +bool ISOBaseMedia_Manager::DeleteNthChild ( BoxRef parentRef, size_t childIndex ) +{ + BoxNode * parent = (BoxNode*)parentRef; + + if ( childIndex >= parent->children.size() ) return false; + + parent->children.erase ( parent->children.begin() + childIndex ); + return true; + +} // ISOBaseMedia_Manager::DeleteNthChild + +// ================================================================================================= +// ISOBaseMedia_Manager::DeleteTypeChild +// ============================= + +bool ISOBaseMedia_Manager::DeleteTypeChild ( BoxRef parentRef, XMP_Uns32 childType ) +{ + BoxNode * parent = (BoxNode*)parentRef; + + BoxListPos child = parent->children.begin(); + BoxListPos limit = parent->children.end(); + + for ( ; child != limit; ++child ) { + if ( child->boxType == childType ) { + parent->children.erase ( child ); + this->subtreeRootNode.changed = true; + return true; + } + } + + return false; + +} // ISOBaseMedia_Manager::DeleteTypeChild + +void ISOBaseMedia_Manager::WriteBoxHeader(XMP_IO* fileRef, XMP_Uns32 boxType, XMP_Uns64 boxSize) +{ + XMP_Uns32 u32; + XMP_Uns64 u64; + XMP_Enforce(boxSize >= 8); // The size must be the full size, not just the content. + + if (boxSize <= 0xFFFFFFFF) { + + u32 = MakeUns32BE((XMP_Uns32)boxSize); + fileRef->Write(&u32, 4); + u32 = MakeUns32BE(boxType); + fileRef->Write(&u32, 4); + + } + else { + + u32 = MakeUns32BE(1); + fileRef->Write(&u32, 4); + u32 = MakeUns32BE(boxType); + fileRef->Write(&u32, 4); + u64 = MakeUns64BE(boxSize); + fileRef->Write(&u64, 8); + + } + +} // WriteBoxHeader + +// ================================================================================================= +// WipeBoxFree +// =========== +// +// Change the box's type to 'free' (or create a 'free' box) and zero the content. + +static XMP_Uns8 kZeroes[64 * 1024]; // C semantics guarantee zero initialization. + +void ISOBaseMedia_Manager::WipeBoxFree(XMP_IO* fileRef, XMP_Uns64 boxOffset, XMP_Uns32 boxSize) +{ + if (boxSize == 0) return; + XMP_Enforce(boxSize >= 8); + + if (boxOffset > Max_XMP_Int64) + XMP_Throw( "Offset out of Int64 bound", kXMPErr_EnforceFailure); + + fileRef->Seek(boxOffset, kXMP_SeekFromStart); + XMP_Uns32 u32; + u32 = MakeUns32BE(boxSize); // ! The actual size should not change, but might have had a long header. + fileRef->Write(&u32, 4); + u32 = MakeUns32BE(ISOMedia::k_free); + fileRef->Write(&u32, 4); + + XMP_Uns32 ioCount = sizeof(kZeroes); + for (boxSize -= 8; boxSize > 0; boxSize -= ioCount) { + if (ioCount > boxSize) ioCount = boxSize; + fileRef->Write(&kZeroes[0], ioCount); + } + +} // WipeBoxFree + +// ================================================================================================= +// ISOBaseMedia_Manager::CreateFreeSpaceList +// =================== +void ISOBaseMedia_Manager::CreateFreeSpaceList(XMP_IO* fileRef, XMP_Uns64 fileSize, + XMP_Uns64 oldOffset, XMP_Uns32 oldSize, SpaceList * spaceList) +{ + XMP_Uns64 boxPos = 0, boxNext = 0, adjacentFree = 0; + ISOMedia::BoxInfo currBox; + + fileRef->Rewind(); + spaceList->clear(); + + for (boxPos = 0; boxPos < fileSize; boxPos = boxNext) { + + boxNext = ISOMedia::GetBoxInfo(fileRef, boxPos, fileSize, &currBox, true /* throw errors */); + XMP_Uns64 currSize = currBox.headerSize + currBox.contentSize; + + if ((currBox.boxType == ISOMedia::k_free) || + (currBox.boxType == ISOMedia::k_skip) || + ((boxPos == oldOffset) && (currSize == oldSize))) { + + if (spaceList->empty() || (boxPos != adjacentFree)) { + spaceList->push_back(SpaceInfo(boxPos, currSize)); + adjacentFree = boxPos + currSize; + } + else { + SpaceInfo * lastSpace = &spaceList->back(); + lastSpace->size += currSize; + } + + } + + } + +} // ISOBaseMedia_Manager::CreateFreeSpaceList + +// ================================================================================================= +// ISOBaseMedia_Manager::AddChildBox +// ========================= +ISOBaseMedia_Manager::BoxRef ISOBaseMedia_Manager::AddChildBox(BoxRef parentRef, XMP_Uns32 childType, const void* dataPtr, XMP_Uns32 size, const XMP_Uns8 * idUUID) +{ + BoxNode * parent = (BoxNode*)parentRef; + XMP_Assert(parent != 0); + + if (childType == ISOMedia::k_uuid && idUUID != 0) + parent->children.push_back(BoxNode(0, childType, 0, idUUID, 0)); + else + parent->children.push_back(BoxNode(0, childType, 0, 0)); + BoxNode * newNode = &parent->children.back(); + this->SetBox(newNode, dataPtr, size); + + return newNode; + +} // ISOBaseMedia_Manager::AddChildBox + + diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/ISOBaseMedia_Support.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/ISOBaseMedia_Support.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/ISOBaseMedia_Support.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/ISOBaseMedia_Support.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __ISOBaseMedia_Support_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2007 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2007 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. @@ -17,6 +17,8 @@ #include "XMPFiles/source/XMPFiles_Impl.hpp" +#include "source/XMLParserAdapter.hpp" +#include "source/ExpatAdapter.hpp" #include // ================================================================================================= @@ -42,6 +44,11 @@ ISOboxType(k_3g2a,0x33673261UL)SEPARATOR \ ISOboxType(k_3g2b,0x33673262UL)SEPARATOR \ ISOboxType(k_3g2c,0x33673263UL)SEPARATOR \ + ISOboxType(k_mif1,0x6d696631UL)SEPARATOR \ + ISOboxType(k_heic,0x68656963UL)SEPARATOR \ + ISOboxType(k_jpeg,0x6a706567UL)SEPARATOR \ + ISOboxType(k_heix,0x68656978UL)SEPARATOR \ + ISOboxType(k_avci,0x61766369UL)SEPARATOR \ \ ISOboxType(k_moov,0x6D6F6F76UL)SEPARATOR /* Container Box, no version/flags. */ \ ISOboxType(k_mvhd,0x6D766864UL)SEPARATOR /* Data FullBox, has version/flags. */ \ @@ -52,6 +59,7 @@ ISOboxType(k_free,0x66726565UL)SEPARATOR /* Free space Box, no version/flags.*/ \ ISOboxType(k_mdat,0x6D646174UL)SEPARATOR /* Media data Box, no version/flags.*/ \ \ + ISOboxType(k_xml,0x786D6C20UL)SEPARATOR /*xml box, has version/flags */ \ ISOboxType(k_trak,0x7472616BUL)SEPARATOR /* Types for the QuickTime timecode track.*/ \ ISOboxType(k_tkhd,0x746B6864UL)SEPARATOR \ ISOboxType(k_edts,0x65647473UL)SEPARATOR \ @@ -70,6 +78,8 @@ ISOboxType(k_dref,0x64726566UL)SEPARATOR \ ISOboxType(k_alis,0x616C6973UL)SEPARATOR \ \ + ISOboxType(k_keys,0x6B657973UL)SEPARATOR /* Type for the QuickTime metadata box containing keys related to metadata item.*/ \ + \ ISOboxType(k_meta,0x6D657461UL)SEPARATOR /* Types for the iTunes metadata boxes.*/ \ ISOboxType(k_ilst,0x696C7374UL)SEPARATOR \ ISOboxType(k_mdir,0x6D646972UL)SEPARATOR \ @@ -82,8 +92,23 @@ ISOboxType(k_wide,0x77696465UL)SEPARATOR \ ISOboxType(k_pnot,0x706E6F74UL)SEPARATOR \ \ + ISOboxType(k_iloc,0x696c6f63UL)SEPARATOR /*For HEIF files*/\ + ISOboxType(k_iinf,0x69696e66UL)SEPARATOR \ + ISOboxType(k_infe,0x696e6665UL)SEPARATOR \ + ISOboxType(k_idat,0x69646174UL)SEPARATOR \ + ISOboxType(k_pict,0x70696374UL)SEPARATOR \ + ISOboxType(k_url,0x75726c20UL)SEPARATOR \ + ISOboxType(k_urn,0x75726e20UL)SEPARATOR \ + ISOboxType(k_uri,0x75726920UL)SEPARATOR \ + ISOboxType(k_Exif,0x45786966UL)SEPARATOR \ + ISOboxType(k_mime,0x6d696d65UL)SEPARATOR \ + ISOboxType(k_iref,0x69726566UL)SEPARATOR \ + ISOboxType(k_pitm,0x7069746dUL)SEPARATOR \ + ISOboxType(k_cdsc,0x63647363UL)SEPARATOR \ + \ ISOboxType(k_XMP_,0x584D505FUL) /* The QuickTime variant XMP box.*/ + #define ISOBoxPrivateList #define ISOboxType(x,y) x=y #define SEPARATOR , @@ -94,7 +119,6 @@ #undef ISOboxType #undef SEPARATOR - bool IsKnownBoxType(XMP_Uns32 boxType) ; void TerminateGlobals(); @@ -124,6 +148,141 @@ } // namespace ISO_Media +// Same for moov(MOOV_Support.hpp) and meta box(Meta_Support.hpp) for now, +// If this changes in future then define this before this file is included. +#ifndef TopBoxSizeLimit + #define TopBoxSizeLimit 100*1024*1024 +#endif // ================================================================================================= +class ISOBaseMedia_Manager { +public: + virtual ~ISOBaseMedia_Manager(){} + typedef const void * BoxRef; // Valid until a sibling or higher box is added or deleted. + + struct BoxInfo { + XMP_Uns32 boxType; // In memory as native endian, compares work with ISOMedia::k_* constants. + XMP_Uns32 childCount; // ! A 'meta' box has both content (version/flags) and children! + XMP_Uns32 contentSize; // Does not include the size of nested boxes. + const XMP_Uns8 * content; // Null if contentSize is zero. + XMP_Uns8 idUUID[16]; // ID of the uuid atom if present + BoxInfo() : boxType(0), childCount(0), contentSize(0), content(0) + { + memset(idUUID, 0, 16); + }; + + }; +#pragma pack (push, 1) // ! These must match the file layout! + struct Content_hdlr { // An 'hdlr' box as defined by ISO 14496-12. Maps OK to the QuickTime box. + XMP_Uns32 versionFlags; // 0 + XMP_Uns32 preDef; // 4 + XMP_Uns32 handlerType; // 8 + XMP_Uns32 reserved[3]; // 12 + // Plus optional component name string, null terminated UTF-8. + }; // 24 +#pragma pack( pop ) + // --------------------------------------------------------------------------------------------- + // GetBox - Pick a box given a '/' separated list of box types. Picks the 1st of each type. + // GetBoxInfo - Get the info if we already have the ref. + // GetNthChild - Pick the overall n-th child of the parent, zero based. + // GetTypeChild - Pick the first child of the given type. + // GetParsedOffset - Get the box's offset in the parsed tree, 0 if changed since parsing. + // GetHeaderSize - Get the box's header size in the parsed tree, 0 if changed since parsing. + + //BoxRef GetBox(const char * boxPath, BoxInfo * info) const; + + void GetBoxInfo(const BoxRef ref, BoxInfo * info) const; + + BoxRef GetNthChild(BoxRef parentRef, size_t childIndex, BoxInfo * info) const; + BoxRef GetTypeChild(BoxRef parentRef, XMP_Uns32 childType, BoxInfo * info) const; + + XMP_Uns32 GetParsedOffset(BoxRef ref) const; + XMP_Uns32 GetHeaderSize(BoxRef ref) const; + + // --------------------------------------------------------------------------------------------- + // NoteChange - Note overall change, value was directly replaced. + virtual void NoteChange(); + + + // SetBox(ref) - Replace the content with a copy of the given data. + // SetBox(path) - Like above, but creating path to the box if necessary. + // AddChildBox - Add a child of the given type, using a copy of the given data (may be null) + void SetBox(BoxRef theBox, const void* dataPtr, XMP_Uns32 size, const XMP_Uns8 * idUUID = 0); + //void SetBox(const char * boxPath, const void* dataPtr, XMP_Uns32 size, const XMP_Uns8 * idUUID = 0); + + BoxRef AddChildBox(BoxRef parentRef, XMP_Uns32 childType, const void * dataPtr, XMP_Uns32 size, const XMP_Uns8 * idUUID = 0); + + // --------------------------------------------------------------------------------------------- + // DeleteNthChild - Delete the overall n-th child, return true if there was one. + // DeleteTypeChild - Delete the first child of the given type, return true if there was one. + + bool DeleteNthChild(BoxRef parentRef, size_t childIndex); + bool DeleteTypeChild(BoxRef parentRef, XMP_Uns32 childType); + + bool IsChanged() const { return this->subtreeRootNode.changed; }; + + struct SpaceInfo { + XMP_Uns64 offset, size; + SpaceInfo() : offset(0), size(0) {}; + SpaceInfo(XMP_Uns64 _offset, XMP_Uns64 _size) : offset(_offset), size(_size) {}; + }; + + typedef std::vector SpaceList; + + void CreateFreeSpaceList(XMP_IO* fileRef, XMP_Uns64 fileSize, + XMP_Uns64 oldOffset, XMP_Uns32 oldSize, SpaceList * spaceList); + + void WipeBoxFree(XMP_IO* fileRef, XMP_Uns64 boxOffset, XMP_Uns32 boxSize); + void WriteBoxHeader(XMP_IO* fileRef, XMP_Uns32 boxType, XMP_Uns64 boxSize); + + struct BoxNode; + typedef std::vector BoxList; + typedef BoxList::iterator BoxListPos; + + struct BoxNode { + // ! Don't have a parent link, it will get destroyed by vector growth! + + XMP_Uns32 offset; // The offset in the fullSubtree, 0 if not in the parse. + XMP_Uns32 boxType; + XMP_Uns32 headerSize; // The actual header size in the fullSubtree, 0 if not in the parse. + XMP_Uns32 contentSize; // The current content size, does not include nested boxes or id. + BoxList children; + XMP_Uns8 idUUID[16]; + RawDataBlock changedContent; // Might be empty even if changed is true. + bool changed; // If true, the content is in changedContent, else in fullSubtree. + + BoxNode() : offset(0), boxType(0), headerSize(0), contentSize(0), changed(false) + { + memset(idUUID, 0, 16); + }; + BoxNode(XMP_Uns32 _offset, XMP_Uns32 _boxType, XMP_Uns32 _headerSize, XMP_Uns32 _contentSize) + : offset(_offset), boxType(_boxType), headerSize(_headerSize), contentSize(_contentSize), changed(false) + { + memset(idUUID, 0, 16); + }; + BoxNode(XMP_Uns32 _offset, XMP_Uns32 _boxType, XMP_Uns32 _headerSize, const XMP_Uns8 * _idUUID, XMP_Uns32 _contentSize) + : offset(_offset), boxType(_boxType), headerSize(_headerSize), contentSize(_contentSize), changed(false) + { + memcpy(idUUID, _idUUID, 16); + }; + }; + BoxNode subtreeRootNode; + // subtree node + // --------------------------------------------------------------------------------------------- + // The client is expected to fill in fullSubtree before calling ParseMemoryTree, and directly + // use fullSubtree after calling UpdateMemoryTree. + // + // IMPORTANT: We only support cases where the subtree('moov' or 'meta') is significantly less than 4 GB, in + // particular with a threshold of probably 100 MB. This has 2 big impacts: we can safely use + // 32-bit offsets and sizes, and comfortably assume everything will fit in available heap space. + + RawDataBlock fullSubtree; // The entire box, straight from the file or from UpdateMemoryTree. + + //virtual void ParseMemoryTree(XMP_Uns8 fileMode) {} //make this virtual + //virtual void UpdateMemoryTree() {} + void FillBoxInfo(const BoxNode & node, BoxInfo * info) const; + XMP_Uns8 * PickContentPtr(const BoxNode & node) const; + +}; + #endif // __ISOBaseMedia_Support_hpp__ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/Makefile.am exempi-2.6.1/XMPFiles/source/FormatSupport/Makefile.am --- exempi-2.5.2/XMPFiles/source/FormatSupport/Makefile.am 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/Makefile.am 2021-11-18 03:53:54.000000000 +0000 @@ -61,6 +61,7 @@ SWF_Support.hpp SWF_Support.cpp\ XDCAM_Support.hpp XDCAM_Support.cpp\ TIFF_FileWriter.cpp XMPScanner.cpp \ + META_Support.cpp META_Support.hpp \ MOOV_Support.cpp MOOV_Support.hpp \ QuickTime_Support.cpp \ ASF_Support.hpp ASF_Support.cpp \ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/Makefile.in exempi-2.6.1/XMPFiles/source/FormatSupport/Makefile.in --- exempi-2.5.2/XMPFiles/source/FormatSupport/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -155,11 +155,11 @@ RIFF_Support.lo TIFF_Support.lo ISOBaseMedia_Support.lo \ PNG_Support.lo ReconcileLegacy.lo GIF_Support.lo \ SWF_Support.lo XDCAM_Support.lo TIFF_FileWriter.lo \ - XMPScanner.lo MOOV_Support.lo QuickTime_Support.lo \ - ASF_Support.lo TimeConversionUtils.lo AIFF/AIFFBehavior.lo \ - AIFF/AIFFMetadata.lo AIFF/AIFFReconcile.lo \ - IFF/ChunkController.lo IFF/Chunk.lo IFF/ChunkPath.lo \ - IFF/IChunkBehavior.lo WAVE/BEXTMetadata.lo \ + XMPScanner.lo META_Support.lo MOOV_Support.lo \ + QuickTime_Support.lo ASF_Support.lo TimeConversionUtils.lo \ + AIFF/AIFFBehavior.lo AIFF/AIFFMetadata.lo \ + AIFF/AIFFReconcile.lo IFF/ChunkController.lo IFF/Chunk.lo \ + IFF/ChunkPath.lo IFF/IChunkBehavior.lo WAVE/BEXTMetadata.lo \ WAVE/DISPMetadata.lo WAVE/WAVEBehavior.lo WAVE/Cr8rMetadata.lo \ WAVE/PrmLMetadata.lo WAVE/CartMetadata.lo WAVE/INFOMetadata.lo \ WAVE/WAVEReconcile.lo WAVE/iXMLMetadata.lo P2_Support.lo \ @@ -188,8 +188,9 @@ ./$(DEPDIR)/GIF_Support.Plo ./$(DEPDIR)/ID3_Support.Plo \ ./$(DEPDIR)/IPTC_Support.Plo \ ./$(DEPDIR)/ISOBaseMedia_Support.Plo \ - ./$(DEPDIR)/MOOV_Support.Plo ./$(DEPDIR)/P2_Support.Plo \ - ./$(DEPDIR)/PNG_Support.Plo ./$(DEPDIR)/PSIR_FileWriter.Plo \ + ./$(DEPDIR)/META_Support.Plo ./$(DEPDIR)/MOOV_Support.Plo \ + ./$(DEPDIR)/P2_Support.Plo ./$(DEPDIR)/PNG_Support.Plo \ + ./$(DEPDIR)/PSIR_FileWriter.Plo \ ./$(DEPDIR)/PSIR_MemoryReader.Plo \ ./$(DEPDIR)/PackageFormat_Support.Plo \ ./$(DEPDIR)/PostScript_Support.Plo \ @@ -413,6 +414,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -448,6 +450,7 @@ SWF_Support.hpp SWF_Support.cpp\ XDCAM_Support.hpp XDCAM_Support.cpp\ TIFF_FileWriter.cpp XMPScanner.cpp \ + META_Support.cpp META_Support.hpp \ MOOV_Support.cpp MOOV_Support.hpp \ QuickTime_Support.cpp \ ASF_Support.hpp ASF_Support.cpp \ @@ -580,6 +583,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ID3_Support.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IPTC_Support.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ISOBaseMedia_Support.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/META_Support.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MOOV_Support.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/P2_Support.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PNG_Support.Plo@am__quote@ # am--include-marker @@ -795,6 +799,7 @@ -rm -f ./$(DEPDIR)/ID3_Support.Plo -rm -f ./$(DEPDIR)/IPTC_Support.Plo -rm -f ./$(DEPDIR)/ISOBaseMedia_Support.Plo + -rm -f ./$(DEPDIR)/META_Support.Plo -rm -f ./$(DEPDIR)/MOOV_Support.Plo -rm -f ./$(DEPDIR)/P2_Support.Plo -rm -f ./$(DEPDIR)/PNG_Support.Plo @@ -884,6 +889,7 @@ -rm -f ./$(DEPDIR)/ID3_Support.Plo -rm -f ./$(DEPDIR)/IPTC_Support.Plo -rm -f ./$(DEPDIR)/ISOBaseMedia_Support.Plo + -rm -f ./$(DEPDIR)/META_Support.Plo -rm -f ./$(DEPDIR)/MOOV_Support.Plo -rm -f ./$(DEPDIR)/P2_Support.Plo -rm -f ./$(DEPDIR)/PNG_Support.Plo diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/META_Support.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/META_Support.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/META_Support.cpp 1970-01-01 00:00:00.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/META_Support.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -0,0 +1,352 @@ +// ================================================================================================= +// Copyright Adobe +// Copyright 2018 Adobe +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= +#include "XMPFiles/source/FormatSupport/META_Support.hpp" + +#include "XMPFiles/source/FormatSupport/ISOBaseMedia_Support.hpp" +#include + +// ================================================================================================= +// Meta_Manager::ParseMetaMemoryTree +// ============================== +void Meta_Manager::ParseMetaMemoryTree() { + //this->fileMode = _fileMode; + this->subtreeRootNode.offset = this->subtreeRootNode.boxType = 0; + this->subtreeRootNode.headerSize = this->subtreeRootNode.contentSize = 0; + this->subtreeRootNode.children.clear(); + this->subtreeRootNode.changedContent.clear(); + this->subtreeRootNode.changed = false; + + if (this->fullSubtree.empty()) return; + + ISOMedia::BoxInfo metaInfo; + const XMP_Uns8 * metaOrigin = &this->fullSubtree[0]; + const XMP_Uns8 * metaLimit = metaOrigin + this->fullSubtree.size(); + + (void)ISOMedia::GetBoxInfo(metaOrigin, metaLimit, &metaInfo); + XMP_Enforce(metaInfo.boxType == ISOMedia::k_meta); + + XMP_Uns64 fullMetaSize = metaInfo.headerSize + metaInfo.contentSize; + + if (fullMetaSize > TopBoxSizeLimit) { // From here on we know 32-bit offsets are safe. + XMP_Throw("Oversize 'meta' box", kXMPErr_EnforceFailure); + } + + this->subtreeRootNode.boxType = ISOMedia::k_meta; + this->subtreeRootNode.headerSize = metaInfo.headerSize; + this->subtreeRootNode.contentSize = (XMP_Uns32)metaInfo.contentSize; + + ///this->subtreeRootNode = BoxNode(0, metaInfo.boxType, metaInfo.headerSize, (XMP_Uns32)metaInfo.contentSize); + ParseNestedMetaBoxes(& (this->subtreeRootNode), "meta"); + +} + +// ================================================================================================= +// Meta_Manager::ParseNestedMetaBoxes +// ============================== +void Meta_Manager::ParseNestedMetaBoxes(BoxNode * parentNode, const std::string & parentPath) { + + + const XMP_Uns8 * metaOrigin = &this->fullSubtree[0]; + ISOMedia::BoxInfo isoInfo; + BoxInfo mmgrInfo; + + const XMP_Uns8 * childOrigin = metaOrigin + parentNode->offset + parentNode->headerSize; + const XMP_Uns8 * childLimit = childOrigin + parentNode->contentSize; + + const XMP_Uns8 * nextChild; + + parentNode->contentSize = 0; + + //meta box, iinf, dref is a full box + if (parentPath == "meta" || parentPath == "iref"){ + childOrigin += 4; parentNode->contentSize = 4; + } + else if (parentPath == "dref"){ + childOrigin += 8; // Adding size(4 bytes) of entry count + parentNode->contentSize = 8; + } + else if (parentPath == "iinf") { + if(childOrigin[0] == 0){ + childOrigin += 6; // 2 bytes in iinf box are for entry count + parentNode->contentSize = 6; + } + else { + childOrigin += 8; // 4 bytes in iinf box are for entry count + parentNode->contentSize = 8; + } + + } + + for (const XMP_Uns8 * currChild = childOrigin; currChild < childLimit; currChild = nextChild) { + nextChild = ISOMedia::GetBoxInfo(currChild, childLimit, &isoInfo); + if ((isoInfo.headerSize < 8) && + (isoInfo.contentSize == 0)) continue; + + XMP_Uns32 childOffset = (XMP_Uns32)(currChild - metaOrigin); + + //currently no uuid box is used in HEIF files + if (isoInfo.boxType == ISOMedia::k_uuid) + parentNode->children.push_back(BoxNode(childOffset, isoInfo.boxType, isoInfo.headerSize, (XMP_Uns8 *)isoInfo.idUUID, (XMP_Uns32)isoInfo.contentSize)); + else + parentNode->children.push_back(BoxNode(childOffset, isoInfo.boxType, isoInfo.headerSize, (XMP_Uns32)isoInfo.contentSize)); + BoxNode * newChild = &parentNode->children.back(); + + switch (isoInfo.boxType) { + + case ISOMedia::k_iinf: this->ParseNestedMetaBoxes(newChild, "iinf"); break; + case ISOMedia::k_dinf: this->ParseNestedMetaBoxes(newChild, "dinf"); break; + case ISOMedia::k_dref: this->ParseNestedMetaBoxes(newChild, "dref"); break; + case ISOMedia::k_iref: this->ParseNestedMetaBoxes(newChild, "iref"); break; + } + + + } +} + +// Find a box given the type path. Pick the first child of each type. +ISOBaseMedia_Manager::BoxRef Meta_Manager::GetBox(const char * boxPath, BoxInfo * info) const +{ + size_t pathLen = strlen(boxPath); + XMP_Assert((pathLen >= 4) && XMP_LitNMatch(boxPath, "meta", 4)); + if (info != 0) memset(info, 0, sizeof(BoxInfo)); + + const char * pathPtr = boxPath + 5; // Skip the "meta/" portion. + const char * pathEnd = boxPath + pathLen; + + BoxRef currRef = &this->subtreeRootNode; + + while (pathPtr < pathEnd) { + + XMP_Assert((pathEnd - pathPtr) >= 4); + XMP_Uns32 boxType = GetUns32BE(pathPtr); + pathPtr += 5; // ! Don't care that the last step goes 1 too far. + + currRef = this->GetTypeChild(currRef, boxType, 0); + if (currRef == 0) return 0; + + } + + this->FillBoxInfo(*((BoxNode*)currRef), info); + return currRef; + +} + +// ================================================================================================= +// Meta_Manager::NewSubtreeSize +// ============================ +// +// Determine the new (changed) size of a subtree. Ignore 'free' and 'wide' boxes. +XMP_Uns32 Meta_Manager::NewSubtreeSize(const BoxNode & node, const std::string & parentPath) +{ + XMP_Uns32 subtreeSize; + if (node.contentSize != 0) + subtreeSize = 8 + node.contentSize; // All boxes will have 8 byte headers. + else + subtreeSize = 8; + + if (node.boxType == ISOMedia::k_uuid) + subtreeSize += 16; // id of uuid is 16 bytes long + + + for (size_t i = 0, limit = node.children.size(); i < limit; ++i) { + + char suffix[6]; + suffix[0] = '/'; + PutUns32BE(node.boxType, &suffix[1]); + suffix[5] = 0; + std::string nodePath = parentPath + suffix; + + subtreeSize += this->NewSubtreeSize(node.children[i], nodePath); + XMP_Enforce(subtreeSize < TopBoxSizeLimit); + + } + + return subtreeSize; + +}// Meta_Manager::NewSubtreeSize + +// ================================================================================================= +// Meta_Manager::UpdateMemoryTree +// ============================== +void Meta_Manager::UpdateMemoryTree() +{ + if (!this->IsChanged()) return; + + XMP_Uns32 newSize = this->NewSubtreeSize(this->subtreeRootNode, ""); + XMP_Enforce(newSize < TopBoxSizeLimit); + + RawDataBlock newData; + newData.assign(newSize, 0); // Prefill with zeroes, can't append multiple items to a vector. + + XMP_Uns8 * newPtr = &newData[0]; + XMP_Uns8 * newEnd = newPtr + newSize; + + XMP_Uns8 * trueEnd = this->AppendNewSubtree(this->subtreeRootNode, "", newPtr, newEnd); //meta is a fullbox + XMP_Enforce(trueEnd == newEnd); + + this->fullSubtree.swap(newData); + this->ParseMetaMemoryTree(); + +} // Meta_Manager::UpdateMemoryTree + +#define IncrNewPtr(count) { newPtr += count; XMP_Enforce ( newPtr <= newEnd ); } + +XMP_Uns8 * Meta_Manager::AppendNewSubtree(const BoxNode & node, const std::string & parentPath, + XMP_Uns8 * newPtr, XMP_Uns8 * newEnd) +{ + + /*XMP_Assert ( (node.boxType != ISOMedia::k_meta) ? (node.children.empty() || (node.contentSize == 0)) : + (node.children.empty() || (node.contentSize == 4)) );*/ + + XMP_Enforce((XMP_Uns32)(newEnd - newPtr) >= (8 + node.contentSize)); + + //XMP_Uns8 * ilocOrigin; + + // Leave the size as 0 for now, append the type and content. + XMP_Uns8 * boxOrigin = newPtr; // Save origin to fill in the final size. + PutUns32BE(node.boxType, (newPtr + 4)); + IncrNewPtr(8); + if (node.boxType == ISOMedia::k_uuid) // For uuid, additional 16 bytes is stored for ID + { + XMP_Enforce((XMP_Uns32)(newEnd - newPtr) >= (16 + node.contentSize)); + memcpy(newPtr, node.idUUID, 16); + IncrNewPtr(16); + } + /*if (node.boxType == ISOMedia::k_iloc) + ilocOrigin = newPtr;*/ + + if (node.contentSize != 0 ) { + const XMP_Uns8 * content = PickContentPtr(node); + memcpy(newPtr, content, node.contentSize); + IncrNewPtr(node.contentSize); + } + + // Append the nested boxes. + + if (!node.children.empty()) { + + char suffix[6]; + suffix[0] = '/'; + PutUns32BE(node.boxType, &suffix[1]); + suffix[5] = 0; + std::string nodePath = parentPath + suffix; + + for (size_t i = 0, limit = node.children.size(); i < limit; ++i) { + newPtr = this->AppendNewSubtree(node.children[i], nodePath, newPtr, newEnd); + } + + } + + // Fill in the final size. + + PutUns32BE((XMP_Uns32)(newPtr - boxOrigin), boxOrigin); + //ilocOfset = (XMP_Uns32)(ilocOrigin - boxOrigin); + return newPtr; + +} // MOOV_Manager::AppendNewSubtree + +// ================================================================================================= +// Meta_Manager::UpdateIlocBoxContent +// ============================== +void Meta_Manager::UpdateIlocBoxContent() { + ISOBaseMedia_Manager::BoxInfo ilocInfo; + ISOBaseMedia_Manager::BoxRef ilocRef = this->GetTypeChild(&subtreeRootNode, ISOMedia::k_iloc, &ilocInfo); + + ISOBaseMedia_Manager::BoxNode * ilocNode = (ISOBaseMedia_Manager::BoxNode*)ilocRef; + + XMP_Uns8 ilocVersion = ilocInfo.content[0]; + if (ilocVersion > 2) //other versions not allowed + return; + + // To know the size of changed content + XMP_Uns32 newSize = 0; + if (ilocVersion < 2) + newSize += 8; + else + newSize += 10; + + for (auto const& itr : itemLocationMap) + { + newSize += itr.second.sizeOfItem; + } + ilocNode->changedContent.assign(newSize, 0); + memcpy(&(ilocNode->changedContent[0]), ilocInfo.content, ilocInfo.contentSize); + + XMP_Uns32 vecIndex = 4;//iloc is a FullBox + //XMP_Uns16 sizeValue = GetUns16BE(ilocInfo.content + 4); + vecIndex += 2; //sizeValue bytes + + if (ilocVersion < 2) { + PutUns16BE((XMP_Uns16)itemLocationMap.size(),&( ilocNode->changedContent[vecIndex])); + vecIndex += 2; + + } + else { + PutUns32BE((XMP_Uns32)itemLocationMap.size(), &(ilocNode->changedContent[vecIndex])); + vecIndex += 4; + } + + bool flag = 0; + for (auto const& itr : itemLocationMap) + { + ilocItem currItem = itr.second; + if (!currItem.changed && flag == 0) { + //memcpy(&(ilocNode->changedContent[vecIndex]), ilocInfo.content + vec, currItem.sizeOfItem); + vecIndex += currItem.sizeOfItem; + continue; + } + flag = 1; + if (ilocVersion < 2) { + XMP_Uns16 itemId = (XMP_Uns16)itr.first; + PutUns16BE(itemId, &(ilocNode->changedContent[vecIndex])); + vecIndex += 2; + } + else if (ilocVersion == 2) { + XMP_Uns32 itemId = itr.first; + PutUns32BE(itemId, &(ilocNode->changedContent[vecIndex])); + vecIndex += 4; + } + if (ilocVersion == 1 || ilocVersion == 2) { + XMP_Uns16 res = 0; + res &= 0xFFF0; + res |= (currItem.constructionMethod & 0x000F); + PutUns16BE(res, &(ilocNode->changedContent[vecIndex])); + vecIndex += 2;// reserved + construction method = 0 + } + PutUns16BE(0, &(ilocNode->changedContent[vecIndex])); //data refrence index + vecIndex += 2; + + + if (ilocByteSizesStruct.baseOffsetSize == 32) { PutUns32BE(0, &(ilocNode->changedContent[vecIndex])); vecIndex += 4; } + else if (ilocByteSizesStruct.baseOffsetSize == 64) { PutUns64BE(0, &(ilocNode->changedContent[vecIndex])); vecIndex += 8; } + XMP_Uns16 nExtents = (XMP_Uns16)currItem.iExtents.size(); + PutUns16BE(nExtents , &(ilocNode->changedContent[vecIndex])); + vecIndex += 2; + + for (size_t j = 0; j < nExtents; j++) { + extent ex = currItem.iExtents[j]; + + if ((ilocVersion == 1 || ilocVersion == 2) && ilocByteSizesStruct.indexSize > 0) { // part4 = index_size // && byteSizes.part4 > 0 + if (ilocByteSizesStruct.indexSize == 32) { PutUns32BE((XMP_Uns32)ex.extent_index, &(ilocNode->changedContent[vecIndex])); vecIndex += 4; } + else if (ilocByteSizesStruct.indexSize == 64) { PutUns64BE(ex.extent_index, &(ilocNode->changedContent[vecIndex])); vecIndex += 8; } + } + + if (ilocByteSizesStruct.offsetSize == 32) { PutUns32BE((XMP_Uns32)ex.extent_offset, &(ilocNode->changedContent[vecIndex])); vecIndex += 4; } + else if (ilocByteSizesStruct.offsetSize == 64) { PutUns64BE(ex.extent_offset, &(ilocNode->changedContent[vecIndex])); vecIndex += 8; } + + if (ilocByteSizesStruct.lengthSize == 32) { PutUns32BE((XMP_Uns32)ex.extent_length, &(ilocNode->changedContent[vecIndex])); vecIndex += 4; } + else if (ilocByteSizesStruct.lengthSize == 64) { PutUns64BE(ex.extent_length, &(ilocNode->changedContent[vecIndex])); vecIndex += 8; } + } + } + + ilocNode->changed = true; + ilocNode->contentSize = newSize; + NoteChange(); +} + diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/META_Support.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/META_Support.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/META_Support.hpp 1970-01-01 00:00:00.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/META_Support.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -0,0 +1,101 @@ +#ifndef __META_Support_hpp__ +#define __META_Support_hpp__ 1 +// ================================================================================================= +// Copyright Adobe +// Copyright 2018 Adobe +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +#include "public/include/XMP_Environment.h" // ! This must be the first include. +#include "public/include/XMP_Const.h" + +#include "source/EndianUtils.hpp" + +#include "XMPFiles/source/XMPFiles_Impl.hpp" +#include "XMPFiles/source/FormatSupport/ISOBaseMedia_Support.hpp" + +#include +#include +#include +#include + + +class Meta_Manager : public ISOBaseMedia_Manager { +public: + //only version 2 and 3 allowed + struct itemInfoEntry { + + // version 2 has item id of 16 bits, version 3 has item id of 32 bits + // So taking type XMP_Uns32 + // itemID=0 means Primary item, but we are not bothered with it, so we can initialize it with 0 + XMP_Uns32 itemID; + XMP_Uns16 itemProtectionIndex; + XMP_Uns32 itemType; + std::string itemName; + // required when itemType='mime' + std::string contentType, contenEncoding; + // required when itemType='uri' + std::string itemUriType; + XMP_Uns8 version; // version of infeBox + + itemInfoEntry() :itemID(0), itemProtectionIndex(0), itemType(0), version(0) {}; + }; + + std::vector itemInfoEntryList; + + struct extent { + XMP_Uns64 extent_index; // Reqd for construction method = 2 | 0 is reserved, starts from 1 + XMP_Uns64 extent_offset; // file offset based on construction method + XMP_Uns64 extent_length; + XMP_Uns64 relativeOffsetInData; // =0 for only 1 extent in iloc item + + extent() :extent_index(0), extent_offset(0), extent_length(0){}; + }; + struct ilocItem { + XMP_Uns8 constructionMethod; //In version 1 and 2 + XMP_Uns16 dataReferenceIndex; + std::vector iExtents; + bool changed; + XMP_Uns32 sizeOfItem; + ilocItem() : constructionMethod(0), dataReferenceIndex(0),changed(false), sizeOfItem(0){}; + }; + + struct { + size_t offsetSize; + size_t baseOffsetSize; + size_t lengthSize; + size_t indexSize; + } ilocByteSizesStruct; + + // Considering Item Id to be unique here + std::map itemLocationMap; + + typedef std::map> ExtentIDMap; + + // unordered_map of + typedef std::unordered_map> RelatedItemsMap; + typedef std::unordered_map ItemReferenceTypeMap; + ItemReferenceTypeMap irefBox; + + void ParseMetaMemoryTree(); + BoxRef GetBox(const char * boxPath, BoxInfo * info) const; + + BoxNode metaNode; + + std::set traversed; + + void UpdateMemoryTree(); + void UpdateIlocBoxContent(); +private: + + void ParseNestedMetaBoxes(BoxNode * parentNode, const std::string & parentPath); + XMP_Uns32 NewSubtreeSize(const BoxNode & node, const std::string & parentPath); + XMP_Uns8 * AppendNewSubtree(const BoxNode & node, const std::string & parentPath, + XMP_Uns8 * newPtr, XMP_Uns8 * newEnd); +}; + + +#endif diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/MOOV_Support.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/MOOV_Support.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/MOOV_Support.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/MOOV_Support.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,12 +1,21 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2009 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2009 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= +#ifndef TraceParseMoovTree +#define TraceParseMoovTree 0 +#endif + +#ifndef TraceUpdateMoovTree +#define TraceUpdateMoovTree 0 +#endif + + #include "XMPFiles/source/FormatSupport/MOOV_Support.hpp" #include "XMPFiles/source/FormatSupport/ISOBaseMedia_Support.hpp" @@ -24,56 +33,6 @@ // ================================================================================================= // ================================================================================================= -#ifndef TraceParseMoovTree - #define TraceParseMoovTree 0 -#endif - -#ifndef TraceUpdateMoovTree - #define TraceUpdateMoovTree 0 -#endif - -// ================================================================================================= -// MOOV_Manager::PickContentPtr -// ============================ - -XMP_Uns8 * MOOV_Manager::PickContentPtr ( const BoxNode & node ) const -{ - if ( node.contentSize == 0 ) { - return 0; - } else if ( node.changed ) { - return (XMP_Uns8*) &node.changedContent[0]; - } else { - return (XMP_Uns8*) &this->fullSubtree[0] + node.offset + node.headerSize; - } -} // MOOV_Manager::PickContentPtr - -// ================================================================================================= -// MOOV_Manager::FillBoxInfo -// ========================= - -void MOOV_Manager::FillBoxInfo ( const BoxNode & node, BoxInfo * info ) const -{ - if ( info == 0 ) return; - - info->boxType = node.boxType; - info->childCount = (XMP_Uns32)node.children.size(); - info->contentSize = node.contentSize; - info->content = PickContentPtr ( node ); - if( node.boxType == ISOMedia::k_uuid ) - memcpy( info->idUUID, node.idUUID, 16); - -} // MOOV_Manager::FillBoxInfo - -// ================================================================================================= -// MOOV_Manager::GetBoxInfo -// ========================= - -void MOOV_Manager::GetBoxInfo ( const BoxRef ref, BoxInfo * info ) const -{ - - this->FillBoxInfo ( *((BoxNode*)ref), info ); - -} // MOOV_Manager::GetBoxInfo // ================================================================================================= // MOOV_Manager::GetBox @@ -90,7 +49,7 @@ const char * pathPtr = boxPath + 5; // Skip the "moov/" portion. const char * pathEnd = boxPath + pathLen; - BoxRef currRef = &this->moovNode; + BoxRef currRef = &this->subtreeRootNode; while ( pathPtr < pathEnd ) { @@ -108,76 +67,6 @@ } // MOOV_Manager::GetBox -// ================================================================================================= -// MOOV_Manager::GetNthChild -// ========================= - -MOOV_Manager::BoxRef MOOV_Manager::GetNthChild ( BoxRef parentRef, size_t childIndex, BoxInfo * info ) const -{ - XMP_Assert ( parentRef != 0 ); - const BoxNode & parent = *((BoxNode*)parentRef); - if ( info != 0 ) memset ( info, 0, sizeof(BoxInfo) ); - - if ( childIndex >= parent.children.size() ) return 0; - - const BoxNode & currNode = parent.children[childIndex]; - - this->FillBoxInfo ( currNode, info ); - return &currNode; - -} // MOOV_Manager::GetNthChild - -// ================================================================================================= -// MOOV_Manager::GetTypeChild -// ========================== - -MOOV_Manager::BoxRef MOOV_Manager::GetTypeChild ( BoxRef parentRef, XMP_Uns32 childType, BoxInfo * info ) const -{ - XMP_Assert ( parentRef != 0 ); - const BoxNode & parent = *((BoxNode*)parentRef); - if ( info != 0 ) memset ( info, 0, sizeof(BoxInfo) ); - if ( parent.children.empty() ) return 0; - - size_t i = 0, limit = parent.children.size(); - for ( ; i < limit; ++i ) { - const BoxNode & currNode = parent.children[i]; - if ( currNode.boxType == childType ) { - this->FillBoxInfo ( currNode, info ); - return &currNode; - } - } - - return 0; - -} // MOOV_Manager::GetTypeChild - -// ================================================================================================= -// MOOV_Manager::GetParsedOffset -// ============================= - -XMP_Uns32 MOOV_Manager::GetParsedOffset ( BoxRef ref ) const -{ - XMP_Assert ( ref != 0 ); - const BoxNode & node = *((BoxNode*)ref); - - if ( node.changed ) return 0; - return node.offset; - -} // MOOV_Manager::GetParsedOffset - -// ================================================================================================= -// MOOV_Manager::GetHeaderSize -// =========================== - -XMP_Uns32 MOOV_Manager::GetHeaderSize ( BoxRef ref ) const -{ - XMP_Assert ( ref != 0 ); - const BoxNode & node = *((BoxNode*)ref); - - if ( node.changed ) return 0; - return node.headerSize; - -} // MOOV_Manager::GetHeaderSize // ================================================================================================= // MOOV_Manager::ParseMemoryTree @@ -186,15 +75,15 @@ // Parse the fullSubtree data, building the BoxNode tree for the stuff that we care about. Tolerate // errors like content ending too soon, make a best effoert to parse what we can. -void MOOV_Manager::ParseMemoryTree ( XMP_Uns8 fileMode1 ) +void MOOV_Manager::ParseMemoryTree ( XMP_Uns8 _fileMode ) { - this->fileMode = fileMode1; + this->fileMode = _fileMode; - this->moovNode.offset = this->moovNode.boxType = 0; - this->moovNode.headerSize = this->moovNode.contentSize = 0; - this->moovNode.children.clear(); - this->moovNode.changedContent.clear(); - this->moovNode.changed = false; + this->subtreeRootNode.offset = this->subtreeRootNode.boxType = 0; + this->subtreeRootNode.headerSize = this->subtreeRootNode.contentSize = 0; + this->subtreeRootNode.children.clear(); + this->subtreeRootNode.changedContent.clear(); + this->subtreeRootNode.changed = false; if ( this->fullSubtree.empty() ) return; @@ -206,20 +95,20 @@ XMP_Enforce ( moovInfo.boxType == ISOMedia::k_moov ); XMP_Uns64 fullMoovSize = moovInfo.headerSize + moovInfo.contentSize; - if ( fullMoovSize > moovBoxSizeLimit ) { // From here on we know 32-bit offsets are safe. + if ( fullMoovSize > TopBoxSizeLimit) { // From here on we know 32-bit offsets are safe. XMP_Throw ( "Oversize 'moov' box", kXMPErr_EnforceFailure ); } - this->moovNode.boxType = ISOMedia::k_moov; - this->moovNode.headerSize = moovInfo.headerSize; - this->moovNode.contentSize = (XMP_Uns32)moovInfo.contentSize; + this->subtreeRootNode.boxType = ISOMedia::k_moov; + this->subtreeRootNode.headerSize = moovInfo.headerSize; + this->subtreeRootNode.contentSize = (XMP_Uns32)moovInfo.contentSize; - bool ignoreMetaBoxes = (fileMode1 == kFileIsTraditionalQT); // ! Don't want, these don't follow ISO spec. + bool ignoreMetaBoxes = (_fileMode == kFileIsTraditionalQT); // ! Don't want, these don't follow ISO spec. #if TraceParseMoovTree - fprintf ( stderr, "Parsing 'moov' subtree, moovNode @ 0x%X, ignoreMetaBoxes = %d\n", - &this->moovNode, ignoreMetaBoxes ); + fprintf ( stderr, "Parsing 'moov' subtree, subtreeRootNode @ 0x%X, ignoreMetaBoxes = %d\n", + &this->subtreeRootNode, ignoreMetaBoxes ); #endif - this->ParseNestedBoxes ( &this->moovNode, "moov", ignoreMetaBoxes ); + this->ParseNestedBoxes ( &this->subtreeRootNode, "moov", ignoreMetaBoxes ); } // MOOV_Manager::ParseMemoryTree @@ -238,7 +127,8 @@ const XMP_Uns8 * nextChild; parentNode->contentSize = 0; // Exclude nested box size. - if ( parentNode->boxType == ISOMedia::k_meta ) { // ! The 'meta' box is a FullBox. + + if ( parentNode->boxType == ISOMedia::k_meta && parentPath != "moov/meta") { // ! The 'meta' box is a FullBox. parentNode->contentSize = 4; childOrigin += 4; } @@ -288,64 +178,8 @@ } // MOOV_Manager::ParseNestedBoxes -// ================================================================================================= -// MOOV_Manager::NoteChange -// ======================== - -void MOOV_Manager::NoteChange() -{ - this->moovNode.changed = true; -} // MOOV_Manager::NoteChange - -// ================================================================================================= -// MOOV_Manager::SetBox -// ==================== -// -// Save the new data, set this box's changed flag, and set the top changed flag. - -void MOOV_Manager::SetBox ( BoxRef theBox, const void* dataPtr, XMP_Uns32 size , const XMP_Uns8 * idUUID ) -{ - XMP_Enforce ( size < moovBoxSizeLimit ); - BoxNode * node = (BoxNode*)theBox; - - if ( node->contentSize == size ) { - if( node->boxType == ISOMedia::k_uuid && idUUID != 0 ) - { - memcpy ( node->idUUID, idUUID, 16 ); - this->moovNode.changed = true; - } - XMP_Uns8 * oldContent = PickContentPtr ( *node ); - if ( memcmp ( oldContent, dataPtr, size ) == 0 ) return; // No change. - memcpy ( oldContent, dataPtr, size ); // Update the old content in-place - this->moovNode.changed = true; - - #if TraceUpdateMoovTree - XMP_Uns32 be32 = MakeUns32BE ( node->boxType ); - fprintf ( stderr, "Updated '%.4s', parse offset 0x%X, same size\n", &be32, node->offset ); - #endif - - } else { - - node->changedContent.assign ( size, 0 ); // Fill with 0's first to get the storage. - memcpy ( &node->changedContent[0], dataPtr, size ); - node->contentSize = size; - node->changed = true; - if( node->boxType == ISOMedia::k_uuid && idUUID != 0) - memcpy ( node->idUUID, idUUID, 16 ); - this->moovNode.changed = true; - - #if TraceUpdateMoovTree - XMP_Uns32 be32 = MakeUns32BE ( node->boxType ); - XMP_Uns32 addr32 = (XMP_Uns32) this->PickContentPtr ( *node ); - fprintf ( stderr, "Updated '%.4s', parse offset 0x%X, new size %d, new content @ 0x%X\n", - &be32, node->offset, node->contentSize, addr32 ); - #endif - - } - -} // MOOV_Manager::SetBox // ================================================================================================= // MOOV_Manager::SetBox @@ -355,7 +189,7 @@ void MOOV_Manager::SetBox ( const char * boxPath, const void* dataPtr, XMP_Uns32 size , const XMP_Uns8 * idUUID ) { - XMP_Enforce ( size < moovBoxSizeLimit ); + XMP_Enforce ( size < TopBoxSizeLimit); size_t pathLen = strlen(boxPath); XMP_Assert ( (pathLen >= 4) && XMP_LitNMatch ( boxPath, "moov", 4 ) ); @@ -364,7 +198,7 @@ const char * pathEnd = boxPath + pathLen; BoxRef parentRef = 0; - BoxRef currRef = &this->moovNode; + BoxRef currRef = &this->subtreeRootNode; while ( pathPtr < pathEnd ) { @@ -378,67 +212,10 @@ } - this->SetBox ( currRef, dataPtr, size, idUUID ); + this->ISOBaseMedia_Manager::SetBox ( currRef, dataPtr, size, idUUID ); } // MOOV_Manager::SetBox -// ================================================================================================= -// MOOV_Manager::AddChildBox -// ========================= - -MOOV_Manager::BoxRef MOOV_Manager::AddChildBox ( BoxRef parentRef, XMP_Uns32 childType, const void* dataPtr, XMP_Uns32 size , const XMP_Uns8 * idUUID ) -{ - BoxNode * parent = (BoxNode*)parentRef; - XMP_Assert ( parent != 0 ); - - if( childType == ISOMedia::k_uuid && idUUID != 0) - parent->children.push_back ( BoxNode ( 0, childType, 0, idUUID, 0 ) ); - else - parent->children.push_back ( BoxNode ( 0, childType, 0, 0 ) ); - BoxNode * newNode = &parent->children.back(); - this->SetBox ( newNode, dataPtr, size ); - - return newNode; - -} // MOOV_Manager::AddChildBox - -// ================================================================================================= -// MOOV_Manager::DeleteNthChild -// ============================ - -bool MOOV_Manager::DeleteNthChild ( BoxRef parentRef, size_t childIndex ) -{ - BoxNode * parent = (BoxNode*)parentRef; - - if ( childIndex >= parent->children.size() ) return false; - - parent->children.erase ( parent->children.begin() + childIndex ); - return true; - -} // MOOV_Manager::DeleteNthChild - -// ================================================================================================= -// MOOV_Manager::DeleteTypeChild -// ============================= - -bool MOOV_Manager::DeleteTypeChild ( BoxRef parentRef, XMP_Uns32 childType ) -{ - BoxNode * parent = (BoxNode*)parentRef; - - BoxListPos child = parent->children.begin(); - BoxListPos limit = parent->children.end(); - - for ( ; child != limit; ++child ) { - if ( child->boxType == childType ) { - parent->children.erase ( child ); - this->moovNode.changed = true; - return true; - } - } - - return false; - -} // MOOV_Manager::DeleteTypeChild // ================================================================================================= // MOOV_Manager::NewSubtreeSize @@ -464,7 +241,7 @@ std::string nodePath = parentPath + suffix; subtreeSize += this->NewSubtreeSize ( node.children[i], nodePath ); - XMP_Enforce ( subtreeSize < moovBoxSizeLimit ); + XMP_Enforce ( subtreeSize < TopBoxSizeLimit); } @@ -491,8 +268,8 @@ if ( (node.boxType == ISOMedia::k_free) || (node.boxType == ISOMedia::k_wide) ) { } - XMP_Assert ( (node.boxType != ISOMedia::k_meta) ? (node.children.empty() || (node.contentSize == 0)) : - (node.children.empty() || (node.contentSize == 4)) ); + /*XMP_Assert ( (node.boxType != ISOMedia::k_meta) ? (node.children.empty() || (node.contentSize == 0)) : + (node.children.empty() || (node.contentSize == 4)) );*/ XMP_Enforce ( (XMP_Uns32)(newEnd - newPtr) >= (8 + node.contentSize) ); @@ -553,8 +330,8 @@ { if ( ! this->IsChanged() ) return; - XMP_Uns32 newSize = this->NewSubtreeSize ( this->moovNode, "" ); - XMP_Enforce ( newSize < moovBoxSizeLimit ); + XMP_Uns32 newSize = this->NewSubtreeSize ( this->subtreeRootNode, "" ); + XMP_Enforce ( newSize < TopBoxSizeLimit); RawDataBlock newData; newData.assign ( newSize, 0 ); // Prefill with zeroes, can't append multiple items to a vector. @@ -567,7 +344,7 @@ newOrigin = newPtr; #endif - XMP_Uns8 * trueEnd = this->AppendNewSubtree ( this->moovNode, "", newPtr, newEnd ); + XMP_Uns8 * trueEnd = this->AppendNewSubtree ( this->subtreeRootNode, "", newPtr, newEnd ); XMP_Enforce ( trueEnd == newEnd ); this->fullSubtree.swap ( newData ); diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/MOOV_Support.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/MOOV_Support.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/MOOV_Support.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/MOOV_Support.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __MOOV_Support_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2009 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2009 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. @@ -16,16 +16,16 @@ #include "source/EndianUtils.hpp" #include "XMPFiles/source/XMPFiles_Impl.hpp" - +#include "XMPFiles/source/FormatSupport/ISOBaseMedia_Support.hpp" #include -#define moovBoxSizeLimit 100*1024*1024 +#define TopBoxSizeLimit 100*1024*1024 // ================================================================================================= // MOOV_Manager // ============ -class MOOV_Manager { +class MOOV_Manager : public ISOBaseMedia_Manager { public: // --------------------------------------------------------------------------------------------- @@ -37,71 +37,23 @@ kFileIsTraditionalQT = 2 // Old QuickTime, no 'ftyp' box. }; - typedef const void * BoxRef; // Valid until a sibling or higher box is added or deleted. - - struct BoxInfo { - XMP_Uns32 boxType; // In memory as native endian, compares work with ISOMedia::k_* constants. - XMP_Uns32 childCount; // ! A 'meta' box has both content (version/flags) and children! - XMP_Uns32 contentSize; // Does not include the size of nested boxes. - const XMP_Uns8 * content; // Null if contentSize is zero. - XMP_Uns8 idUUID[16]; // ID of the uuid atom if present - BoxInfo() : boxType(0), childCount(0), contentSize(0), content(0) - { - memset ( idUUID ,0, 16 ); - }; - }; + // --------------------------------------------------------------------------------------------- // GetBox - Pick a box given a '/' separated list of box types. Picks the 1st of each type. - // GetBoxInfo - Get the info if we already have the ref. - // GetNthChild - Pick the overall n-th child of the parent, zero based. - // GetTypeChild - Pick the first child of the given type. - // GetParsedOffset - Get the box's offset in the parsed tree, 0 if changed since parsing. - // GetHeaderSize - Get the box's header size in the parsed tree, 0 if changed since parsing. BoxRef GetBox ( const char * boxPath, BoxInfo * info ) const; - void GetBoxInfo ( const BoxRef ref, BoxInfo * info ) const; - - BoxRef GetNthChild ( BoxRef parentRef, size_t childIndex, BoxInfo * info ) const; - BoxRef GetTypeChild ( BoxRef parentRef, XMP_Uns32 childType, BoxInfo * info ) const; - - XMP_Uns32 GetParsedOffset ( BoxRef ref ) const; - XMP_Uns32 GetHeaderSize ( BoxRef ref ) const; // --------------------------------------------------------------------------------------------- // NoteChange - Note overall change, value was directly replaced. - // SetBox(ref) - Replace the content with a copy of the given data. // SetBox(path) - Like above, but creating path to the box if necessary. - // AddChildBox - Add a child of the given type, using a copy of the given data (may be null) - - void NoteChange(); - void SetBox ( BoxRef theBox, const void* dataPtr, XMP_Uns32 size , const XMP_Uns8 * idUUID = 0 ); void SetBox ( const char * boxPath, const void* dataPtr, XMP_Uns32 size , const XMP_Uns8 * idUUID = 0 ); - BoxRef AddChildBox ( BoxRef parentRef, XMP_Uns32 childType, const void * dataPtr, XMP_Uns32 size , const XMP_Uns8 * idUUID = 0 ); - - // --------------------------------------------------------------------------------------------- - // DeleteNthChild - Delete the overall n-th child, return true if there was one. - // DeleteTypeChild - Delete the first child of the given type, return true if there was one. - - bool DeleteNthChild ( BoxRef parentRef, size_t childIndex ); - bool DeleteTypeChild ( BoxRef parentRef, XMP_Uns32 childType ); // --------------------------------------------------------------------------------------------- - bool IsChanged() const { return this->moovNode.changed; }; - - // --------------------------------------------------------------------------------------------- - // The client is expected to fill in fullSubtree before calling ParseMemoryTree, and directly - // use fullSubtree after calling UpdateMemoryTree. - // - // IMPORTANT: We only support cases where the 'moov' subtree is significantly less than 4 GB, in - // particular with a threshold of probably 100 MB. This has 2 big impacts: we can safely use - // 32-bit offsets and sizes, and comfortably assume everything will fit in available heap space. - - RawDataBlock fullSubtree; // The entire 'moov' box, straight from the file or from UpdateMemoryTree. void ParseMemoryTree ( XMP_Uns8 fileMode ); void UpdateMemoryTree(); @@ -140,13 +92,6 @@ XMP_Uns32 nextTrackID; // 108 }; // 112 - struct Content_hdlr { // An 'hdlr' box as defined by ISO 14496-12. Maps OK to the QuickTime box. - XMP_Uns32 versionFlags; // 0 - XMP_Uns32 preDef; // 4 - XMP_Uns32 handlerType; // 8 - XMP_Uns32 reserved [3]; // 12 - // Plus optional component name string, null terminated UTF-8. - }; // 24 struct Content_stsd_entry { XMP_Uns32 entrySize; // 0 @@ -170,9 +115,9 @@ #pragma pack( pop ) -#if SUNOS_SPARC || XMP_IOS_ARM +#if SUNOS_SPARC || XMP_IOS_ARM || XMP_ANDROID_ARM #pragma pack( ) -#endif //#if SUNOS_SPARC || XMP_IOS_ARM +#endif //#if SUNOS_SPARC || XMP_IOS_ARM || XMP_ANDROID_ARM // --------------------------------------------------------------------------------------------- @@ -189,46 +134,11 @@ private: - struct BoxNode; - typedef std::vector BoxList; - typedef BoxList::iterator BoxListPos; - - struct BoxNode { - // ! Don't have a parent link, it will get destroyed by vector growth! - - XMP_Uns32 offset; // The offset in the fullSubtree, 0 if not in the parse. - XMP_Uns32 boxType; - XMP_Uns32 headerSize; // The actual header size in the fullSubtree, 0 if not in the parse. - XMP_Uns32 contentSize; // The current content size, does not include nested boxes or id. - BoxList children; - XMP_Uns8 idUUID[16]; - RawDataBlock changedContent; // Might be empty even if changed is true. - bool changed; // If true, the content is in changedContent, else in fullSubtree. - - BoxNode() : offset(0), boxType(0), headerSize(0), contentSize(0), changed(false) - { - memset ( idUUID, 0, 16 ); - }; - BoxNode ( XMP_Uns32 _offset, XMP_Uns32 _boxType, XMP_Uns32 _headerSize, XMP_Uns32 _contentSize ) - : offset(_offset), boxType(_boxType), headerSize(_headerSize), contentSize(_contentSize), changed(false) - { - memset ( idUUID, 0, 16 ); - }; - BoxNode ( XMP_Uns32 _offset, XMP_Uns32 _boxType, XMP_Uns32 _headerSize, const XMP_Uns8 * _idUUID, XMP_Uns32 _contentSize ) - : offset(_offset), boxType(_boxType), headerSize(_headerSize), contentSize(_contentSize), changed(false) - { - memcpy ( idUUID, _idUUID, 16 ); - }; - }; - + XMP_Uns8 fileMode; - BoxNode moovNode; - + void ParseNestedBoxes ( BoxNode * parentNode, const std::string & parentPath, bool ignoreMetaBoxes ); - XMP_Uns8 * PickContentPtr ( const BoxNode & node ) const; - void FillBoxInfo ( const BoxNode & node, BoxInfo * info ) const; - XMP_Uns32 NewSubtreeSize ( const BoxNode & node, const std::string & parentPath ); XMP_Uns8 * AppendNewSubtree ( const BoxNode & node, const std::string & parentPath, XMP_Uns8 * newPtr, XMP_Uns8 * newEnd ); diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/P2_Support.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/P2_Support.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/P2_Support.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/P2_Support.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,15 +1,17 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2014 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2014 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. +#include + #include "public/include/XMP_Const.h" #include "public/include/XMP_IO.hpp" @@ -22,23 +24,33 @@ #include "XMPFiles/source/FormatSupport/P2_Support.hpp" #include "third-party/zuid/interfaces/MD5.h" -#include P2_Clip::P2_Clip(const std::string & p2ClipMetadataFilePath) - try :headContentCached(false),p2XMLParser(0),p2Root(0) - ,p2ClipContent(0),filePath(p2ClipMetadataFilePath) + :headContentCached(false), p2XMLParser(0), p2Root(0) + , p2ClipContent(0), filePath(p2ClipMetadataFilePath) { - Host_IO::FileRef hostRef = Host_IO::Open ( p2ClipMetadataFilePath.c_str(), Host_IO::openReadOnly ); - XMPFiles_IO xmlFile ( hostRef, p2ClipMetadataFilePath.c_str(), Host_IO::openReadOnly ); - CreateExpatParser(xmlFile); - xmlFile.Close(); + PrepareForExpatParser(p2ClipMetadataFilePath); } -catch(...) + + + +void P2_Clip::PrepareForExpatParser(const std::string &p2ClipMetadataFilePath) { - DestroyExpatParser(); - throw; -} + try { + + Host_IO::FileRef hostRef = Host_IO::Open(p2ClipMetadataFilePath.c_str(), Host_IO::openReadOnly); + XMPFiles_IO xmlFile(hostRef, p2ClipMetadataFilePath.c_str(), Host_IO::openReadOnly); + CreateExpatParser(xmlFile); + xmlFile.Close(); + } + catch (...) + { + DestroyExpatParser(); + throw; + } + +} P2_Clip::~P2_Clip() { DestroyExpatParser(); @@ -108,7 +120,10 @@ { if (headContentCached) return; headContentCached = true; - XMP_StringPtr p2NameSpace=GetP2RootNode()->ns.c_str(); + XML_NodePtr p2RootNode = GetP2RootNode(); + if( p2RootNode == 0 ) return; + XMP_StringPtr p2NameSpace = p2RootNode->ns.c_str(); + p2ClipContent = GetP2RootNode()->GetNamedElement ( p2NameSpace, "ClipContent" ); if ( p2ClipContent == 0 ) return; XML_NodePtr p2node; @@ -136,7 +151,7 @@ p2Offset= p2node->GetNamedElement ( p2NameSpace, "GlobalShotID" ); GetElementLocation(p2Offset,headContent.shotId ); XML_NodePtr p2connection= p2node->GetNamedElement ( p2NameSpace, "Connection" ); - if ( p2node != 0 ) + if ( p2connection != 0 ) { p2node= p2connection->GetNamedElement ( p2NameSpace, "Top" ); if ( p2node != 0 ) @@ -301,28 +316,35 @@ return false; } -bool P2_SpannedClip::IsComplete() const +void P2_SpannedClip::checkSpannedClipIsComplete() { - RelatedP2ClipList::iterator iter=spannedP2Clip.begin(); - if (! (*iter)->IsTopClip() ) return false; - std::string* next=(*iter)->GetNextClipId(); - while(++iter != spannedP2Clip.end() && + RelatedP2ClipList::iterator iter = spannedP2Clip.begin(); + if (!(*iter)->IsTopClip()) + completeSpannedClip = false; + + std::string* next = (*iter)->GetNextClipId(); + while (++iter != spannedP2Clip.end() && next != 0 && (*iter)->IsValidClip() && - *next == *( (*iter)->GetClipId() ) - ) + *next == *((*iter)->GetClipId()) + ) next = (*iter)->GetNextClipId(); - if ( iter != spannedP2Clip.end() || next != 0 ) + if (iter != spannedP2Clip.end() || next != 0) { - iter=spannedP2Clip.begin(); - std::string* prev= (*iter)->GetClipId(); - while(++iter != spannedP2Clip.end() && - prev != 0 && (*iter)->GetPreviousClipId() !=0 && - *prev == *( (*iter)->GetPreviousClipId() ) - ) - prev= (*iter)->GetClipId(); - if ( iter != spannedP2Clip.end() ) return false; + iter = spannedP2Clip.begin(); + std::string* prev = (*iter)->GetClipId(); + while (++iter != spannedP2Clip.end() && + prev != 0 && (*iter)->GetPreviousClipId() != 0 && + *prev == *((*iter)->GetPreviousClipId()) + ) + prev = (*iter)->GetClipId(); + if (iter != spannedP2Clip.end()) completeSpannedClip = false; } - return true; + completeSpannedClip = true; +} + +bool P2_SpannedClip::IsComplete() +{ + return completeSpannedClip; } std::string P2_SpannedClip::GetXMPFilePath() @@ -356,7 +378,9 @@ digestStr->erase(); if ( this->headContent.clipMetadata == 0 ) return; // Bail if we don't have any legacy XML. - XMP_StringPtr p2NS = this->GetP2RootNode()->ns.c_str(); + XML_NodePtr p2RootNode = this->GetP2RootNode(); // Return if there is no root node. + if( p2RootNode == 0 ) return; + XMP_StringPtr p2NS = p2RootNode->ns.c_str(); XML_NodePtr legacyContext; MD5_CTX md5Context; unsigned char digestBin [16]; @@ -542,10 +566,7 @@ if ( ! spannedClips->AddIfRelated(tempClip) ) delete tempClip; } - if(spannedClips->IsComplete()) - { - return; - } + spannedClips->checkSpannedClipIsComplete(); } } diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/P2_Support.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/P2_Support.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/P2_Support.hpp 2020-02-12 03:14:47.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/P2_Support.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __P2_Support_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2014 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2014 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" @@ -66,6 +66,7 @@ ClipContent headContent; private: void DestroyExpatParser(); + void PrepareForExpatParser(const std::string & p2ClipMetadataFilePath); void CreateExpatParser(XMPFiles_IO &xmlFile); void CacheClipContent(); @@ -79,7 +80,7 @@ }; // class P2_Clip struct P2SpannedClip_Order { - bool operator()( P2_Clip* lhs, P2_Clip* rhs) const + bool operator()( P2_Clip* lhs, P2_Clip* rhs) const { return lhs->GetOffsetInShot() < rhs->GetOffsetInShot(); } @@ -90,7 +91,8 @@ public: P2_SpannedClip(const std::string & p2ClipMetadataFilePath); bool AddIfRelated(P2_Clip* openedClip); - bool IsComplete()const; + bool IsComplete(); + void checkSpannedClipIsComplete(); XMP_Uns32 GetDuration(); P2_Clip* TopP2Clip() ; std::string GetXMPFilePath(); @@ -106,6 +108,7 @@ typedef std::multiset RelatedP2ClipList; std::set addedClipIds; RelatedP2ClipList spannedP2Clip; + bool completeSpannedClip; }; // class P2_SpannedClip diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/PackageFormat_Support.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/PackageFormat_Support.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/PackageFormat_Support.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/PackageFormat_Support.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2013 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2013 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/PackageFormat_Support.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/PackageFormat_Support.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/PackageFormat_Support.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/PackageFormat_Support.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __PackageFormat_Support_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2013 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2013 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/PNG_Support.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/PNG_Support.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/PNG_Support.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/PNG_Support.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2008 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2008 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. #include "public/include/XMP_Const.h" @@ -19,325 +19,494 @@ namespace CRC { - /* Table of CRCs of all 8-bit messages. */ - static unsigned long crc_table[256]; - - /* Flag: has the table been computed? Initially false. */ - static int crc_table_computed = 0; + /* Table of CRCs of all 8-bit messages. */ + static unsigned long crc_table[256]; + + /* Flag: has the table been computed? Initially false. */ + static int crc_table_computed = 0; + + /* Make the table for a fast CRC. */ + static void make_crc_table(void) + { + unsigned long c; + int n, k; + + for (n = 0; n < 256; n++) + { + c = (unsigned long) n; + for (k = 0; k < 8; k++) + { + if (c & 1) + { + c = 0xedb88320L ^ (c >> 1); + } + else + { + c = c >> 1; + } + } + crc_table[n] = c; + } + crc_table_computed = 1; + } + + /* Update a running CRC with the bytes buf[0..len-1]--the CRC + should be initialized to all 1's, and the transmitted value + is the 1's complement of the final running CRC (see the + crc() routine below). */ + + static unsigned long update_crc(unsigned long crc, unsigned char *buf, int len) + { + unsigned long c = crc; + int n; + + if (!crc_table_computed) + { + make_crc_table(); + } + + for (n = 0; n < len; n++) + { + c = crc_table[(c ^ buf[n]) & 0xff] ^ (c >> 8); + } + + return c; + } + + /* Return the CRC of the bytes buf[0..len-1]. */ +#if 0 + static unsigned long crc(unsigned char *buf, int len) + { + return update_crc(0xffffffffL, buf, len) ^ 0xffffffffL; + } +#endif +} // namespace CRC - /* Make the table for a fast CRC. */ - static void make_crc_table(void) - { - unsigned long c; - int n, k; +namespace PNG_Support +{ + enum chunkType { + // Critical chunks - (shall appear in this order, except PLTE is optional) + IHDR = 'IHDR', + PLTE = 'PLTE', + IDAT = 'IDAT', + IEND = 'IEND', + // Ancillary chunks - (need not appear in this order) + cHRM = 'cHRM', + gAMA = 'gAMA', + iCCP = 'iCCP', + sBIT = 'sBIT', + sRGB = 'sRGB', + bKGD = 'bKGD', + hIST = 'hIST', + tRNS = 'tRNS', + pHYs = 'pHYs', + sPLT = 'sPLT', + tIME = 'tIME', + iTXt = 'iTXt', + tEXt = 'tEXt', + zTXt = 'zTXt' + + }; + + // ============================================================================================= + + long OpenPNG ( XMP_IO* fileRef, ChunkState & inOutChunkState ) + { + XMP_Int64 pos = 0; + long name; + XMP_Uns32 len; + + pos = fileRef->Seek ( 8, kXMP_SeekFromStart ); + if (pos != 8) return 0; + + // read first and following chunks + while ( ReadChunk ( fileRef, inOutChunkState, &name, &len, pos) ) {} + + return (long)inOutChunkState.chunks.size(); + + } + + // ============================================================================================= + + bool ReadChunk ( XMP_IO* fileRef, ChunkState & inOutChunkState, long * chunkType, XMP_Uns32 * chunkLength, XMP_Int64 & inOutPosition ) + { + try + { + XMP_Uns64 startPosition = inOutPosition; + long bytesRead; + char buffer[8]; + + bytesRead = fileRef->Read ( buffer, 8 ); + if ( bytesRead != 8 ) return false; + inOutPosition += 8; + *chunkLength = GetUns32BE(buffer); + *chunkType = GetUns32BE(buffer + 4); + + inOutPosition += *chunkLength; + inOutPosition += 4; //for CRC + + if(inOutPosition > fileRef->Length()) + XMP_Throw("Invalid PNG chunk length", kXMPErr_BadPNG); + + ChunkData newChunk; + + newChunk.pos = startPosition; + newChunk.len = *chunkLength; + newChunk.type = *chunkType; + + // check for XMP in iTXt-chunk + if (newChunk.type == iTXt) + { + CheckiTXtChunkHeader(fileRef, inOutChunkState, newChunk); + } + + inOutChunkState.chunks.push_back ( newChunk ); + + fileRef->Seek ( inOutPosition, kXMP_SeekFromStart ); + + } catch ( ... ) { + throw; + } + + return true; + + } + + // ============================================================================================= + + /*PNG file is structured in a series of chunks, where each chunk consists of four parts: + Length: 4 bytes + Chunk type: 4 bytes + Chunk data: The data bytes of “Length†length. + CRC: 4 bytes. + + XMP metadata is present in chunk of type “iTXtâ€.FindAndReadXMPChunk api will continue to + find chunks until it finds "iTXt" chunk. XMP metadata is extracted from "iTXt" chunk by + ExtractXMPPacket api. FindAndReadXMPChunk terminates if it finds "iTXt" chunk or end of + file is reached. + */ + + bool FindAndReadXMPChunk(XMP_IO* fileRef, std::string& outXMPPacket, XMP_Int64& outXmpOffset, bool isOpenForRead) + { + XMP_Int64 inOutPosition = 8; + + XMP_Int64 fileLength = fileRef->Length(); + XMP_Int64 remainingBytes = fileLength - inOutPosition; + + XMP_Uns32 chunkType = 0; + XMP_Uns32 chunkLength = 0; + bool processedXMP = false; + bool iendChunkFound = false; + XMP_Uns32 currentBufferSize = 0; + + const XMP_Uns8 CRC = 4; //No. of bytes stores CRC info. + const XMP_Uns32 MaxBufferSize = 1024 * 1024; //max buffer. + XMP_Uns8* buffer = NULL; + outXMPPacket.clear(); - for (n = 0; n < 256; n++) - { - c = (unsigned long) n; - for (k = 0; k < 8; k++) + try { + while (remainingBytes >= 8) { - if (c & 1) + XMP_Int64 seekedPosition = fileRef->Seek(inOutPosition, kXMP_SeekFromStart); + if (seekedPosition == -1) { - c = 0xedb88320L ^ (c >> 1); + XMP_Throw ( "seek failed", kXMPErr_BadPNG ); + } + + if (remainingBytes > MaxBufferSize) + { + currentBufferSize = MaxBufferSize; } else { - c = c >> 1; + currentBufferSize = static_cast(remainingBytes); } - } - crc_table[n] = c; - } - crc_table_computed = 1; - } - - /* Update a running CRC with the bytes buf[0..len-1]--the CRC - should be initialized to all 1's, and the transmitted value - is the 1's complement of the final running CRC (see the - crc() routine below). */ - static unsigned long update_crc(unsigned long crc, unsigned char *buf, int len) - { - unsigned long c = crc; - int n; - - if (!crc_table_computed) - { - make_crc_table(); - } - - for (n = 0; n < len; n++) - { - c = crc_table[(c ^ buf[n]) & 0xff] ^ (c >> 8); - } + buffer = new XMP_Uns8[currentBufferSize]; - return c; - } + fileRef->Read(buffer, currentBufferSize, true); + + //Process the buffer. + XMP_Uns8* tempBuffer = buffer; + XMP_Uns8* bufferLimit = buffer + currentBufferSize; + while (true) + { + chunkLength = GetUns32BE(tempBuffer); + chunkType = GetUns32BE(tempBuffer + 4); -#if 0 // unused - /* Return the CRC of the bytes buf[0..len-1]. */ - static unsigned long crc(unsigned char *buf, int len) - { - return update_crc(0xffffffffL, buf, len) ^ 0xffffffffL; - } -#endif -} // namespace CRC + tempBuffer += 8; -namespace PNG_Support -{ - enum chunkType { - // Critical chunks - (shall appear in this order, except PLTE is optional) - IHDR = 'IHDR', - PLTE = 'PLTE', - IDAT = 'IDAT', - IEND = 'IEND', - // Ancillary chunks - (need not appear in this order) - cHRM = 'cHRM', - gAMA = 'gAMA', - iCCP = 'iCCP', - sBIT = 'sBIT', - sRGB = 'sRGB', - bKGD = 'bKGD', - hIST = 'hIST', - tRNS = 'tRNS', - pHYs = 'pHYs', - sPLT = 'sPLT', - tIME = 'tIME', - iTXt = 'iTXt', - tEXt = 'tEXt', - zTXt = 'zTXt' - - }; + if (chunkType == iTXt) + { + ExtractXMPPacket(fileRef, chunkLength, tempBuffer, bufferLimit - tempBuffer, inOutPosition, outXMPPacket, outXmpOffset); + processedXMP = true; + break; + } + else if (chunkType == IEND && isOpenForRead) { + /*signifies end of png file. No need to process further.*/ + iendChunkFound = true; + break; + } - // ============================================================================================= + //skip the current chunk. + inOutPosition += 8 + static_cast(chunkLength) + CRC; + + if(inOutPosition > fileLength) + { + XMP_Throw ( "Invalid PNG chunk length", kXMPErr_BadPNG ); + } - long OpenPNG ( XMP_IO* fileRef, ChunkState & inOutChunkState ) - { - XMP_Uns64 pos = 0; - long name; - XMP_Uns32 len; - - pos = fileRef->Seek ( 8, kXMP_SeekFromStart ); - if (pos != 8) return 0; - - // read first and following chunks - while ( ReadChunk ( fileRef, inOutChunkState, &name, &len, pos) ) {} - - return (long)inOutChunkState.chunks.size(); + //if current buffer have enough data for current chunk and next chunk's 8 bytes + if ((bufferLimit - tempBuffer) > static_cast((chunkLength + CRC + 8))) + { + tempBuffer += chunkLength + CRC; + continue; + } - } + break; + } - // ============================================================================================= + delete[] buffer; + buffer = NULL; - bool ReadChunk ( XMP_IO* fileRef, ChunkState & inOutChunkState, long * chunkType, XMP_Uns32 * chunkLength, XMP_Uns64 & inOutPosition ) - { - try - { - XMP_Uns64 startPosition = inOutPosition; - long bytesRead; - char buffer[4]; - - bytesRead = fileRef->Read ( buffer, 4 ); - if ( bytesRead != 4 ) return false; - inOutPosition += 4; - *chunkLength = GetUns32BE(buffer); - - bytesRead = fileRef->Read ( buffer, 4 ); - if ( bytesRead != 4 ) return false; - inOutPosition += 4; - *chunkType = GetUns32BE(buffer); - - inOutPosition += *chunkLength; - - bytesRead = fileRef->Read ( buffer, 4 ); - if ( bytesRead != 4 ) return false; - inOutPosition += 4; - /*long crc =*/ GetUns32BE(buffer); - - ChunkData newChunk; - - newChunk.pos = startPosition; - newChunk.len = *chunkLength; - newChunk.type = *chunkType; + if (processedXMP || iendChunkFound) + { + //if xmp packet found or IEND chunk found, no need to process further. + break; + } - // check for XMP in iTXt-chunk - if (newChunk.type == iTXt) - { - CheckiTXtChunkHeader(fileRef, inOutChunkState, newChunk); + remainingBytes = fileLength - inOutPosition; } - - inOutChunkState.chunks.push_back ( newChunk ); - - fileRef->Seek ( inOutPosition, kXMP_SeekFromStart ); - - } catch ( ... ) { - - return false; - } - - return true; - - } - - // ============================================================================================= - - bool WriteXMPChunk ( XMP_IO* fileRef, XMP_Uns32 len, const char* inBuffer ) - { - bool ret = false; - unsigned long datalen = (4 + ITXT_HEADER_LEN + len); - unsigned char* buffer = new unsigned char[datalen]; - - try + catch(XMP_Error&) { - size_t pos = 0; - memcpy(&buffer[pos], ITXT_CHUNK_TYPE, 4); - pos += 4; - memcpy(&buffer[pos], ITXT_HEADER_DATA, ITXT_HEADER_LEN); - pos += ITXT_HEADER_LEN; - memcpy(&buffer[pos], inBuffer, len); - - unsigned long crc_value = MakeUns32BE( CalculateCRC( buffer, datalen )); - datalen -= 4; - unsigned long len_value = MakeUns32BE( datalen ); - datalen += 4; - - fileRef->Write ( &len_value, 4 ); - fileRef->Write ( buffer, datalen ); - fileRef->Write ( &crc_value, 4 ); - - ret = true; + delete[] buffer; + buffer = NULL; + throw; } - catch ( ... ) {} - - delete [] buffer; - - return ret; - } - - // ============================================================================================= - - bool CopyChunk ( XMP_IO* sourceRef, XMP_IO* destRef, ChunkData& chunk ) - { - try + catch (...) { - sourceRef->Seek ( chunk.pos, kXMP_SeekFromStart ); - XIO::Copy (sourceRef, destRef, (chunk.len + 12)); - - } catch ( ... ) { - - return false; - + delete[] buffer; + buffer = NULL; + throw; } - - return true; - } - - // ============================================================================================= - unsigned long UpdateChunkCRC( XMP_IO* fileRef, ChunkData& inOutChunkData ) - { - unsigned long ret = 0; - unsigned long datalen = (inOutChunkData.len + 4); - unsigned char* buffer = new unsigned char[datalen]; - - try - { - fileRef->Seek ( (inOutChunkData.pos + 4), kXMP_SeekFromStart ); - - size_t pos = 0; - /*long bytesRead =*/ fileRef->Read ( &buffer[pos], (inOutChunkData.len + 4) ); - - unsigned long crc = CalculateCRC( buffer, (inOutChunkData.len + 4) ); - unsigned long crc_value = MakeUns32BE( crc ); - - fileRef->Seek ( (inOutChunkData.pos + 4 + 4 + inOutChunkData.len), kXMP_SeekFromStart ); - fileRef->Write ( &crc_value, 4 ); - - ret = crc; - } - catch ( ... ) {} - - delete [] buffer; - - return ret; - } - - // ============================================================================================= - - bool CheckIHDRChunkHeader ( ChunkData& inOutChunkData ) - { - return (inOutChunkData.type == IHDR); + return (outXMPPacket.size() != 0); } + + // ============================================================================================= + + bool ExtractXMPPacket(XMP_IO* fileRef, XMP_Uns32 chunkLength, XMP_Uns8* buffer, XMP_Int64 bufferLength,XMP_Int64 filePosition, std::string& outXMPPacket,XMP_Int64& xmpOffset) + { + if(chunkLength <= ITXT_HEADER_LEN) + return false; + + std::string packetStr; + + if(bufferLength >= chunkLength) + { + packetStr.assign((char*)buffer , chunkLength); + } + else + { + XMP_Int64 fileLength = fileRef->Length(); + filePosition += 8; - // ============================================================================================= - - unsigned long CheckiTXtChunkHeader ( XMP_IO* fileRef, ChunkState& inOutChunkState, ChunkData& inOutChunkData ) - { - try - { - fileRef->Seek ( (inOutChunkData.pos + 8), kXMP_SeekFromStart ); - - char buffer[ITXT_HEADER_LEN]; - long bytesRead = fileRef->Read ( buffer, ITXT_HEADER_LEN ); - - if (bytesRead == ITXT_HEADER_LEN) + if (filePosition + chunkLength + 4 > fileLength) //not enough data in file. { - if (memcmp(buffer, ITXT_HEADER_DATA, ITXT_HEADER_LEN) == 0) - { - // return length of XMP - if (inOutChunkData.len > ITXT_HEADER_LEN) - { - inOutChunkState.xmpPos = inOutChunkData.pos + 8 + ITXT_HEADER_LEN; - inOutChunkState.xmpLen = inOutChunkData.len - ITXT_HEADER_LEN; - inOutChunkState.xmpChunk = inOutChunkData; - inOutChunkData.xmp = true; - - return inOutChunkState.xmpLen; - } - } + XMP_Throw ( "Invalid PNG chunk length", kXMPErr_BadPNG ); } - } - catch ( ... ) {} - - return 0; - } - - bool ReadBuffer ( XMP_IO* fileRef, XMP_Uns64 & pos, XMP_Uns32 len, char * outBuffer ) - { - try - { - if ( (fileRef == 0) || (outBuffer == 0) ) return false; - - fileRef->Seek ( pos, kXMP_SeekFromStart ); - long bytesRead = fileRef->Read ( outBuffer, len ); - if ( XMP_Uns32(bytesRead) != len ) return false; - - return true; - } - catch ( ... ) {} - - return false; - } - - bool WriteBuffer ( XMP_IO* fileRef, XMP_Uns64 & pos, XMP_Uns32 len, const char * inBuffer ) - { - try - { - if ( (fileRef == 0) || (inBuffer == 0) ) return false; - - fileRef->Seek ( pos, kXMP_SeekFromStart ); - fileRef->Write ( inBuffer, len ); - - return true; - } - catch ( ... ) {} - - return false; - } - - unsigned long CalculateCRC( unsigned char* inBuffer, XMP_Uns32 len ) - { - return CRC::update_crc(0xffffffffL, inBuffer, len) ^ 0xffffffffL; - } + packetStr.assign((char*)buffer , bufferLength); + xmpOffset = filePosition + ITXT_HEADER_LEN; + filePosition += bufferLength; + + XMP_Uns32 remainingLength = chunkLength - static_cast(bufferLength); + std::string remainingPacket; + remainingPacket.reserve(remainingLength); + remainingPacket.assign(remainingLength, ' '); + + fileRef->Seek ( filePosition, kXMP_SeekFromStart ); + long bytesRead = fileRef->Read ( const_cast(remainingPacket.data()), remainingLength, true); + packetStr += remainingPacket; + } + + if (packetStr.compare(0, ITXT_HEADER_LEN, std::string(ITXT_HEADER_DATA, ITXT_HEADER_LEN)) == 0) + { + outXMPPacket.clear(); + outXMPPacket = packetStr.substr(ITXT_HEADER_LEN); + } + else + { + return false; + } + + return true; + } + + + + // ============================================================================================= + + bool WriteXMPChunk ( XMP_IO* fileRef, XMP_Uns32 len, const char* inBuffer ) + { + bool ret = false; + XMP_Uns32 datalen = (4 + ITXT_HEADER_LEN + len); + unsigned char* buffer = new unsigned char[datalen]; + + try + { + size_t pos = 0; + memcpy(&buffer[pos], ITXT_CHUNK_TYPE, 4); + pos += 4; + memcpy(&buffer[pos], ITXT_HEADER_DATA, ITXT_HEADER_LEN); + pos += ITXT_HEADER_LEN; + memcpy(&buffer[pos], inBuffer, len); + + XMP_Uns32 crc_value = MakeUns32BE( (XMP_Uns32)CalculateCRC( buffer, datalen )); + datalen -= 4; + XMP_Uns32 len_value = MakeUns32BE( datalen ); + datalen += 4; + + fileRef->Write ( &len_value, 4 ); + fileRef->Write ( buffer, datalen ); + fileRef->Write ( &crc_value, 4 ); + + ret = true; + } + catch ( ... ) {} + + delete [] buffer; + + return ret; + } + + // ============================================================================================= + + bool CopyChunk ( XMP_IO* sourceRef, XMP_IO* destRef, ChunkData& chunk ) + { + try + { + sourceRef->Seek ( chunk.pos, kXMP_SeekFromStart ); + XIO::Copy (sourceRef, destRef, (chunk.len + 12)); + + } catch ( ... ) { + + return false; + + } + + return true; + } + + // ============================================================================================= + + unsigned long UpdateChunkCRC( XMP_IO* fileRef, ChunkData& inOutChunkData ) + { + unsigned long ret = 0; + unsigned long datalen = (inOutChunkData.len + 4); + unsigned char* buffer = new unsigned char[datalen]; + + try + { + fileRef->Seek ( (inOutChunkData.pos + 4), kXMP_SeekFromStart ); + + size_t pos = 0; + long bytesRead = fileRef->Read ( &buffer[pos], (inOutChunkData.len + 4) ); + + XMP_Uns32 crc = (XMP_Uns32)CalculateCRC( buffer, (inOutChunkData.len + 4) ); + XMP_Uns32 crc_value = MakeUns32BE( crc ); + + fileRef->Seek ( (inOutChunkData.pos + 4 + 4 + inOutChunkData.len), kXMP_SeekFromStart ); + fileRef->Write ( &crc_value, 4 ); + + ret = crc; + } + catch ( ... ) {} + + delete [] buffer; + + return ret; + } + + // ============================================================================================= + + bool CheckIHDRChunkHeader ( ChunkData& inOutChunkData ) + { + return (inOutChunkData.type == IHDR); + } + + // ============================================================================================= + + unsigned long CheckiTXtChunkHeader ( XMP_IO* fileRef, ChunkState& inOutChunkState, ChunkData& inOutChunkData ) + { + try + { + if(inOutChunkData.len <= ITXT_HEADER_LEN) + return 0; + + fileRef->Seek ( (inOutChunkData.pos + 8), kXMP_SeekFromStart ); + + char buffer[ITXT_HEADER_LEN]; + long bytesRead = fileRef->Read ( buffer, ITXT_HEADER_LEN ); + + if (bytesRead == ITXT_HEADER_LEN) + { + if (memcmp(buffer, ITXT_HEADER_DATA, ITXT_HEADER_LEN) == 0) + { + // return length of XMP + + inOutChunkState.xmpPos = inOutChunkData.pos + 8 + ITXT_HEADER_LEN; + inOutChunkState.xmpLen = inOutChunkData.len - ITXT_HEADER_LEN; + inOutChunkState.xmpChunk = inOutChunkData; + inOutChunkData.xmp = true; + + return inOutChunkState.xmpLen; + + } + } + } + catch ( ... ) {} + + return 0; + } + + bool ReadBuffer ( XMP_IO* fileRef, XMP_Uns64 & pos, XMP_Uns32 len, char * outBuffer ) + { + try + { + if ( (fileRef == 0) || (outBuffer == 0) ) return false; + + fileRef->Seek ( pos, kXMP_SeekFromStart ); + long bytesRead = fileRef->Read ( outBuffer, len ); + if ( XMP_Uns32(bytesRead) != len ) return false; + + return true; + } + catch ( ... ) {} + + return false; + } + + bool WriteBuffer ( XMP_IO* fileRef, XMP_Uns64 & pos, XMP_Uns32 len, const char * inBuffer ) + { + try + { + if ( (fileRef == 0) || (inBuffer == 0) ) return false; + + fileRef->Seek ( pos, kXMP_SeekFromStart ); + fileRef->Write ( inBuffer, len ); + + return true; + } + catch ( ... ) {} + + return false; + } + + unsigned long CalculateCRC( unsigned char* inBuffer, XMP_Uns32 len ) + { + return CRC::update_crc(0xffffffffL, inBuffer, len) ^ 0xffffffffL; + } + } // namespace PNG_Support diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/PNG_Support.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/PNG_Support.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/PNG_Support.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/PNG_Support.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __PNG_Support_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2007 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2007 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -60,7 +60,7 @@ long OpenPNG ( XMP_IO* fileRef, ChunkState& inOutChunkState ); - bool ReadChunk ( XMP_IO* fileRef, ChunkState& inOutChunkState, long* chunkType, XMP_Uns32* chunkLength, XMP_Uns64& inOutPosition ); + bool ReadChunk ( XMP_IO* fileRef, ChunkState& inOutChunkState, long* chunkType, XMP_Uns32* chunkLength, XMP_Int64& inOutPosition ); bool WriteXMPChunk ( XMP_IO* fileRef, XMP_Uns32 len, const char* inBuffer ); bool CopyChunk ( XMP_IO* sourceRef, XMP_IO* destRef, ChunkData& chunk ); unsigned long UpdateChunkCRC( XMP_IO* fileRef, ChunkData& inOutChunkData ); @@ -72,6 +72,17 @@ bool WriteBuffer ( XMP_IO* fileRef, XMP_Uns64& pos, XMP_Uns32 len, const char* inBuffer ); unsigned long CalculateCRC( unsigned char* inBuffer, XMP_Uns32 len ); + + + //These 2 functions are introduced to reduce the file read call which is required to find + //and process XMP in PNG file. Reading small data from file is an expensive operation + //if processed file is present on network. + //Instead of reading 8 bytes to identify each chunk type(see ReadChunk), FindAndReadXMPChunk will copy the file data in a buffer of 1 MB and then process it. + //see bug CTECHXMP-4169872. + //Now PNG_MetaHandler::CacheFileData is using this function instead of OpenPNG. + + bool FindAndReadXMPChunk ( XMP_IO* fileRef, std::string& outXMPPacket,XMP_Int64& xmpOffset, bool isOpenForRead ); + bool ExtractXMPPacket(XMP_IO* fileRef, XMP_Uns32 chunkLength, XMP_Uns8* buffer, XMP_Int64 bytesInBuffer,XMP_Int64 filePosition, std::string& outXMPPacket,XMP_Int64& xmpOffset); } // namespace PNG_Support diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/PostScript_Support.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/PostScript_Support.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/PostScript_Support.cpp 2017-08-04 02:10:10.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/PostScript_Support.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2012 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2012 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "XMPFiles/source/FormatSupport/PostScript_Support.hpp" @@ -267,6 +267,7 @@ if ( ! CheckBytes ( ioBuf.ptr, Uns8Ptr("EPSF-"), 5 ) ) return true; }//intentional fall through for further checking of unknown files + // fallthrough case kXMP_EPSFile: { @@ -1014,14 +1015,7 @@ if(itr!=tokenzs.end()) { ++itr; - if (itr == tokenzs.end()) - { - // bug 101914 - corrupt file make us - // reach the end. -- Hub - // https://bugs.freedesktop.org/show_bug.cgi?id=101914 - break; - } - if (itr->noOfDelimiter==0 && IsNumeric(itr->token[0]) ) + if (itrnoOfDelimiter==0 && IsNumeric(itr->token[0]) ) { const char * str=itr->token.c_str(); short day= GetNumber(&str); @@ -1030,6 +1024,10 @@ date.day=day; } } + else if (itr == tokenzs.end()) + { + break; + } } } } diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/PostScript_Support.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/PostScript_Support.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/PostScript_Support.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/PostScript_Support.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __PostScript_Support_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2012 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2012 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" @@ -147,7 +147,7 @@ // embedd xpacket in EPS files.the xpacket is written inbetween kEPS_Injectdata1 and kEPS_Injectdata2. // The tokens kPS_Injectdata1 and kPS_Injectdata2 are used to embedd xpacket in DSC compliant PS files // The code inside the tokens is taken from examples in XMP Spec part 3 -// section 2.6.2 PS, EPS (PostScript® and Encapsulated PostScript) +// section 2.6.2 PS, EPS (PostScript and Encapsulated PostScript) static const std::string kEPS_Injectdata1="\n/currentdistillerparams where\n" "{pop currentdistillerparams /CoreDistVersion get 5000 lt} {true} ifelse\n" "{userdict /EPSHandler1_pdfmark /cleartomark load put\n" diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/PSIR_FileWriter.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/PSIR_FileWriter.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/PSIR_FileWriter.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/PSIR_FileWriter.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/PSIR_MemoryReader.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/PSIR_MemoryReader.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/PSIR_MemoryReader.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/PSIR_MemoryReader.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/PSIR_Support.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/PSIR_Support.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/PSIR_Support.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/PSIR_Support.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __PSIR_Support_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/QuickTime_Support.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/QuickTime_Support.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/QuickTime_Support.cpp 2018-02-02 15:07:11.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/QuickTime_Support.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2009 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2009 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -815,7 +815,7 @@ XMP_Uns16 macScript = GetMacScript ( macLang ); if ( macScript == kNoMacScript ) return false; - #if XMP_UNIXBuild + #if XMP_UNIXBuild | XMP_AndroidBuild if ( macScript != smRoman ) return false; #elif XMP_WinBuild if ( GetWinCP(macLang) == 0 ) return false; @@ -838,7 +838,7 @@ #if XMP_MacBuild XMP_Uns16 macScript = GetMacScript ( macLang ); ReconcileUtils::UTF8ToMacEncoding ( macScript, macLang, (XMP_Uns8*)utf8Value.c_str(), utf8Value.size(), macValue ); - #elif XMP_UNIXBuild + #elif XMP_UNIXBuild | XMP_AndroidBuild UTF8ToMacRoman ( utf8Value, macValue ); #elif XMP_WinBuild UINT winCP = GetWinCP ( macLang ); @@ -864,7 +864,7 @@ #if XMP_MacBuild XMP_Uns16 macScript = GetMacScript ( macLang ); ReconcileUtils::MacEncodingToUTF8 ( macScript, macLang, (XMP_Uns8*)macValue.c_str(), macValue.size(), utf8Value ); - #elif XMP_UNIXBuild + #elif XMP_UNIXBuild | XMP_AndroidBuild MacRomanToUTF8 ( macValue, utf8Value ); #elif XMP_WinBuild UINT winCP = GetWinCP ( macLang ); @@ -888,7 +888,7 @@ // TradQT_Manager::ParseCachedBoxes // ================================ // -// Parse the cached '©...' children of the 'moov'/'udta' box. The contents of each cached box are +// Parse the cached '©...' children of the 'moov'/'udta' box. The contents of each cached box are // a sequence of "mini boxes" analogous to XMP AltText arrays. Each mini box has a 16-bit size, // 16-bit language code, and text. The size is only the text size. The language codes are Macintosh // Script Manager langXyz codes. The text encoding is implicit in the language, see comments in @@ -943,6 +943,19 @@ } // TradQT_Manager::ParseCachedBoxes +/*Parsed the metadata present in moov/meta atom. The moov/meta box contains 3 mandatory child atoms namely + - metadata handler atom 'hdlr*, + - metadata item keys atom 'keys' + - metadata item list atom 'ilst' + hdlr atom contains information about the structure followed in meta atom, + If the handler type is not mdta, meta atom does not follow specs according to QT and function will not parse moov/meta atom further + + 'keys' atom holds a list of the metadata keys that may be present in the meta atom. These keys are indexed starting from 1 + + 'ilst' atom holds a list of actual metadata values that are present in the metadata atom. The metadata items are formatted as a list of items. + 'ilst' atom contains child atoms whose atom type should be set equal to the index of the key from the metadata item keys atom. In addition, + each child atom contains a Value Atom, to hold the value of the metadata item.. +*/ // ================================================================================================= // TradQT_Manager::ImportSimpleXMP // =============================== @@ -1249,7 +1262,7 @@ if ( udtaRef != 0 ) { // Might not have been a moov/udta box in the parse. - // First go through the moov/udta/©... children and delete those that are not in the map. + // First go through the moov/udta/©... children and delete those that are not in the map. for ( XMP_Uns32 ordinal = udtaInfo.childCount; ordinal > 0; --ordinal ) { // ! Go backwards because of deletions. @@ -1318,7 +1331,7 @@ MOOV_Manager::BoxRef itemRef = moovMgr->GetTypeChild ( udtaRef, qtItem->id, &itemInfo ); if ( itemRef != 0 ) { - moovMgr->SetBox ( itemRef, &fullValue[0], qtTotalSize ); + moovMgr->ISOBaseMedia_Manager::SetBox( itemRef, &fullValue[0], qtTotalSize ); } else { moovMgr->AddChildBox ( udtaRef, qtItem->id, &fullValue[0], qtTotalSize ); } diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/QuickTime_Support.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/QuickTime_Support.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/QuickTime_Support.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/QuickTime_Support.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __QuickTime_Support_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2009 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2009 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. @@ -38,17 +38,25 @@ enum { // List of recognized items from the QuickTime 'moov'/'udta' box. // These items are defined by Adobe. - kQTilst_Reel = 0xA952454CUL, // '©REL' - kQTilst_Timecode = 0xA954494DUL, // '©TIM' - kQTilst_TimeScale = 0xA9545343UL, // '©TSC' - kQTilst_TimeSize = 0xA954535AUL // '©TSZ' + kQTilst_Reel = 0xA952454CUL, // 'REL' + kQTilst_Timecode = 0xA954494DUL, // 'TIM' + kQTilst_TimeScale = 0xA9545343UL, // 'TSC' + kQTilst_TimeSize = 0xA954535AUL // 'TSZ' }; + enum { kNoMacLang = 0xFFFF, kNoMacScript = 0xFFFF }; +enum { // Values for the type field at the start of a 'data' box. + kData_Implicit = 0, // Implicit (unique) based on the box type + kData_UTF_8 = 1, // UTF-8 text, no nul terminator + kData_UTF_16 = 2, // Big endian UTF-16 text + kData_ShiftJIS = 3, // ShiftJIS text +}; + extern bool ConvertToMacLang ( const std::string & utf8Value, XMP_Uns16 macLang, std::string * macValue ); extern bool ConvertFromMacLang ( const std::string & macValue, XMP_Uns16 macLang, std::string * utf8Value ); @@ -70,6 +78,8 @@ void UpdateChangedBoxes ( MOOV_Manager * moovMgr ); + //Functions for supporting "moov/meta" atom + private: struct ValueInfo { @@ -100,6 +110,36 @@ bool ImportLangItem ( const ValueInfo & qtItem, SXMPMeta * xmp, XMP_StringPtr ns, XMP_StringPtr langArray ) const; + //Data Structures to handle metadata in moov/meta atom + + struct DataBoxInfo { + std::string value; + XMP_Uns32 dataType; + XMP_Uns32 localeInfo; + DataBoxInfo(XMP_Uns32 dt, XMP_Uns32 l) : dataType(dt), localeInfo(l) {}; + }; + + typedef std::vector DataBoxInfoVector; + + struct MetaItemBoxInfo { + std::string key; + XMP_Uns32 type;//key_index + DataBoxInfoVector values; + size_t firstText; // Index of the first text value. + MetaItemBoxInfo() : type(0), firstText(std::string::npos) {}; + MetaItemBoxInfo(XMP_Uns32 t) : type(t), firstText(std::string::npos) {}; + }; + + typedef std::vector MetaItemBoxInfoVector; + MetaItemBoxInfoVector MetaBoxItemList; + + bool ConvertQTDateTime(XMP_StringPtr dateStr, XMP_DateTime* xmpDateTime); + bool ConvertXMPDateTime(std::string& strValue); + bool FormatLocationToGPSProperty(XMP_StringPtr, XMP_StringPtr, std::string&, XMP_Uns32 &); + bool FormatGPSPropertyToLocation(std::string &xmpValue, XMP_StringPtr propName); + bool isValidType(XMP_Uns32 typeCode); + bool DecodeString(const std::string & iTunesValue, XMP_Uns16 typeCode, std::string * utf8Value); + }; // TradQT_Manager #endif // __QuickTime_Support_hpp__ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/Reconcile_Impl.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/Reconcile_Impl.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/Reconcile_Impl.cpp 2016-12-07 05:07:54.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/Reconcile_Impl.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. @@ -177,6 +177,10 @@ // ! Does not exist, must not be called, for Generic UNIX builds. +#elif XMP_AndroidBuild + + // Not Implemented for Android, as(for now) Not possible to identify locale from native side of Android + #endif // ================================================================================================= @@ -205,13 +209,17 @@ #elif XMP_UNIXBuild XMP_Throw ( "Generic UNIX does not have conversions between local and Unicode", kXMPErr_Unavailable ); + + #elif XMP_AndroidBuild + + XMP_Throw ( "Conversions between local and Unicode not implemented for Android", kXMPErr_Unavailable ); #elif XMP_iOSBuild IOSConvertEncoding(kCFStringEncodingUTF8, CFStringGetSystemEncoding(), utf8Ptr, utf8Len, local); - + #endif @@ -354,6 +362,10 @@ // ! Does not exist, must not be called, for Generic UNIX builds. +#elif XMP_AndroidBuild + + // Not to be called for Android. Keep Android only UTF8 + #endif // ================================================================================================= @@ -363,6 +375,8 @@ void ReconcileUtils::LocalToUTF8 ( const void * _localPtr, size_t localLen, std::string * utf8 ) { const XMP_Uns8* localPtr = (XMP_Uns8*)_localPtr; +// UNUSED -- Hub const char* localPtr1 = (const char*)_localPtr; +// UNUSED -- Hub const wchar_t * lptr=(const wchar_t *)_localPtr; utf8->erase(); @@ -382,6 +396,10 @@ #elif XMP_UNIXBuild XMP_Throw ( "Generic UNIX does not have conversions between local and Unicode", kXMPErr_Unavailable ); + + #elif XMP_AndroidBuild + + XMP_Throw ( "Conversions between local and Unicode not implemented for Android", kXMPErr_Unavailable ); #elif XMP_iOSBuild diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/Reconcile_Impl.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/Reconcile_Impl.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/Reconcile_Impl.hpp 2016-12-07 05:07:54.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/Reconcile_Impl.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __Reconcile_Impl_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/ReconcileIPTC.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/ReconcileIPTC.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/ReconcileIPTC.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/ReconcileIPTC.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -151,7 +151,7 @@ if ( XMP_LitMatch ( xmpNS, kXMP_NS_DC ) && XMP_LitMatch ( xmpProp, "creator" ) ) arrayForm = kXMP_PropArrayIsOrdered; for ( size_t ds = 0; ds < count; ++ds ) { - (void) iptc.GetDataSet_UTF8 ( id, &utf8Str, ds ); + if (!iptc.GetDataSet_UTF8(id, &utf8Str, ds)) continue; NormalizeToLF ( &utf8Str ); xmp->AppendArrayItem ( xmpNS, xmpProp, arrayForm, utf8Str.c_str() ); } @@ -193,7 +193,7 @@ IPTC_Manager::DataSetInfo dsInfo; size_t count = iptc.GetDataSet ( dateID, &dsInfo ); - if ( count == 0 || dsInfo.dataLen == 0 ) return; + if ( count == 0 || dsInfo.dataLen == 0 || dsInfo.dataPtr == NULL) return; size_t chPos, digits; XMP_DateTime xmpDate; @@ -227,7 +227,7 @@ // Now add the time portion if present. count = iptc.GetDataSet ( timeID, &dsInfo ); - if ( count != 0 && dsInfo.dataLen > 0 ) { + if ( count != 0 && dsInfo.dataLen > 0 && dsInfo.dataPtr != NULL) { chPos = 0; for ( digits = 0; digits < 2; ++digits, ++chPos ) { diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/ReconcileLegacy.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/ReconcileLegacy.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/ReconcileLegacy.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/ReconcileLegacy.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/ReconcileLegacy.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/ReconcileLegacy.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/ReconcileLegacy.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/ReconcileLegacy.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __ReconcileLegacy_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. @@ -85,7 +85,7 @@ // Here are the primary (0th) IFD tags that get special treatment: // // 270, 33432 - ASCII mapped to alt-text['x-default'] -// 306 - DateTime master +// 306 - DateTime main // 315 - ASCII mapped to text seq[1] // // Here are the primary (0th) IFD tags that get mapped by type and count: @@ -97,7 +97,7 @@ // // 34856, 41484 - OECF/SFR table // 36864, 40960 - 4 ASCII chars to text -// 36867, 36868 - DateTime master +// 36867, 36868 - DateTime main // 37121 - 4 UInt8 to integer seq // 37385 - Flash struct // 37510 - explicitly encoded text to alt-text['x-default'] @@ -114,8 +114,8 @@ // Here are the GPS IFD tags that get special treatment: // // 0 - 4 UInt8 to text "n.n.n.n" -// 2, 4, 20, 22 - Latitude or longitude master -// 7 - special DateTime master, the time part +// 2, 4, 20, 22 - Latitude or longitude main +// 7 - special DateTime main, the time part // 27, 28 - explicitly encoded text // // Here are the GPS IFD tags that get mapped by type and count: @@ -161,7 +161,7 @@ // 296 SHORT 1 ResolutionUnit integer // 301 SHORT 3*256 TransferFunction integer seq // 305 ASCII Any Software text, xmp:CreatorTool -// 306 ASCII 20 DateTime date, master of 37520, xmp:DateTime +// 306 ASCII 20 DateTime date, main of 37520, xmp:DateTime // 315 ASCII Any Artist text, dc:creator[1] // 318 RATIONAL 2 WhitePoint rational seq // 319 RATIONAL 6 PrimaryChromaticities rational seq @@ -181,8 +181,8 @@ // 34855 SHORT Any ISOSpeedRatings integer seq // 34856 UNDEFINED Any OECF OECF/SFR table // 36864 UNDEFINED 4 ExifVersion text, Exif has 4 ASCII chars -// 36867 ASCII 20 DateTimeOriginal date, master of 37521 -// 36868 ASCII 20 DateTimeDigitized date, master of 37522 +// 36867 ASCII 20 DateTimeOriginal date, main of 37521 +// 36868 ASCII 20 DateTimeDigitized date, main of 37522 // 37121 UNDEFINED 4 ComponentsConfiguration integer seq, Exif has 4 UInt8 // 37122 RATIONAL 1 CompressedBitsPerPixel rational // 37377 SRATIONAL 1 ShutterSpeedValue rational @@ -235,12 +235,12 @@ // // 0 BYTE 4 GPSVersionID text, "n.n.n.n", Exif has 4 UInt8 // 1 ASCII 2 GPSLatitudeRef latitude, with 2 -// 2 RATIONAL 3 GPSLatitude latitude, master of 2 +// 2 RATIONAL 3 GPSLatitude latitude, main of 2 // 3 ASCII 2 GPSLongitudeRef longitude, with 4 -// 4 RATIONAL 3 GPSLongitude longitude, master of 3 +// 4 RATIONAL 3 GPSLongitude longitude, main of 3 // 5 BYTE 1 GPSAltitudeRef integer // 6 RATIONAL 1 GPSAltitude rational -// 7 RATIONAL 3 GPSTimeStamp date, master of 29 +// 7 RATIONAL 3 GPSTimeStamp date, main of 29 // 8 ASCII Any GPSSatellites text // 9 ASCII 2 GPSStatus text // 10 ASCII 2 GPSMeasureMode text @@ -253,9 +253,9 @@ // 17 RATIONAL 1 GPSImgDirection rational // 18 ASCII Any GPSMapDatum text // 19 ASCII 2 GPSDestLatitudeRef latitude, with 20 -// 20 RATIONAL 3 GPSDestLatitude latitude, master of 19 +// 20 RATIONAL 3 GPSDestLatitude latitude, main of 19 // 21 ASCII 2 GPSDestLongitudeRef longitude, with 22 -// 22 RATIONAL 3 GPSDestLongitude logitude, master of 21 +// 22 RATIONAL 3 GPSDestLongitude logitude, main of 21 // 23 ASCII 2 GPSDestBearingRef text // 24 RATIONAL 1 GPSDestBearing rational // 25 ASCII 2 GPSDestDistanceRef text diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/ReconcileTIFF.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/ReconcileTIFF.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/ReconcileTIFF.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/ReconcileTIFF.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -116,6 +116,9 @@ { /* 40964 */ kTIFF_RelatedSoundFile, kTIFF_ASCIIType, kAnyCount, kExport_Always, kXMP_NS_EXIF, "RelatedSoundFile" }, // ! Exif spec says count of 13. { /* 36867 */ kTIFF_DateTimeOriginal, kTIFF_ASCIIType, 20, kExport_Always, "", "" }, // ! Has a special mapping. { /* 36868 */ kTIFF_DateTimeDigitized, kTIFF_ASCIIType, 20, kExport_Always, "", "" }, // ! Has a special mapping. + { /* 36880 */ kTIFF_OffsetTime, kTIFF_ASCIIType, 7, kExport_Always, "", "" }, // ! Has a special mapping. + { /* 36881 */ kTIFF_OffsetTimeOriginal, kTIFF_ASCIIType, 7, kExport_Always, "", "" }, // ! Has a special mapping. + { /* 36882 */ kTIFF_OffsetTimeDigitized, kTIFF_ASCIIType, 7, kExport_Always, "", "" }, // ! Has a special mapping. { /* 42016 */ kTIFF_ImageUniqueID, kTIFF_ASCIIType, 33, kExport_InjectOnly, kXMP_NS_EXIF, "ImageUniqueID" }, { /* 42032 */ kTIFF_CameraOwnerName, kTIFF_ASCIIType, kAnyCount, kExport_InjectOnly, kXMP_NS_ExifEX, "CameraOwnerName" }, { /* 42033 */ kTIFF_BodySerialNumber, kTIFF_ASCIIType, kAnyCount, kExport_InjectOnly, kXMP_NS_ExifEX, "BodySerialNumber" }, @@ -314,7 +317,8 @@ IPTC_Manager::DataSetInfo tmpInfo; for ( i = 0; i < iptcCount; ++i ) { (void) iptc.GetDataSet ( id, &tmpInfo, i ); - if ( ReconcileUtils::IsASCII ( tmpInfo.dataPtr, tmpInfo.dataLen ) ) break; + if (tmpInfo.dataLen == 0 || tmpInfo.dataPtr == NULL + || ReconcileUtils::IsASCII(tmpInfo.dataPtr, tmpInfo.dataLen)) break; } if ( i == iptcCount ) iptcCount = 0; // Return 0 if value(s) should be ignored. } @@ -360,7 +364,8 @@ if ( ignoreLocalText & (! newIPTC.UsingUTF8()) ) { // Check to see if the new value should be ignored. (void) newIPTC.GetDataSet ( id, &newInfo, newCount ); - if ( ! ReconcileUtils::IsASCII ( newInfo.dataPtr, newInfo.dataLen ) ) continue; + if (newInfo.dataLen == 0 || newInfo.dataPtr == NULL + || ! ReconcileUtils::IsASCII ( newInfo.dataPtr, newInfo.dataLen ) ) continue; } (void) newIPTC.GetDataSet_UTF8 ( id, &newStr, newCount ); @@ -467,12 +472,12 @@ { try { // Don't let errors with one stop the others. -#if SUNOS_SPARC || XMP_IOS_ARM +#if SUNOS_SPARC || XMP_IOS_ARM || XMP_ANDROID_ARM XMP_Uns32 binPtr[2]; memcpy(&binPtr, tagInfo.dataPtr, sizeof(XMP_Uns32)*2); #else XMP_Uns32 * binPtr = (XMP_Uns32*)tagInfo.dataPtr; -#endif //#if SUNOS_SPARC || XMP_IOS_ARM +#endif //#if SUNOS_SPARC || XMP_IOS_ARM || XMP_ANDROID_ARM XMP_Int32 binNum = GetUns32AsIs ( &binPtr[0] ); XMP_Int32 binDenom = GetUns32AsIs ( &binPtr[1] ); if ( ! nativeEndian ) { @@ -1248,6 +1253,14 @@ bool found = tiff.GetTag ( ifd, mapInfo.id, &tagInfo ); if ( ! found ) continue; + /* tag length need to be checked in case of TIFF_MemoryReader, as a possible case + the data length value might be changed (flippig because of endianess) by next overlapping IFD leading to crash. + To avoid that, rechecking the datalen just before its access. Fixing CTECHXMP-4170409*/ + if(tiff.IsCheckTagLength() && + tagInfo.dataLen > tiff.GetTiffLength() - ((XMP_Uns8*)tagInfo.dataPtr - tiff.GetTiffStream())) { + continue; // Bad Tag + } + XMP_Assert ( tagInfo.type != kTIFF_UndefinedType ); // These must have a special mapping. if ( tagInfo.type == kTIFF_UndefinedType ) continue; @@ -1277,7 +1290,7 @@ // ImportTIFF_Date // =============== // -// Convert an Exif 2.2 master date/time tag plus associated fractional seconds to an XMP date/time. +// Convert an Exif 2.2 main date/time tag plus associated fractional seconds to an XMP date/time. // The Exif date/time part is a 20 byte ASCII value formatted as "YYYY:MM:DD HH:MM:SS" with a // terminating nul. Any of the numeric portions can be blanks if unknown. The fractional seconds // are a nul terminated ASCII string with possible space padding. They are literally the fractional @@ -1287,11 +1300,14 @@ ImportTIFF_Date ( const TIFF_Manager & tiff, const TIFF_Manager::TagInfo & dateInfo, SXMPMeta * xmp, const char * xmpNS, const char * xmpProp ) { - XMP_Uns16 secID = 0; + XMP_Uns16 secID = 0, offsetID = 0; switch ( dateInfo.id ) { - case kTIFF_DateTime : secID = kTIFF_SubSecTime; break; - case kTIFF_DateTimeOriginal : secID = kTIFF_SubSecTimeOriginal; break; - case kTIFF_DateTimeDigitized : secID = kTIFF_SubSecTimeDigitized; break; + case kTIFF_DateTime : secID = kTIFF_SubSecTime; + offsetID = kTIFF_OffsetTime; break; + case kTIFF_DateTimeOriginal : secID = kTIFF_SubSecTimeOriginal; + offsetID = kTIFF_OffsetTimeOriginal; break; + case kTIFF_DateTimeDigitized : secID = kTIFF_SubSecTimeDigitized; + offsetID = kTIFF_OffsetTimeDigitized; break; } try { // Don't let errors with one stop the others. @@ -1332,7 +1348,31 @@ for ( ; digits < 9; ++digits ) binValue.nanoSecond *= 10; if ( binValue.nanoSecond != 0 ) binValue.hasTime = true; } + // The offset time tags were added to EXIF spec 2.3.1., therefore we not + // supporting read/write in older versions + // We need EXIF spec version to figure out the same. + bool haveOldExif = true; // Default to old Exif if no version tag. + TIFF_Manager::TagInfo tagInfo; + bool foundExif = tiff.GetTag ( kTIFF_ExifIFD, kTIFF_ExifVersion, &tagInfo ); + if ( foundExif && (tagInfo.type == kTIFF_UndefinedType) && (tagInfo.count == 4) ) { + haveOldExif = (strncmp ( (char*)tagInfo.dataPtr, "0231", 4 ) < 0); + } + + if (!haveOldExif) + { + TIFF_Manager::TagInfo timezoneInfo; + found = tiff.GetTag ( kTIFF_ExifIFD, offsetID, &timezoneInfo ); + if ( found && (timezoneInfo.type == kTIFF_ASCIIType) && (timezoneInfo.count == 7) ) { + const char * timezoneStr = (const char *) timezoneInfo.dataPtr; + if ( (timezoneStr[0] == '+') || (timezoneStr[0] == '-') || (timezoneStr[3] == ':') ) { + binValue.tzSign = (timezoneStr[0] == '-') ? -1 : 1; + binValue.tzHour = GatherInt ( &timezoneStr[1], 2 ); + binValue.tzMinute = GatherInt ( &timezoneStr[4], 2 ); + binValue.hasTimeZone = true; + } + } + } xmp->SetProperty_Date ( xmpNS, xmpProp, binValue ); } catch ( ... ) { @@ -2036,7 +2076,7 @@ size_t count = (size_t) xmp->CountArrayItems ( kXMP_NS_ExifEX, "LensSpecification" ); if ( count > 0 ) { (void) xmp->GetArrayItem ( kXMP_NS_ExifEX, "LensSpecification", 1, &fullStr, 0 ); - for ( size_t i = 2; i <= count; ++i ) { + for ( XMP_Index i = 2; i <= (XMP_Index)count; ++i ) { fullStr += ' '; (void) xmp->GetArrayItem ( kXMP_NS_ExifEX, "LensSpecification", i, &oneItem, 0 ); fullStr += oneItem; @@ -2205,13 +2245,13 @@ xmp->SetProperty ( kXMP_NS_EXIF, "GPSVersionID", strOut ); } - // 2 GPSLatitude is a GPS coordinate master. + // 2 GPSLatitude is a GPS coordinate main. found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSLatitude, &tagInfo ); if ( found ) { ImportTIFF_GPSCoordinate ( exif, tagInfo, xmp, kXMP_NS_EXIF, "GPSLatitude" ); } - // 4 GPSLongitude is a GPS coordinate master. + // 4 GPSLongitude is a GPS coordinate main. found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSLongitude, &tagInfo ); if ( found ) { ImportTIFF_GPSCoordinate ( exif, tagInfo, xmp, kXMP_NS_EXIF, "GPSLongitude" ); @@ -2223,13 +2263,13 @@ ImportTIFF_GPSTimeStamp ( exif, tagInfo, xmp, kXMP_NS_EXIF, "GPSTimeStamp" ); } - // 20 GPSDestLatitude is a GPS coordinate master. + // 20 GPSDestLatitude is a GPS coordinate main. found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSDestLatitude, &tagInfo ); if ( found ) { ImportTIFF_GPSCoordinate ( exif, tagInfo, xmp, kXMP_NS_EXIF, "GPSDestLatitude" ); } - // 22 GPSDestLongitude is a GPS coordinate master. + // 22 GPSDestLongitude is a GPS coordinate main. found = exif.GetTag ( kTIFF_GPSInfoIFD, kTIFF_GPSDestLongitude, &tagInfo ); if ( found ) { ImportTIFF_GPSCoordinate ( exif, tagInfo, xmp, kXMP_NS_EXIF, "GPSDestLongitude" ); @@ -2345,67 +2385,87 @@ TIFF_Manager::TagInfo exifInfo; IPTC_Manager::DataSetInfo iptcInfo; + + IPTC_Writer oldIPTC; - if ( iptcDigestState == kDigestDiffers ) { - PhotoDataUtils::ExportIPTC ( *xmp, &oldIPTC ); // Predict old IPTC DataSets based on the existing XMP. + if (iptcDigestState == kDigestDiffers) { + PhotoDataUtils::ExportIPTC(*xmp, &oldIPTC); // Predict old IPTC DataSets based on the existing XMP. } - + // --------------------------------------------------------------------------------- // Process the copyright. Replace internal nuls in the Exif to "merge" the portions. - + // Get the basic info about available values. - haveXMP = xmp->GetLocalizedText ( kXMP_NS_DC, "rights", "", "x-default", 0, &xmpValue, 0 ); - iptcCount = PhotoDataUtils::GetNativeInfo ( iptc, kIPTC_CopyrightNotice, iptcDigestState, haveXMP, &iptcInfo ); - haveIPTC = (iptcCount > 0); - haveExif = (! haveXMP) && (! haveIPTC) && PhotoDataUtils::GetNativeInfo ( exif, kTIFF_PrimaryIFD, kTIFF_Copyright, &exifInfo ); - XMP_Assert ( (! (haveExif & haveXMP)) & (! (haveExif & haveIPTC)) ); + haveXMP = xmp->GetLocalizedText(kXMP_NS_DC, "rights", "", "x-default", 0, &xmpValue, 0); + iptcCount = PhotoDataUtils::GetNativeInfo(iptc, kIPTC_CopyrightNotice, iptcDigestState, haveXMP, &iptcInfo); + haveIPTC = (iptcCount > 0); + haveExif = (!haveXMP) && (!haveIPTC) && PhotoDataUtils::GetNativeInfo(exif, kTIFF_PrimaryIFD, kTIFF_Copyright, &exifInfo); + XMP_Assert((!(haveExif & haveXMP)) & (!(haveExif & haveIPTC))); - if ( haveExif && (exifInfo.dataLen > 1) ) { // Replace internal nul characters with linefeed. - for ( XMP_Uns32 i = 0; i < exifInfo.dataLen-1; ++i ) { - if ( ((char*)exifInfo.dataPtr)[i] == 0 ) ((char*)exifInfo.dataPtr)[i] = 0x0A; + if (haveExif && (exifInfo.dataLen > 1)) { // Replace internal nul characters with linefeed. + for (XMP_Uns32 i = 0; i < exifInfo.dataLen - 1; ++i) { + if (((char*)exifInfo.dataPtr)[i] == 0) ((char*)exifInfo.dataPtr)[i] = 0x0A; } } - - if ( haveIPTC && ((iptcDigestState == kDigestDiffers) || (!haveXMP && !haveExif)) ) { - PhotoDataUtils::ImportIPTC_LangAlt ( iptc, xmp, kIPTC_CopyrightNotice, kXMP_NS_DC, "rights" ); - } else if ( haveExif && PhotoDataUtils::IsValueDifferent ( exifInfo, xmpValue, &exifValue ) ) { - xmp->SetLocalizedText ( kXMP_NS_DC, "rights", "", "x-default", exifValue.c_str() ); + try { + if (haveIPTC && ((iptcDigestState == kDigestDiffers) || (!haveXMP && !haveExif))) { + PhotoDataUtils::ImportIPTC_LangAlt(iptc, xmp, kIPTC_CopyrightNotice, kXMP_NS_DC, "rights"); + } + else if (haveExif && PhotoDataUtils::IsValueDifferent(exifInfo, xmpValue, &exifValue)) { + xmp->SetLocalizedText(kXMP_NS_DC, "rights", "", "x-default", exifValue.c_str()); + } } - + catch (...) { + } + + // ------------------------ // Process the description. - + // Get the basic info about available values. - haveXMP = xmp->GetLocalizedText ( kXMP_NS_DC, "description", "", "x-default", 0, &xmpValue, 0 ); - iptcCount = PhotoDataUtils::GetNativeInfo ( iptc, kIPTC_Description, iptcDigestState, haveXMP, &iptcInfo ); - haveIPTC = (iptcCount > 0); - haveExif = (! haveXMP) && (! haveIPTC) && PhotoDataUtils::GetNativeInfo ( exif, kTIFF_PrimaryIFD, kTIFF_ImageDescription, &exifInfo ); - XMP_Assert ( (! (haveExif & haveXMP)) & (! (haveExif & haveIPTC)) ); - - if ( haveIPTC && ((iptcDigestState == kDigestDiffers) || (!haveXMP && !haveExif)) ) { - PhotoDataUtils::ImportIPTC_LangAlt ( iptc, xmp, kIPTC_Description, kXMP_NS_DC, "description" ); - } else if ( haveExif && PhotoDataUtils::IsValueDifferent ( exifInfo, xmpValue, &exifValue ) ) { - xmp->SetLocalizedText ( kXMP_NS_DC, "description", "", "x-default", exifValue.c_str() ); + haveXMP = xmp->GetLocalizedText(kXMP_NS_DC, "description", "", "x-default", 0, &xmpValue, 0); + iptcCount = PhotoDataUtils::GetNativeInfo(iptc, kIPTC_Description, iptcDigestState, haveXMP, &iptcInfo); + haveIPTC = (iptcCount > 0); + haveExif = (!haveXMP) && (!haveIPTC) && PhotoDataUtils::GetNativeInfo(exif, kTIFF_PrimaryIFD, kTIFF_ImageDescription, &exifInfo); + XMP_Assert((!(haveExif & haveXMP)) & (!(haveExif & haveIPTC))); + + try { + if (haveIPTC && ((iptcDigestState == kDigestDiffers) || (!haveXMP && !haveExif))) { + PhotoDataUtils::ImportIPTC_LangAlt(iptc, xmp, kIPTC_Description, kXMP_NS_DC, "description"); + } + else if (haveExif && PhotoDataUtils::IsValueDifferent(exifInfo, xmpValue, &exifValue)) { + xmp->SetLocalizedText(kXMP_NS_DC, "description", "", "x-default", exifValue.c_str()); + } + } + catch (...) { + } // ------------------------------------------------------------------------------------------- // Process the creator. The XMP and IPTC are arrays, the Exif is a semicolon separated string. - + // Get the basic info about available values. - haveXMP = xmp->DoesPropertyExist ( kXMP_NS_DC, "creator" ); - haveExif = PhotoDataUtils::GetNativeInfo ( exif, kTIFF_PrimaryIFD, kTIFF_Artist, &exifInfo ); - iptcCount = PhotoDataUtils::GetNativeInfo ( iptc, kIPTC_Creator, iptcDigestState, haveXMP, &iptcInfo ); - haveIPTC = (iptcCount > 0); - haveExif = (! haveXMP) && (! haveIPTC) && PhotoDataUtils::GetNativeInfo ( exif, kTIFF_PrimaryIFD, kTIFF_Artist, &exifInfo ); - XMP_Assert ( (! (haveExif & haveXMP)) & (! (haveExif & haveIPTC)) ); + + haveXMP = xmp->DoesPropertyExist(kXMP_NS_DC, "creator"); + haveExif = PhotoDataUtils::GetNativeInfo(exif, kTIFF_PrimaryIFD, kTIFF_Artist, &exifInfo); + iptcCount = PhotoDataUtils::GetNativeInfo(iptc, kIPTC_Creator, iptcDigestState, haveXMP, &iptcInfo); + haveIPTC = (iptcCount > 0); + haveExif = (!haveXMP) && (!haveIPTC) && PhotoDataUtils::GetNativeInfo(exif, kTIFF_PrimaryIFD, kTIFF_Artist, &exifInfo); + XMP_Assert((!(haveExif & haveXMP)) & (!(haveExif & haveIPTC))); + + try { + if (haveIPTC && ((iptcDigestState == kDigestDiffers) || (!haveXMP && !haveExif))) { + PhotoDataUtils::ImportIPTC_Array(iptc, xmp, kIPTC_Creator, kXMP_NS_DC, "creator"); + } + else if (haveExif && PhotoDataUtils::IsValueDifferent(exifInfo, xmpValue, &exifValue)) { + SXMPUtils::SeparateArrayItems(xmp, kXMP_NS_DC, "creator", + (kXMP_PropArrayIsOrdered | kXMPUtil_AllowCommas), exifValue); + } + } + catch (...) { - if ( haveIPTC && ((iptcDigestState == kDigestDiffers) || (!haveXMP && !haveExif)) ) { - PhotoDataUtils::ImportIPTC_Array ( iptc, xmp, kIPTC_Creator, kXMP_NS_DC, "creator" ); - } else if ( haveExif && PhotoDataUtils::IsValueDifferent ( exifInfo, xmpValue, &exifValue ) ) { - SXMPUtils::SeparateArrayItems ( xmp, kXMP_NS_DC, "creator", - (kXMP_PropArrayIsOrdered | kXMPUtil_AllowCommas), exifValue ); } - + // ------------------------------------------------------------------------------ // Process DateTimeDigitized; DateTimeOriginal and DateTime are 2-way. // *** Exif DateTimeOriginal <-> XMP exif:DateTimeOriginal @@ -2413,7 +2473,8 @@ // *** Exif DateTimeDigitized <-> IPTC DigitalCreateDate <-> XMP xmp:CreateDate // *** TIFF DateTime <-> XMP xmp:ModifyDate - Import3WayDateTime ( kTIFF_DateTimeDigitized, exif, iptc, xmp, iptcDigestState, oldIPTC ); + Import3WayDateTime(kTIFF_DateTimeDigitized, exif, iptc, xmp, iptcDigestState, oldIPTC); + } // PhotoDataUtils::Import3WayItems @@ -2665,7 +2726,7 @@ // ExportTIFF_Date // =============== // -// Convert an XMP date/time to an Exif 2.2 master date/time tag plus associated fractional seconds. +// Convert an XMP date/time to an Exif 2.2 main date/time tag plus associated fractional seconds. // The Exif date/time part is a 20 byte ASCII value formatted as "YYYY:MM:DD HH:MM:SS" with a // terminating nul. The fractional seconds are a nul terminated ASCII string with possible space // padding. They are literally the fractional part, the digits that would be to the right of the @@ -2676,10 +2737,18 @@ { XMP_Uns8 mainIFD = kTIFF_ExifIFD; XMP_Uns16 fracID=0; + XMP_Uns16 offsetID=0; switch ( mainID ) { - case kTIFF_DateTime : mainIFD = kTIFF_PrimaryIFD; fracID = kTIFF_SubSecTime; break; - case kTIFF_DateTimeOriginal : fracID = kTIFF_SubSecTimeOriginal; break; - case kTIFF_DateTimeDigitized : fracID = kTIFF_SubSecTimeDigitized; break; + case kTIFF_DateTime : mainIFD = kTIFF_PrimaryIFD; + fracID = kTIFF_SubSecTime; + offsetID = kTIFF_OffsetTime; + break; + case kTIFF_DateTimeOriginal : fracID = kTIFF_SubSecTimeOriginal; + offsetID = kTIFF_OffsetTimeOriginal; + break; + case kTIFF_DateTimeDigitized : fracID = kTIFF_SubSecTimeDigitized; + offsetID = kTIFF_OffsetTimeDigitized; + break; } try { // Don't let errors with one stop the others. @@ -2689,6 +2758,7 @@ if ( ! foundXMP ) { tiff->DeleteTag ( mainIFD, mainID ); tiff->DeleteTag ( kTIFF_ExifIFD, fracID ); // ! The subseconds are always in the Exif IFD. + tiff->DeleteTag ( kTIFF_ExifIFD, offsetID );// ! The offsetTime are always in the Exif IFD. return; } @@ -2733,23 +2803,53 @@ if ( xmpBin.nanoSecond == 0 ) { tiff->DeleteTag ( kTIFF_ExifIFD, fracID ); - - } else { - - snprintf ( buffer, sizeof(buffer), "%09d", xmpBin.nanoSecond ); // AUDIT: Use of sizeof(buffer) is safe. - for ( size_t i = strlen(buffer)-1; i > 0; --i ) { - if ( buffer[i] != '0' ) break; - buffer[i] = 0; // Strip trailing zero digits. + } + else + { + snprintf(buffer, sizeof(buffer), "%09d", xmpBin.nanoSecond); // AUDIT: Use of sizeof(buffer) is safe. + for (size_t i = strlen(buffer) - 1; i > 0; --i) + { + if (buffer[i] != '0') + break; + buffer[i] = 0; // Strip trailing zero digits. } + tiff->SetTag_ASCII(kTIFF_ExifIFD, fracID, buffer); // ! The subseconds are always in the Exif IFD. + } - tiff->SetTag_ASCII ( kTIFF_ExifIFD, fracID, buffer ); // ! The subseconds are always in the Exif IFD. + bool haveOldExif = true; // Default to old Exif if no version tag. + TIFF_Manager::TagInfo tagInfo; + bool foundExif = tiff->GetTag ( kTIFF_ExifIFD, kTIFF_ExifVersion, &tagInfo ); + if ( foundExif && (tagInfo.type == kTIFF_UndefinedType) && (tagInfo.count == 4) ) { + haveOldExif = (strncmp ( (char*)tagInfo.dataPtr, "0231", 4 ) < 0); + } + if (!haveOldExif) + { + // The offset time tags were added to EXIF spec 2.3.1., therefore we are not + // supporting read/write in older versions + // We need EXIF spec version to figure out the same. + + if ( xmpBin.hasTimeZone == 0 || (xmpBin.tzSign != -1 && xmpBin.tzSign != 1) ){ + + tiff->DeleteTag ( kTIFF_ExifIFD, offsetID ); + + }else + { + char tzSign = '+'; + if (xmpBin.tzSign == -1) + tzSign = '-'; + + char offsetBuffer[7]; + snprintf(offsetBuffer, sizeof(offsetBuffer), "%c%02d:%02d", // AUDIT: Use of sizeof(offsetBuffer) is safe. + tzSign, xmpBin.tzHour, xmpBin.tzMinute); + tiff->SetTag_ASCII(kTIFF_ExifIFD, offsetID, offsetBuffer); // ! The OffsetTime are always in the Exif IFD. + } } } catch ( ... ) { // Do nothing, let other exports proceed. // ? Notify client? - } + } } // ExportTIFF_Date @@ -3023,7 +3123,7 @@ XMP_Uns32 oldDenom = tiff->GetUns32 ( &(((XMP_Uns32*)oldInfo.dataPtr)[5]) ); if ( oldDenom != 1 ) denom = oldDenom; } - fSec *= denom; + fSec = fSec * denom + 0.5; while ( fSec > mMaxSec ) { fSec /= 10; denom /= 10; } tiff->PutUns32 ( (XMP_Uns32)fSec, &exifTime[4] ); tiff->PutUns32 ( denom, &exifTime[5] ); diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/RIFF.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/RIFF.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/RIFF.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/RIFF.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2009 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2009 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -141,12 +141,12 @@ // BASE CLASS CHUNK /////////////////////////////////////////////// // ad hoc creation -Chunk::Chunk( ContainerChunk* parent_, ChunkType c, XMP_Uns32 id_ ) +Chunk::Chunk( ContainerChunk* _parent, ChunkType c, XMP_Uns32 _id ) { this->hasChange = false; this->chunkType = c; // base class assumption - this->parent = parent_; - this->id = id_; + this->parent = _parent; + this->id = _id; this->oldSize = 0; this->newSize = 8; this->oldPos = 0; // inevitable for ad-hoc @@ -162,10 +162,10 @@ } // parsing creation -Chunk::Chunk( ContainerChunk* parent_, RIFF_MetaHandler* handler, bool skip, ChunkType c ) +Chunk::Chunk( ContainerChunk* _parent, RIFF_MetaHandler* handler, bool skip, ChunkType c ) { chunkType = c; // base class assumption - this->parent = parent_; + this->parent = _parent; this->oldSize = 0; this->hasChange = false; // [2414649] valid assumption at creation time @@ -179,12 +179,16 @@ // Make sure the size is within expected bounds. XMP_Int64 chunkEnd = this->oldPos + this->oldSize; XMP_Int64 chunkLimit = handler->oldFileSize; - if ( parent_ != 0 ) chunkLimit = parent_->oldPos + parent_->oldSize; + if ( _parent != 0 ) chunkLimit = _parent->oldPos + _parent->oldSize; if ( chunkEnd > chunkLimit ) { bool isUpdate = XMP_OptionIsSet ( handler->parent->openFlags, kXMPFiles_OpenForUpdate ); bool repairFile = XMP_OptionIsSet ( handler->parent->openFlags, kXMPFiles_OpenRepairFile ); - if ( (! isUpdate) || (repairFile && (parent_ == 0)) ) { + if ( (! isUpdate) || (repairFile && (_parent == 0)) ) { this->oldSize = chunkLimit - this->oldPos; + if (this->oldSize < 8) + { + XMP_Throw("Invalid RIFF chunk size", kXMPErr_BadFileFormat); + } } else { XMP_Throw ( "Bad RIFF chunk size", kXMPErr_BadFileFormat ); } @@ -237,12 +241,12 @@ // CONTAINER CHUNK ///////////////////////////////////////////////// // a) creation // [2376832] expectedSize - minimum padding "parking size" to use, if not available append to end -ContainerChunk::ContainerChunk( ContainerChunk* parent_, XMP_Uns32 id_, XMP_Uns32 containerType ) : Chunk( NULL /* !! */, chunk_CONTAINER, id_ ) +ContainerChunk::ContainerChunk( ContainerChunk* parent_, XMP_Uns32 id_, XMP_Uns32 _containerType ) : Chunk( NULL /* !! */, chunk_CONTAINER, id_ ) { // accept no unparented ConatinerChunks XMP_Enforce( parent_ != NULL ); - this->containerType = containerType; + this->containerType = _containerType; this->newSize = 12; this->parent = parent_; @@ -253,7 +257,7 @@ } // b) parsing -ContainerChunk::ContainerChunk( ContainerChunk* parent, RIFF_MetaHandler* handler ) : Chunk( parent, handler, false, chunk_CONTAINER ) +ContainerChunk::ContainerChunk( ContainerChunk* parent_, RIFF_MetaHandler* handler ) : Chunk( parent_, handler, false, chunk_CONTAINER ) { bool repairMode = ( 0 != ( handler->parent->openFlags & kXMPFiles_OpenRepairFile )); @@ -611,9 +615,9 @@ chunkVectIter iter; for( iter = this->children.begin(); iter != this->children.end(); iter++ ) { - char buffer[256]; - snprintf( buffer, 250, "offset 0x%.8llX", offset ); - r += std::string ( level*4, ' ' ) + std::string( buffer ) + ":" + (*iter)->toString( level + 1 ); + char lBuffer[256]; + snprintf( lBuffer, 250, "offset 0x%.8llX", offset ); + r += std::string ( level*4, ' ' ) + std::string( lBuffer ) + ":" + (*iter)->toString( level + 1 ); offset += (*iter)->newSize; if ( offset % 2 == 1 ) offset++; @@ -718,7 +722,7 @@ void XMPChunk::changesAndSize( RIFF_MetaHandler* handler ) { - XMP_Enforce( &handler->xmpPacket != 0 ); + //XMP_Enforce( &handler->xmpPacket != 0 ); XMP_Enforce( handler->xmpPacket.size() > 0 ); this->newSize = 8 + handler->xmpPacket.size(); diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/RIFF.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/RIFF.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/RIFF.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/RIFF.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __RIFF_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2009 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2009 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -175,11 +175,11 @@ // ================================================================================================= // ImportCr8rItems // =============== -#if SUNOS_SPARC || SUNOS_X86 +#if SUNOS_SPARC || SUNOS_X86 || XMP_ANDROID_ARM #pragma pack ( 1 ) #else #pragma pack ( push, 1 ) -#endif //#if SUNOS_SPARC || SUNOS_X86 +#endif //#if SUNOS_SPARC || SUNOS_X86 || XMP_ANDROID_ARM struct PrmLBoxContent { XMP_Uns32 magic; XMP_Uns32 size; @@ -204,7 +204,7 @@ char appOptions[16]; char appName[32]; }; -#if SUNOS_SPARC || SUNOS_X86 +#if SUNOS_SPARC || SUNOS_X86 || XMP_AndroidBuild #pragma pack ( ) #else #pragma pack ( pop ) diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/RIFF_Support.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/RIFF_Support.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/RIFF_Support.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/RIFF_Support.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,14 +1,16 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2008 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2008 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. +#include + #include "public/include/XMP_Const.h" #include "public/include/XMP_IO.hpp" @@ -22,7 +24,6 @@ #include "XMPFiles/source/FormatSupport/RIFF_Support.hpp" #include "XMPFiles/source/FormatSupport/Reconcile_Impl.hpp" -#include #define MIN(a, b) ((a) < (b) ? (a) : (b)) @@ -655,7 +656,7 @@ lastChunk->getChild( handler->xmpChunk ) == lastChunk->children.end() // not already in last chunk? ) { - RIFF::ContainerChunk* cur; + RIFF::ContainerChunk* cur = NULL; chunkVectIter child; XMP_Int32 chunkNo; diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/RIFF_Support.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/RIFF_Support.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/RIFF_Support.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/RIFF_Support.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __RIFF_Support_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2009 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2009 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/SVG_Adapter.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/SVG_Adapter.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/SVG_Adapter.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/SVG_Adapter.cpp 2022-02-12 23:39:28.000000000 +0000 @@ -1,14 +1,14 @@ // ================================================================================================= -// Copyright 2015 Adobe Systems Incorporated +// Copyright 2015 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // -// This file includes implementation of SVG metadata, according to Scalable Vector Graphics (SVG) 1.1 Specification. +// This file includes implementation of SVG metadata, according to Scalable Vector Graphics (SVG) 1.1 Specification. // "https://www.w3.org/TR/2003/REC-SVG11-20030114/" -// Copyright © 1994-2002 World Wide Web Consortium, (Massachusetts Institute of Technology, -// Institut National de Recherche en Informatique et en Automatique, Keio University). +// Copyright © 1994-2002 World Wide Web Consortium, (Massachusetts Institute of Technology, +// Institut National de Recherche en Informatique et en Automatique, Keio University). // All Rights Reserved . http://www.w3.org/Consortium/Legal // // ================================================================================================= @@ -134,7 +134,7 @@ XMP_Uns32 index = 0; IteratorStringXMP_Int64 indexIterator = iterator.first; for ( ; index < ( requiredIndex - 1 ) && indexIterator != iterator.second; ++indexIterator, ++index ); - if ( index == requiredIndex - 1 ) + if ( indexIterator != this->mPIWithOffsetMap.end() && index == requiredIndex - 1 ) return indexIterator->second; } } @@ -183,7 +183,7 @@ #if BanAllEntityUsage if ( this->isAborted ) { XMP_Error error( kXMPErr_BadXML, "DOCTYPE is not allowed" ); - this->NotifyClient( kXMPErrSev_Recoverable, error ); + this->NotifyClient( kXMPErrSev_Recoverable, error ); } #endif @@ -211,12 +211,19 @@ length = 1; } - status = XML_Parse( this->parser, ( const char * ) buffer, static_cast< XMP_StringLen >( length ), last ); + try + { + status = XML_Parse(this->parser, (const char *)buffer, static_cast(length), last); + } + catch (XMP_Error &e) + { + return false; //Don't let one failure abort checking other file formats , this api is called only from checkFileFormat + } #if BanAllEntityUsage if ( this->isAborted ) { XMP_Error error( kXMPErr_BadXML, "DOCTYPE is not allowed" ); - this->NotifyClient( kXMPErrSev_Recoverable, error ); + this->NotifyClient( kXMPErrSev_Recoverable, error ); } #endif @@ -233,6 +240,8 @@ { // Expat delivers the full name as a catenation of namespace URI, separator, and local name. size_t sepPos = strlen( fullName ); + if (!sepPos) + return; //Throw? for ( --sepPos; sepPos > 0; --sepPos ) { if ( fullName[ sepPos ] == FullNameSeparator ) break; } @@ -300,6 +309,9 @@ if ( iterator == thiz->mOffsetsMap.end() && localName != "svg" ) return; + if( thiz->depth > 2 && ( localName == "metadata" || localName == "title" || localName == "desc" ) ) + return; + XML_Node * parentNode = thiz->parseStack.back(); XML_Node * elemNode = new XML_Node( parentNode, "", kElemNode ); @@ -315,7 +327,7 @@ elemNode->ns = NS; elemNode->nsPrefixLen = prefixLen; // ! Includes the ':'. - if ( strcmp( prefix, "_dflt_:" ) == 0 ) + if ( strcmp( prefix, "_dflt_:" ) == 0 || ( (localName == "svg" || localName == "metadata") && NS == kURI_SVG) ) { elemNode->name = localName; elemNode->nsPrefixLen = 0; @@ -361,6 +373,9 @@ string NS, localName; ParseFullNS( name, NS, localName ); + if(thiz->depth > 1 && ( localName == "metadata" || localName == "title" || localName == "desc" )) + return; + IteratorStringOffsetStruct iterator = thiz->mOffsetsMap.find( localName ); if ( iterator != thiz->mOffsetsMap.end() ) { @@ -408,7 +423,14 @@ return; // Ignore all PIs except the XMP packet wrapper. SVG_Adapter * thiz = ( SVG_Adapter* ) userData; XML_Node * parentNode = thiz->parseStack.back(); - if ( parentNode->name != "metadata" ) + + XMP_VarString nsURI = parentNode->ns; + XMP_VarString elementName = parentNode->name; + //remove prefix from name if any + size_t colonPos = elementName.find ( ':' ); + XMP_VarString parentNodeName ( elementName.substr ( colonPos + 1 , elementName.size() - colonPos ) ); + + if ( nsURI != kURI_SVG || parentNodeName != "metadata" ) return; IteratorStringXMP_Int64 iterator = thiz->mPIWithOffsetMap.find( target ); if ( iterator != thiz->mPIWithOffsetMap.end() ) diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/SVG_Adapter.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/SVG_Adapter.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/SVG_Adapter.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/SVG_Adapter.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,15 +2,15 @@ #define __SVG_Adapter_hpp__ // ================================================================================================= -// Copyright 2015 Adobe Systems Incorporated +// Copyright 2015 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // // This file includes implementation of SVG metadata, according to Scalable Vector Graphics (SVG) 1.1 Specification. // "https://www.w3.org/TR/2003/REC-SVG11-20030114/" -// Copyright © 1994-2002 World Wide Web Consortium, (Massachusetts Institute of Technology, +// Copyright 1994-2002 World Wide Web Consortium, (Massachusetts Institute of Technology, // Institut National de Recherche en Informatique et en Automatique, Keio University). // All Rights Reserved . http://www.w3.org/Consortium/Legal // @@ -31,6 +31,8 @@ typedef struct XML_ParserStruct *XML_Parser; typedef std::map::iterator IteratorStringXMP_Int64; +#define kURI_SVG "http://www.w3.org/2000/svg" + struct OffsetStruct { XMP_Int64 startOffset; diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/SWF_Support.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/SWF_Support.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/SWF_Support.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/SWF_Support.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2007 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2007 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -38,7 +38,7 @@ bool SWF_IO::GetTagInfo ( const RawDataBlock & swfStream, XMP_Uns32 tagOffset, SWF_IO::TagInfo * info ) { if ( tagOffset >= swfStream.size() ) return false; - XMP_Uns32 spaceLeft = swfStream.size() - tagOffset; + XMP_Uns32 spaceLeft = (XMP_Uns32)swfStream.size() - tagOffset; XMP_Uns8 headerSize = 2; if ( spaceLeft < headerSize ) return false; // The minimum empty tag is a 2 byte header. @@ -228,13 +228,13 @@ PutUns32LE ( SWF_IO::CompressedSignature, &bufferOut[0] ); bufferOut[3] = dataIn[3]; // Copy the SWF version. - PutUns32LE ( lengthIn, &bufferOut[4] ); + PutUns32LE ( (XMP_Uns32)lengthIn, &bufferOut[4] ); fileOut->Write ( bufferOut, SWF_IO::HeaderPrefixSize ); // Feed the input to the compression engine in one step, write the output as available. zipState.next_in = (Bytef*)&dataIn[SWF_IO::HeaderPrefixSize]; - zipState.avail_in = lengthIn - SWF_IO::HeaderPrefixSize; + zipState.avail_in = (XMP_Uns32)lengthIn - SWF_IO::HeaderPrefixSize; zipState.next_out = &bufferOut[0]; zipState.avail_out = bufferSize; diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/SWF_Support.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/SWF_Support.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/SWF_Support.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/SWF_Support.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __SWF_Support_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2008 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2008 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/TIFF_FileWriter.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/TIFF_FileWriter.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/TIFF_FileWriter.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/TIFF_FileWriter.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -700,9 +700,9 @@ if ( (tagType < kTIFF_ByteType) || (tagType > kTIFF_LastType) ) continue; // Bad type, skip this tag. XMP_Uns16 tagID = this->GetUns16 ( &rawTag->id ); - XMP_Uns32 tagCount = this->GetUns32 ( &rawTag->count ); + XMP_Uns32 tagCnt = this->GetUns32 ( &rawTag->count ); - InternalTagMap::value_type mapValue ( tagID, InternalTagInfo ( tagID, tagType, tagCount, kIsMemoryBased ) ); + InternalTagMap::value_type mapValue ( tagID, InternalTagInfo ( tagID, tagType, tagCnt, kIsMemoryBased ) ); InternalTagMap::iterator newPos = ifdInfo.tagMap.insert ( ifdInfo.tagMap.end(), mapValue ); InternalTagInfo& mapTag = newPos->second; @@ -895,9 +895,9 @@ if ( (tagType < kTIFF_ByteType) || (tagType > kTIFF_LastType) ) continue; // Bad type, skip this tag. XMP_Uns16 tagID = this->GetUns16 ( &rawTag->id ); - XMP_Uns32 tagCount = this->GetUns32 ( &rawTag->count ); + XMP_Uns32 tagCnt = this->GetUns32 ( &rawTag->count ); - InternalTagMap::value_type mapValue ( tagID, InternalTagInfo ( tagID, tagType, tagCount, kIsFileBased ) ); + InternalTagMap::value_type mapValue ( tagID, InternalTagInfo ( tagID, tagType, tagCnt, kIsFileBased ) ); InternalTagMap::iterator newPos = ifdInfo.tagMap.insert ( ifdInfo.tagMap.end(), mapValue ); InternalTagInfo& mapTag = newPos->second; @@ -971,17 +971,17 @@ } // TIFF_FileWriter::IntegrateFromPShop6 // ================================================================================================= -// TIFF_FileWriter::CopyTagToMasterIFD +// TIFF_FileWriter::CopyTagToMainIFD // =================================== // -// Create a new master IFD entry from a buried Photoshop 6 IFD entry. Don't try to get clever with +// Create a new main IFD entry from a buried Photoshop 6 IFD entry. Don't try to get clever with // large values, just create a new copy. This preserves a clean separation between the memory-based // and file-based TIFF processing. -void* TIFF_FileWriter::CopyTagToMasterIFD ( const TagInfo & ps6Tag, InternalIFDInfo * masterIFD ) +void* TIFF_FileWriter::CopyTagToMainIFD ( const TagInfo & ps6Tag, InternalIFDInfo * mainIFD ) { InternalTagMap::value_type mapValue ( ps6Tag.id, InternalTagInfo ( ps6Tag.id, ps6Tag.type, ps6Tag.count, this->fileParsed ) ); - InternalTagMap::iterator newPos = masterIFD->tagMap.insert ( masterIFD->tagMap.end(), mapValue ); + InternalTagMap::iterator newPos = mainIFD->tagMap.insert ( mainIFD->tagMap.end(), mapValue ); InternalTagInfo& newTag = newPos->second; newTag.dataLen = ps6Tag.dataLen; @@ -998,11 +998,11 @@ newTag.changed = true; // ! See comments with ProcessPShop6IFD. XMP_Assert ( (newTag.origDataLen == 0) && (newTag.origDataOffset == 0) ); - masterIFD->changed = true; + mainIFD->changed = true; return newPos->second.dataPtr; // ! Return the address within the map entry for small values. -} // TIFF_FileWriter::CopyTagToMasterIFD +} // TIFF_FileWriter::CopyTagToMainIFD // ================================================================================================= // FlipCFATable @@ -1016,10 +1016,10 @@ XMP_Uns16* u16Ptr = (XMP_Uns16*)voidPtr; - Flip2 ( &u16Ptr[0] ); // Flip the counts to match the master TIFF. + Flip2 ( &u16Ptr[0] ); // Flip the counts to match the main TIFF. Flip2 ( &u16Ptr[1] ); - XMP_Uns16 columns = GetUns16 ( &u16Ptr[0] ); // Fetch using the master TIFF's routine. + XMP_Uns16 columns = GetUns16 ( &u16Ptr[0] ); // Fetch using the main TIFF's routine. XMP_Uns16 rows = GetUns16 ( &u16Ptr[1] ); if ( tagLen != (XMP_Uns32)(4 + columns*rows) ) return false; @@ -1061,10 +1061,10 @@ { XMP_Uns16* u16Ptr = (XMP_Uns16*)voidPtr; - Flip2 ( &u16Ptr[0] ); // Flip the data to match the master TIFF. + Flip2 ( &u16Ptr[0] ); // Flip the data to match the main TIFF. Flip2 ( &u16Ptr[1] ); - XMP_Uns16 columns = GetUns16 ( &u16Ptr[0] ); // Fetch using the master TIFF's routine. + XMP_Uns16 columns = GetUns16 ( &u16Ptr[0] ); // Fetch using the main TIFF's routine. XMP_Uns16 rows = GetUns16 ( &u16Ptr[1] ); XMP_Uns32 minLen = 4 + columns + (8 * columns * rows); // Minimum legit tag size. @@ -1111,25 +1111,25 @@ bool needsFlipping = (this->bigEndian != buriedExif.IsBigEndian()); - InternalIFDInfo* masterIFD = &this->containedIFDs[ifd]; + InternalIFDInfo* mainIFD = &this->containedIFDs[ifd]; TagInfoMap::const_iterator ps6Pos = ps6IFD.begin(); TagInfoMap::const_iterator ps6End = ps6IFD.end(); for ( ; ps6Pos != ps6End; ++ps6Pos ) { - // Copy buried tags to the master IFD if they don't already exist there. + // Copy buried tags to the main IFD if they don't already exist there. const TagInfo& ps6Tag = ps6Pos->second; - if ( this->FindTagInIFD ( ifd, ps6Tag.id ) != 0 ) continue; // Keep existing master tags. + if ( this->FindTagInIFD ( ifd, ps6Tag.id ) != 0 ) continue; // Keep existing main tags. if ( needsFlipping && (ps6Tag.id == 37500) ) continue; // Don't copy an unflipped MakerNote. if ( (ps6Tag.id == kTIFF_ExifIFDPointer) || // Skip the tags that are explicit offsets. (ps6Tag.id == kTIFF_GPSInfoIFDPointer) || (ps6Tag.id == kTIFF_JPEGInterchangeFormat) || (ps6Tag.id == kTIFF_InteroperabilityIFDPointer) ) continue; - void* voidPtr = this->CopyTagToMasterIFD ( ps6Tag, masterIFD ); + void* voidPtr = this->CopyTagToMainIFD ( ps6Tag, mainIFD ); if ( needsFlipping ) { switch ( ps6Tag.type ) { @@ -1509,8 +1509,9 @@ if ( (appendAll | currTag.changed) && (currTag.dataLen > 4) ) { XMP_Uns32 valueOffset = this->GetUns32 ( &currTag.smallValue ); + bool inplaceUpdate = (currTag.dataLen <= currTag.origDataLen) && (! appendAll); - if ( (currTag.dataLen <= currTag.origDataLen) && (! appendAll) ) { + if ( inplaceUpdate ) { XMP_Assert ( valueOffset == currTag.origDataOffset ); } else { XMP_Assert ( valueOffset == appendedOffset ); @@ -1520,7 +1521,10 @@ XMP_Assert ( valueOffset <= newLength ); // Provably true, valueOffset is in the old span, newLength is the new bigger span. if ( currTag.dataLen > (newLength - valueOffset) ) XMP_Throw ( "Buffer overrun", kXMPErr_InternalFailure ); memcpy ( (newStream + valueOffset), currTag.dataPtr, currTag.dataLen ); // AUDIT: Protected by the above check. - if ( (currTag.dataLen & 1) != 0 ) newStream[valueOffset+currTag.dataLen] = 0; + if ( !inplaceUpdate && ((currTag.dataLen & 1) != 0) ) { + newStream[valueOffset+currTag.dataLen] = 0; + + } } @@ -1542,7 +1546,7 @@ } if ( appendedIFDs[kTIFF_TNailIFD] ) { - size_t primaryTagCount = this->containedIFDs[kTIFF_PrimaryIFD].tagMap.size(); + XMP_Uns32 primaryTagCount = (XMP_Uns32)(this->containedIFDs[kTIFF_PrimaryIFD].tagMap.size()); if ( primaryTagCount > 0 ) { XMP_Uns32 tnailLinkOffset = newIFDOffsets[kTIFF_PrimaryIFD] + 2 + (12 * primaryTagCount); this->PutUns32 ( newIFDOffsets[kTIFF_TNailIFD], (newStream + tnailLinkOffset) ); diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/TIFF_MemoryReader.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/TIFF_MemoryReader.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/TIFF_MemoryReader.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/TIFF_MemoryReader.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -70,7 +70,7 @@ } else if ( thisTag == prevTag ) { // Duplicate tag, keep the 2nd copy, move the tail of the array up, prevTag is unchanged. - memmove ( &ifdEntries[i-1], &ifdEntries[i], 12*(tagCount-i) ); // may overlap -- Hub + memmove ( &ifdEntries[i-1], &ifdEntries[i], 12*(tagCount-i) ); // AUDIT: Safe, moving tail forward, i >= 1. --tagCount; --i; // ! Don't move forward in the array, we've moved the unseen part up. @@ -86,24 +86,24 @@ // Out of order duplicate, move it to position j, move the tail of the array up. ifdEntries[j] = ifdEntries[i]; - memmove ( &ifdEntries[i], &ifdEntries[i+1], 12*(tagCount-(i+1)) ); // may overlap -- Hub + memmove ( &ifdEntries[i], &ifdEntries[i+1], 12*(tagCount-(i+1)) ); // AUDIT: Safe, moving tail forward, i >= 1. --tagCount; --i; // ! Don't move forward in the array, we've moved the unseen part up. } else { // Move the out of order entry to position j+1, move the middle of the array down. - #if ! (SUNOS_SPARC || XMP_IOS_ARM) + #if ! (SUNOS_SPARC || XMP_IOS_ARM || XMP_ANDROID_ARM) TweakedIFDEntry temp = ifdEntries[i]; ++j; // ! So the insertion index becomes j. - memmove ( &ifdEntries[j+1], &ifdEntries[j], 12*(i-j) ); // FAILED -- AUDIT: Safe, moving less than i entries to a location before i. + memmove ( &ifdEntries[j+1], &ifdEntries[j], 12*(i-j) ); // AUDIT: Safe, moving less than i entries to a location before i. ifdEntries[j] = temp; #else void * tempifdEntries = &ifdEntries[i]; TweakedIFDEntry temp; memcpy ( &temp, tempifdEntries, sizeof(TweakedIFDEntry) ); ++j; // ! So the insertion index becomes j. - memmove ( &ifdEntries[j+1], &ifdEntries[j], 12*(i-j) ); // FAILED -- AUDIT: Safe, moving less than i entries to a location before i. + memmove ( &ifdEntries[j+1], &ifdEntries[j], 12*(i-j) ); // AUDIT: Safe, moving less than i entries to a location before i. tempifdEntries = &ifdEntries[j]; memcpy ( tempifdEntries, &temp, sizeof(TweakedIFDEntry) ); #endif @@ -688,7 +688,7 @@ if ( (GetUns16AsIs(&thisEntry->type) < kTIFF_ByteType) || (GetUns16AsIs(&thisEntry->type) > kTIFF_LastType) ) continue; // Bad type, skip this tag. - #if ! (SUNOS_SPARC || XMP_IOS_ARM) + #if ! (SUNOS_SPARC || XMP_IOS_ARM || XMP_ANDROID_ARM) thisEntry->bytes *= (XMP_Uns32)kTIFF_TypeSizes[thisEntry->type]; if ( thisEntry->bytes > 4 ) { diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/TIFF_Support.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/TIFF_Support.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/TIFF_Support.cpp 2016-12-07 05:07:54.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/TIFF_Support.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/TIFF_Support.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/TIFF_Support.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/TIFF_Support.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/TIFF_Support.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __TIFF_Support_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2006 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2006 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. @@ -25,11 +25,11 @@ #include "source/Endian.h" -#if SUNOS_SPARC || XMP_IOS_ARM +#if SUNOS_SPARC || XMP_IOS_ARM || XMP_ANDROID_ARM static const IEndian &IE = BigEndian::getInstance(); #else static const IEndian &IE = LittleEndian::getInstance(); -#endif //#if SUNOS_SPARC || XMP_IOS_ARM +#endif //#if SUNOS_SPARC || XMP_IOS_ARM || XMP_ANDROID_ARM // ================================================================================================= /// \file TIFF_Support.hpp @@ -97,9 +97,9 @@ static const size_t kTIFF_TypeSizes[] = { 0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 4 }; -static const bool kTIFF_IsIntegerType[] = { 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0 }; -static const bool kTIFF_IsRationalType[] = { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }; -static const bool kTIFF_IsFloatType[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 }; +static const bool kTIFF_IsIntegerType[] = { 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0 ,0 }; +static const bool kTIFF_IsRationalType[] = { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 ,0 }; +static const bool kTIFF_IsFloatType[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 ,0 }; enum { // Encodings for SetTag_EncodedString. kTIFF_EncodeUndefined = 0, @@ -187,6 +187,9 @@ kTIFF_RelatedSoundFile = 40964, kTIFF_DateTimeOriginal = 36867, kTIFF_DateTimeDigitized = 36868, + kTIFF_OffsetTime = 36880, + kTIFF_OffsetTimeOriginal = 36881, + kTIFF_OffsetTimeDigitized = 36882, kTIFF_SubSecTime = 37520, kTIFF_SubSecTimeOriginal = 37521, kTIFF_SubSecTimeDigitized = 37522, @@ -360,6 +363,9 @@ kTIFF_ExifVersion, // 36864 kTIFF_DateTimeOriginal, // 36867 kTIFF_DateTimeDigitized, // 36868 + kTIFF_OffsetTime, // 36880 + kTIFF_OffsetTimeOriginal, // 36881 + kTIFF_OffsetTimeDigitized, // 36882 kTIFF_ComponentsConfiguration, // 37121 kTIFF_CompressedBitsPerPixel, // 37122 kTIFF_ShutterSpeedValue, // 37377 @@ -512,6 +518,8 @@ bool IsBigEndian() const { return this->bigEndian; }; bool IsLittleEndian() const { return (! this->bigEndian); }; bool IsNativeEndian() const { return this->nativeEndian; }; + bool IsCheckTagLength () const { return this->checkTagLength; } + // --------------------------------------------------------------------------------------------- // The TIFF_Manager only keeps explicit knowledge of up to 4 IFDs: @@ -557,6 +565,9 @@ // new tag will have type short or long. virtual bool GetTag_Integer ( XMP_Uns8 ifd, XMP_Uns16 id, XMP_Uns32* data ) const = 0; + virtual XMP_Uns32 GetTiffLength() const = 0; + + virtual XMP_Uns8 *GetTiffStream() const = 0; void SetTag_Integer ( XMP_Uns8 ifd, XMP_Uns16 id, XMP_Uns32 data ); @@ -671,6 +682,7 @@ protected: bool bigEndian, nativeEndian; + bool checkTagLength { false }; XMP_Uns32 CheckTIFFHeader ( const XMP_Uns8* tiffPtr, XMP_Uns32 length ); // The pointer is to a buffer of the first 8 bytes. The length is the overall length, used @@ -732,6 +744,9 @@ bool GetTag_ASCII ( XMP_Uns8 ifd, XMP_Uns16 id, XMP_StringPtr* dataPtr, XMP_StringLen* dataLen ) const; bool GetTag_EncodedString ( XMP_Uns8 ifd, XMP_Uns16 id, std::string* utf8Str ) const; + XMP_Uns32 GetTiffLength() const { return tiffLength; } + + XMP_Uns8 *GetTiffStream() const { return tiffStream; } void SetTag_EncodedString ( XMP_Uns8 /*ifd*/, XMP_Uns16 /*id*/, const std::string& /*utf8Str*/, XMP_Uns8 /*encoding*/ ) { NotAppropriate(); }; @@ -747,7 +762,9 @@ XMP_Uns32 UpdateMemoryStream ( void** dataPtr, bool condenseStream = false ) { IgnoreParam(condenseStream); if ( dataPtr != 0 ) *dataPtr = tiffStream; return tiffLength; }; void UpdateFileStream ( XMP_IO* /*fileRef*/, XMP_ProgressTracker* /*progressTracker*/ ) { NotAppropriate(); }; - TIFF_MemoryReader() : ownedStream(false), tiffStream(0), tiffLength(0) {}; + TIFF_MemoryReader() : ownedStream(false), tiffStream(0), tiffLength(0) { + checkTagLength = true; + }; virtual ~TIFF_MemoryReader() { if ( this->ownedStream ) free ( this->tiffStream ); }; @@ -847,6 +864,9 @@ bool GetTag_ASCII ( XMP_Uns8 ifd, XMP_Uns16 id, XMP_StringPtr* dataPtr, XMP_StringLen* dataLen ) const; bool GetTag_EncodedString ( XMP_Uns8 ifd, XMP_Uns16 id, std::string* utf8Str ) const; + XMP_Uns32 GetTiffLength() const { return tiffLength; } + + XMP_Uns8 *GetTiffStream() const { return memStream; } void SetTag_EncodedString ( XMP_Uns8 ifd, XMP_Uns16 id, const std::string& utf8Str, XMP_Uns8 encoding ); @@ -966,7 +986,7 @@ void ProcessPShop6IFD ( const TIFF_MemoryReader& buriedExif, XMP_Uns8 ifd ); - void* CopyTagToMasterIFD ( const TagInfo& ps6Tag, InternalIFDInfo* masterIFD ); + void* CopyTagToMainIFD ( const TagInfo& ps6Tag, InternalIFDInfo* mainIFD ); void PreflightIFDLinkage(); diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/TimeConversionUtils.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/TimeConversionUtils.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/TimeConversionUtils.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/TimeConversionUtils.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2014 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2014 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -19,7 +19,7 @@ namespace TimeConversionUtils { - void DropFrameToHMSF( + static void DropFrameToHMSF( XMP_Int64 inFrames, XMP_Int64 inTimecodeFPS, XMP_Uns32& outHours, @@ -68,7 +68,7 @@ outFrames = static_cast(framesLeft % framesPerSecond); } - bool ConvertSamplesToTimecode( + static bool ConvertSamplesToTimecode( std::string & outTimecode, XMP_Int64 inSamples, XMP_Uns64 inSampleRate, @@ -308,7 +308,7 @@ return result; } - bool StringToNumber( + static bool StringToNumber( XMP_Int32 & outNumber, const std::string & inString ) { @@ -327,7 +327,7 @@ return numberFound; } - void ParseTimeCodeString( + static void ParseTimeCodeString( const std::string & inTimecode, XMP_Int32 & outHours, XMP_Int32 & outMinutes, @@ -475,7 +475,7 @@ outFrames = m1; } - bool ConvertTimecodeToSamples( + static bool ConvertTimecodeToSamples( XMP_Int64 & outSamples, const std::string & inTimecode, XMP_Uns64 inSampleRate, diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/TimeConversionUtils.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/TimeConversionUtils.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/TimeConversionUtils.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/TimeConversionUtils.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define TimeConversionUtils_h__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2014 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2014 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -31,8 +31,7 @@ XMP_Uns64 inSampleRate, const std::string & inTimecodeFormat ); - - + }; #endif // TimeConversionUtils_h__ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/BEXTMetadata.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/BEXTMetadata.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/BEXTMetadata.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/BEXTMetadata.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/BEXTMetadata.h exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/BEXTMetadata.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/BEXTMetadata.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/BEXTMetadata.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _BEXTMetadata_h_ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/CartMetadata.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/CartMetadata.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/CartMetadata.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/CartMetadata.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/CartMetadata.h exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/CartMetadata.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/CartMetadata.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/CartMetadata.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _CartMetadata_h_ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/Cr8rMetadata.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/Cr8rMetadata.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/Cr8rMetadata.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/Cr8rMetadata.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/Cr8rMetadata.h exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/Cr8rMetadata.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/Cr8rMetadata.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/Cr8rMetadata.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _Cr8rMetadata_h_ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/DISPMetadata.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/DISPMetadata.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/DISPMetadata.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/DISPMetadata.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/DISPMetadata.h exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/DISPMetadata.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/DISPMetadata.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/DISPMetadata.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _DISPMetadata_h_ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/INFOMetadata.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/INFOMetadata.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/INFOMetadata.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/INFOMetadata.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include @@ -152,7 +152,7 @@ { TValueObject* strObj = dynamic_cast*>(iter->second); - XMP_Uns32 chunkSize = kChunkHeaderSize + strObj->getValue().length() + 1; // 1 byte is added for NULL termination string + XMP_Uns32 chunkSize = kChunkHeaderSize + (XMP_Uns32)strObj->getValue().length() + 1; // 1 byte is added for NULL termination string if( chunkSize & 1 ) { @@ -194,9 +194,9 @@ TValueObject* strObj = dynamic_cast*>(iter->second); std::string value = strObj->getValue(); XMP_Uns32 id = iter->first; - XMP_Uns32 size = value.length() + 1; // Null terminated string + XMP_Uns32 lSize = (XMP_Uns32)value.length() + 1; // Null terminated string - if( size & 1 && strObj->hasChanged() ) + if( lSize & 1 && strObj->hasChanged() ) { // // if we modified the value of this entry @@ -205,31 +205,31 @@ // size of each LIST:INFO entry has // an odd size // - size++; + lSize++; } // // chunk id and chunk size are stored in little endian format // id = BE.getUns32( &id ); - size = LE.getUns32( &size ); + lSize = LE.getUns32( &lSize ); // // copy values into output buffer // memcpy( buffer+offset, &id, kSizeChunkID ); - memcpy( buffer+offset+kSizeChunkID, &size, kSizeChunkSize ); + memcpy( buffer+offset+kSizeChunkID, &lSize, kSizeChunkSize ); //size has been changed in little endian format. Change it back to bigendina - size = LE.getUns32( &size ); + lSize = LE.getUns32( &lSize ); memcpy( buffer+offset+kChunkHeaderSize, value.c_str(), value.length() ); // // update pointer // offset += kChunkHeaderSize; - offset += size; + offset += lSize; - if( size & 1 ) + if( lSize & 1 ) { // // take account of pad byte diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/INFOMetadata.h exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/INFOMetadata.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/INFOMetadata.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/INFOMetadata.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _INFOMetadata_h_ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/iXMLMetadata.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/iXMLMetadata.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/iXMLMetadata.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/iXMLMetadata.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2014 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2014 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -19,7 +19,7 @@ namespace IFF_RIFF { - static const char * tagNames[ iXMLMetadata::kLastEntry ] = { + static const char * tagNames[ iXMLMetadata::kLastEntry - 1 ] = { "TAPE", //kTape, // std::string "TAKE", //kTake, // std::string "SCENE", //kScene, // std::string @@ -250,6 +250,10 @@ } break; + case kNativeTrackCount: + ret = false; + break; + default: ret = true; } @@ -386,16 +390,16 @@ void iXMLMetadata::UpdateXMLNode( XML_Node * parentNode, const char * localName, const std::string & value ) { XML_Node * node = parentNode->GetNamedElement( "", localName ); - - if ( node == NULL ) { - node = new XML_Node( parentNode, localName, kElemNode ); - if ( node == NULL ) { - XMP_Error error( kXMPErr_NoMemory, "Unable to create new objects" ); - NotifyClient( kXMPErrSev_OperationFatal, error ); - return; + if (node == NULL) { + + node = new XML_Node(parentNode, localName, kElemNode); + if (node == NULL) { + XMP_Error error(kXMPErr_NoMemory, "Unable to create new objects"); + NotifyClient(kXMPErrSev_OperationFatal, error); + return; + } + parentNode->content.push_back(node); } - parentNode->content.push_back( node ); - } if ( node->IsLeafContentNode() == false ) { XMP_Error error( kXMPErr_BadBlockFormat, "iXML Metadata reconciliation failure: node was supposed to be a leaf node" ); @@ -468,6 +472,7 @@ void iXMLMetadata::UpdateTrackListInfo( XML_Node * parentNode ) { if ( valueExists( kTrackList ) ) { + RemoveXMLNode(parentNode, tagNames[kTrackList]); XMP_Uns32 size; const TrackListInfo * arrayObj( NULL ); try { @@ -507,13 +512,14 @@ node->content.push_back( track ); } const TrackListInfo & ref = arrayObj[i]; - count = ConvertUns64ToString( ref.mChannelIndex ); - UpdateXMLNode( track, trackChannelIndexTagName, count ); - if ( ref.mChannelIndex != i + 1 ) - count = ConvertUns64ToString( i + 1 ); - UpdateXMLNode( track, trackInterleaveIndexTagName, count ); - UpdateXMLNode( track, trackNameTagName, ref.mName ); - UpdateXMLNode( track, trackFunctionTagName, ref.mFunction ); + if (ref.mChannelIndex.size()>0) + UpdateXMLNode( track, trackChannelIndexTagName, ref.mChannelIndex); + if (ref.mInterleaveIndex.size()>0) + UpdateXMLNode( track, trackInterleaveIndexTagName,ref.mInterleaveIndex ); + if (ref.mName.size()>0) + UpdateXMLNode( track, trackNameTagName, ref.mName ); + if (ref.mFunction.size()>0) + UpdateXMLNode( track, trackFunctionTagName, ref.mFunction ); } } else { RemoveXMLNode( parentNode, tagNames[ kTrackList ] ); @@ -650,6 +656,10 @@ return validateInt( valueObj, 0, Max_XMP_Uns32 ); break; + case kNativeTrackCount: + return validateInt(valueObj, 1, Max_XMP_Uns64); + break; + default: return false; break; @@ -862,7 +872,8 @@ NotifyClient( recoverable ? kXMPErrSev_Recoverable : kXMPErrSev_OperationFatal, error ); } } else { - XMP_Error error ( recoverable ? kXMPErrSev_Recoverable : kXMPErrSev_OperationFatal, "iXML Metadata reconciliation failure: node not present" ); + XMP_Error error(kXMPErr_BadBlockFormat, "iXML Metadata reconciliation failure: node not present"); + NotifyClient(recoverable ? kXMPErrSev_Recoverable : kXMPErrSev_OperationFatal, error); } return nodeValue; } @@ -884,56 +895,49 @@ return Max_XMP_Uns64; } + + /* + * Handling of Tracklist changed in refrence to bug CTECHXMP-4169661 + */ void iXMLMetadata::ParseAndSetTrackListInfo( XML_Node * parentNode ) { XMP_Uns64 trackCount( 0 ); - try { - trackCount = ParseUns64Value( parentNode, trackCountTagName ); - } catch( ... ) { - XMP_Error error( kXMPErr_BadBlockFormat, "iXML Metadata reconciliation failure: failed parsing track list" ); - NotifyClient( kXMPErrSev_Recoverable, error ); - return; + XMP_Uns64 nativeTrackCount(0); //to notice if there is change in track count as read from iXML chunk + try + { + nativeTrackCount = ParseUns64Value(parentNode, trackCountTagName); + this->setValue(kNativeTrackCount, nativeTrackCount); } - std::vector< TrackListInfo > trackInfoListVector( trackCount ); + catch (...) { + //do nothing. don't set native track count value + } + trackCount = parentNode->CountNamedElements("", trackTagName); + std::vector< TrackListInfo > trackInfoListVector ; for ( size_t i = 0; i < trackCount; i++ ) { XML_Node * trackElement = parentNode->GetNamedElement( "", trackTagName, i ); if ( trackElement ) { - XMP_Uns64 channelIndex( 0 ), interleaveIndex( 0 ); - std::string name, function; + + std::string name, function, channelIndex, interleaveIndex; - try { - channelIndex = ParseUns64Value( trackElement, trackChannelIndexTagName ); - interleaveIndex = ParseUns64Value( trackElement, trackInterleaveIndexTagName ); + channelIndex = ParseStringValue( trackElement, trackChannelIndexTagName ); + interleaveIndex = ParseStringValue( trackElement, trackInterleaveIndexTagName ); name = ParseStringValue( trackElement, trackNameTagName ); function = ParseStringValue( trackElement, trackFunctionTagName ); - } catch( ... ) { - XMP_Error error( kXMPErr_BadBlockFormat, "iXML Metadata reconciliation failure: failed parsing track list" ); - NotifyClient( kXMPErrSev_Recoverable, error ); - return; - } - - // check value of interleave index it should be between 1 and trackCount. - if ( interleaveIndex > 0 && interleaveIndex <= trackCount - && trackInfoListVector[ interleaveIndex - 1 ].mChannelIndex == 0 ) - { - TrackListInfo & currentElement = trackInfoListVector[ interleaveIndex - 1 ]; - currentElement.mChannelIndex = channelIndex; - currentElement.mName = name; - currentElement.mFunction = function; - } else { - XMP_Error error( kXMPErr_BadBlockFormat, "iXML Metadata reconciliation failure: interleave index is not correct" ); - NotifyClient( kXMPErrSev_Recoverable, error ); - return; - } + + if (channelIndex.size() > 0 || interleaveIndex.size() > 0 || name.size() > 0 || function.size() > 0) + { + TrackListInfo currentElement(channelIndex, name, function, interleaveIndex); + trackInfoListVector.push_back(currentElement); + } + } else { - XMP_Error error( kXMPErr_BadBlockFormat, "iXML Metadata reconciliation failure: number of track elements is less than expected" ); - NotifyClient( kXMPErrSev_Recoverable, error ); - return; + trackCount = i; } } - if ( trackCount > 0 ) { - this->setArray( kTrackList, trackInfoListVector.data(), ( XMP_Uns32 ) trackInfoListVector.size() ); + XMP_Uns32 count = (XMP_Uns32)trackInfoListVector.size(); + if (count > 0 ) { + this->setArray( kTrackList, trackInfoListVector.data(), count); } } diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/iXMLMetadata.h exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/iXMLMetadata.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/iXMLMetadata.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/iXMLMetadata.h 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __iXMLMetadata_h__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2014 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2014 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -31,26 +31,29 @@ class TrackListInfo { public: - TrackListInfo() : mChannelIndex( 0 ) {} + TrackListInfo() {} - TrackListInfo( XMP_Uns64 channelIndex, const std::string & name, const std::string & function ) - : mChannelIndex( channelIndex ) - , mName( name ) - , mFunction( function ) {} - - bool operator == ( const TrackListInfo & other ) const { - return mChannelIndex == other.mChannelIndex && - mName.compare( other.mName ) == 0 && - mFunction.compare( other.mFunction ) == 0; + TrackListInfo(const std::string & channelIndex, const std::string & name, const std::string & function, const std::string & interleaveIndex) + : mChannelIndex(channelIndex) + , mName(name) + , mFunction(function) + , mInterleaveIndex(interleaveIndex) {} + + bool operator == (const TrackListInfo & other) const { + return mChannelIndex.compare(other.mChannelIndex) == 0 && + mName.compare(other.mName) == 0 && + mFunction.compare(other.mFunction) == 0 && + mInterleaveIndex.compare(other.mInterleaveIndex) == 0; } bool operator != ( const TrackListInfo & other ) const { return !( this->operator==( other ) ); } - XMP_Uns64 mChannelIndex; + std::string mChannelIndex; std::string mName; std::string mFunction; + std::string mInterleaveIndex; }; enum @@ -80,6 +83,7 @@ kTimeStampSampleSinceMidnightLow, // XMP_Uns32 kTimeStampSampleSinceMidnightHigh, // XMP_Uns32 kTrackList, // std::vector< TrackListInfo > + kNativeTrackCount, kLastEntry }; diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/PrmLMetadata.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/PrmLMetadata.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/PrmLMetadata.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/PrmLMetadata.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/PrmLMetadata.h exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/PrmLMetadata.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/PrmLMetadata.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/PrmLMetadata.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _PrmlMetadata_h_ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/WAVEBehavior.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/WAVEBehavior.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/WAVEBehavior.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/WAVEBehavior.cpp 2022-02-12 23:39:28.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -252,7 +252,7 @@ // // calculate index of chunk to remove // - XMP_Uns32 i = std::find( riffChunk->firstChild(), riffChunk->lastChild(), &chunk ) - riffChunk->firstChild(); + XMP_Uns32 i = (XMP_Uns32)(std::find( riffChunk->firstChild(), riffChunk->lastChild(), &chunk ) - riffChunk->firstChild()); // // validate index @@ -608,11 +608,10 @@ memcpy( &ds64, data, kMinimumDS64ChunkSize ); // If there is more data but the table length is <= 0 then this is not a valid ds64 chunk - if( size > kMinimumDS64ChunkSize && ds64.tableLength > 0 ) + if (size > kMinimumDS64ChunkSize && ds64.tableLength > 0 && ((size - kMinimumDS64ChunkSize) >= (ds64.tableLength * sizeof(ChunkSize64)))) { // copy chunk sizes table // - XMP_Assert( size - kMinimumDS64ChunkSize >= ds64.tableLength * sizeof(ChunkSize64)); XMP_Uns32 offset = kMinimumDS64ChunkSize; ChunkSize64 chunkSize; diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/WAVEBehavior.h exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/WAVEBehavior.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/WAVEBehavior.h 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/WAVEBehavior.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _WAVEBEHAVIOR_h_ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/WAVEReconcile.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/WAVEReconcile.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/WAVEReconcile.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/WAVEReconcile.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -73,7 +73,7 @@ static const char * kDM_good = "good"; static const char * kIXML_trackList = "trackList"; static const char * kIXML_channelIndex = "channelIndex"; -/*static const char * kIXML_interleaveIndex = "interleaveIndex";*/ +static const char * kIXML_interleaveIndex = "interleaveIndex"; static const char * kIXML_Name = "name"; static const char * kIXML_Function = "function"; @@ -495,7 +495,7 @@ // if the XMP property doesn't contain a valid hex string then // keep the existing value in the umid BEXT field // - bextMeta->setArray(BEXTMetadata::kUMID, reinterpret_cast(umid.data()), umid.length()); + bextMeta->setArray(BEXTMetadata::kUMID, reinterpret_cast(umid.data()),((XMP_Uns32)umid.length())); } } else @@ -1005,27 +1005,38 @@ if ( inXMP.DoesPropertyExist( kXMP_NS_iXML, kIXML_trackList ) ) { XMP_OptionBits options( 0 ); if ( inXMP.GetProperty( kXMP_NS_iXML, kIXML_trackList, NULL, &options ) && - XMP_OptionIsSet( options, kXMP_PropArrayIsOrdered ) ) + XMP_OptionIsSet( options, kXMP_PropArrayIsUnordered ) ) { XMP_Index count = inXMP.CountArrayItems( kXMP_NS_iXML, kIXML_trackList ); - std::vector< iXMLMetadata::TrackListInfo > trackListInfo( count ); + std::vector< iXMLMetadata::TrackListInfo > trackListInfo; + XMP_Index size = count; for ( XMP_Index i = 0; i < count; i++ ) { - iXMLMetadata::TrackListInfo & trackRef = trackListInfo[i]; std::string trackPath; SXMPUtils::ComposeArrayItemPath( kXMP_NS_iXML, kIXML_trackList, i + 1, &trackPath ); - std::string fieldPath; + std::string fieldPath, channelIndex, interleaveIndex, name, function; SXMPUtils::ComposeStructFieldPath( kXMP_NS_iXML, trackPath.c_str(), kXMP_NS_iXML, kIXML_channelIndex, &fieldPath ); - XMP_Int64 int64Value; - inXMP.GetProperty_Int64( kXMP_NS_iXML, fieldPath.c_str(), &int64Value, &options ); - trackRef.mChannelIndex = int64Value; - inXMP.GetStructField( kXMP_NS_iXML, trackPath.c_str(), kXMP_NS_iXML, kIXML_Name, &trackRef.mName, &options ); - inXMP.GetStructField( kXMP_NS_iXML, trackPath.c_str(), kXMP_NS_iXML, kIXML_Function, &trackRef.mFunction, &options ); + //XMP_Int64 int64Value; + + inXMP.GetStructField( kXMP_NS_iXML, trackPath.c_str(), kXMP_NS_iXML, kIXML_channelIndex, &channelIndex, &options ); + inXMP.GetStructField(kXMP_NS_iXML, trackPath.c_str(), kXMP_NS_iXML, kIXML_interleaveIndex, &interleaveIndex, &options); + inXMP.GetStructField(kXMP_NS_iXML, trackPath.c_str(), kXMP_NS_iXML, kIXML_Name, &name, &options); + inXMP.GetStructField( kXMP_NS_iXML, trackPath.c_str(), kXMP_NS_iXML, kIXML_Function, &function, &options ); + + if (channelIndex.size() > 0 || interleaveIndex.size() > 0 || name.size() > 0 || function.size() > 0) + { + iXMLMetadata::TrackListInfo trackRef(channelIndex, name, function, interleaveIndex); + trackListInfo.push_back(trackRef); + } + else + size--; } - outNativeMeta.setArray< iXMLMetadata::TrackListInfo >( iXMLMetadata::kTrackList, trackListInfo.data(), count ); + outNativeMeta.setArray< iXMLMetadata::TrackListInfo >( iXMLMetadata::kTrackList, trackListInfo.data(), size ); + outNativeMeta.setValue(iXMLMetadata::kNativeTrackCount, (XMP_Uns64)size); inXMP.DeleteProperty( kXMP_NS_iXML, kIXML_trackList ); } } else { outNativeMeta.deleteValue( iXMLMetadata::kTrackList ); + outNativeMeta.deleteValue(iXMLMetadata::kNativeTrackCount); } } catch( ... ) { // do nothing @@ -1116,17 +1127,19 @@ inNativeMeta.getArray< iXMLMetadata::TrackListInfo >( iXMLMetadata::kTrackList, countOfTracks ); if ( countOfTracks > 0 && trackInfoArray != NULL ) { outXMP.DeleteProperty( kXMP_NS_iXML, kIXML_trackList ); - outXMP.SetProperty( kXMP_NS_iXML, kIXML_trackList, 0, kXMP_PropArrayIsOrdered ); + outXMP.SetProperty( kXMP_NS_iXML, kIXML_trackList, 0, kXMP_PropArrayIsUnordered); for ( XMP_Uns32 i = 0; i < countOfTracks; i++ ) { std::string trackPath; SXMPUtils::ComposeArrayItemPath( kXMP_NS_iXML, kIXML_trackList, i + 1, &trackPath ); const iXMLMetadata::TrackListInfo & ref = trackInfoArray[i]; std::string value; - SXMPUtils::ConvertFromInt64( ref.mChannelIndex, "%llu", &value ); - outXMP.SetStructField( kXMP_NS_iXML, trackPath.c_str(), kXMP_NS_iXML, kIXML_channelIndex, value ); - if ( ref.mName.size() > 0 ) + if(ref.mChannelIndex.size()>0) + outXMP.SetStructField( kXMP_NS_iXML, trackPath.c_str(), kXMP_NS_iXML, kIXML_channelIndex, ref.mChannelIndex); + if (ref.mInterleaveIndex.size()>0) + outXMP.SetStructField(kXMP_NS_iXML, trackPath.c_str(), kXMP_NS_iXML, kIXML_interleaveIndex, ref.mInterleaveIndex); + if (ref.mName.size()>0) outXMP.SetStructField( kXMP_NS_iXML, trackPath.c_str(), kXMP_NS_iXML, kIXML_Name, ref.mName ); - if ( ref.mFunction.size() > 0 ) + if (ref.mFunction.size()>0) outXMP.SetStructField( kXMP_NS_iXML, trackPath.c_str(), kXMP_NS_iXML, kIXML_Function, ref.mFunction ); } changed = true; diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/WAVEReconcile.h exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/WAVEReconcile.h --- exempi-2.5.2/XMPFiles/source/FormatSupport/WAVE/WAVEReconcile.h 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/WAVE/WAVEReconcile.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _WAVEReconcile_h_ diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/XDCAM_Support.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/XDCAM_Support.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/XDCAM_Support.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/XDCAM_Support.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2008 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2008 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/XDCAM_Support.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/XDCAM_Support.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/XDCAM_Support.hpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/XDCAM_Support.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __XDCAM_Support_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2008 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2008 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/XMPScanner.cpp exempi-2.6.1/XMPFiles/source/FormatSupport/XMPScanner.cpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/XMPScanner.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/XMPScanner.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,9 +1,9 @@ // ================================================================================================= -// Copyright 2004 Adobe Systems Incorporated +// Copyright 2004 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // // Adobe patent application tracking #P435, entitled 'Unique markers to simplify embedding data of // one format in a file with a different format', inventors: Sean Parent, Greg Gilley. @@ -226,7 +226,7 @@ { const int bytesPerChar = ths->fBytesPerChar; const char * litPtr = literal + ths->fPosition; - const XMP_Int32 charsToGo = (XMP_Int32) strlen ( literal ) - ths->fPosition; + const XMP_Int32 charsToGo = (XMP_Int32) (strlen ( literal ) - ths->fPosition); int charsDone = 0; while ( (charsDone < charsToGo) && (ths->fBufferPtr < ths->fBufferLimit) ) { @@ -373,14 +373,14 @@ ths->fBufferPtr += bytesPerChar; ths->fPosition = 1; // fall through OK because MatchOpenQuote will check the buffer limit and nulls ... - + // fallthrough case 1 : // Look for the open quote. result = MatchOpenQuote ( ths, NULL ); if ( result != eTriYes ) return result; ths->fPosition = 2; // fall through OK because the buffer limit and nulls are checked below ... - + // fallthrough default : // Look for the close quote, capturing the value along the way. assert ( ths->fPosition == 2 ); @@ -433,7 +433,7 @@ ths->fPacketLength = 0; ths->fPosition = 1; // ! OK to fall through here, we didn't consume a byte in this step. - + // fallthrough case 1 : // Look for the first null byte. if ( currByte != 0 ) return eTriYes; // No nulls found. ths->fCharForm = eChar16BitBig; // Assume 16 bit big endian for now. @@ -662,7 +662,7 @@ } else if ( ths->fAttrName == "bytes" ) { - long value = 0; + XMP_Int32 value = 0; int count = (int) ths->fAttrValue.size(); int i; diff -Nru exempi-2.5.2/XMPFiles/source/FormatSupport/XMPScanner.hpp exempi-2.6.1/XMPFiles/source/FormatSupport/XMPScanner.hpp --- exempi-2.5.2/XMPFiles/source/FormatSupport/XMPScanner.hpp 2016-12-07 05:07:54.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/FormatSupport/XMPScanner.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,11 +2,11 @@ #define __XMPScanner_hpp__ // ================================================================================================= -// Copyright 2004 Adobe Systems Incorporated +// Copyright 2004 Adobe // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // // Adobe patent application tracking #P435, entitled 'Unique markers to simplify embedding data of // one format in a file with a different format', inventors: Sean Parent, Greg Gilley. diff -Nru exempi-2.5.2/XMPFiles/source/HandlerRegistry.cpp exempi-2.6.1/XMPFiles/source/HandlerRegistry.cpp --- exempi-2.5.2/XMPFiles/source/HandlerRegistry.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/HandlerRegistry.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -453,6 +453,7 @@ bool HandlerRegistry::getFormatInfo( XMP_FileFormat format, XMP_OptionBits* flags /*= 0*/ ) { + XMP_OptionBits voidOptionBits = 0; if ( flags == 0 ) flags = &voidOptionBits; XMPFileHandlerInfo* handler = this->getHandlerInfo( format ); @@ -703,6 +704,12 @@ handlerInfo = this->tryFolderHandlers( session->format, rootPath, gpName, parentName, leafName, session ); // ! Parent and GP are empty. + if ( handlerInfo == 0 && session->format == kXMP_AVCUltraFile ) + { + session->format = kXMP_P2File; + handlerInfo = this->tryFolderHandlers( session->format, rootPath, gpName, parentName, leafName, session ); // ! Parent and GP are empty. + } + return handlerInfo; // ! Return found handler or 0. } diff -Nru exempi-2.5.2/XMPFiles/source/HandlerRegistry.h exempi-2.6.1/XMPFiles/source/HandlerRegistry.h --- exempi-2.5.2/XMPFiles/source/HandlerRegistry.h 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/HandlerRegistry.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _HANDLERREGISTRY_h_ diff -Nru exempi-2.5.2/XMPFiles/source/Makefile.in exempi-2.6.1/XMPFiles/source/Makefile.in --- exempi-2.5.2/XMPFiles/source/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -397,6 +397,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/XMPFiles/source/NativeMetadataSupport/IMetadata.cpp exempi-2.6.1/XMPFiles/source/NativeMetadataSupport/IMetadata.cpp --- exempi-2.5.2/XMPFiles/source/NativeMetadataSupport/IMetadata.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/NativeMetadataSupport/IMetadata.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "XMPFiles/source/NativeMetadataSupport/IMetadata.h" diff -Nru exempi-2.5.2/XMPFiles/source/NativeMetadataSupport/IMetadata.h exempi-2.6.1/XMPFiles/source/NativeMetadataSupport/IMetadata.h --- exempi-2.5.2/XMPFiles/source/NativeMetadataSupport/IMetadata.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/NativeMetadataSupport/IMetadata.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _IMetadata_h_ diff -Nru exempi-2.5.2/XMPFiles/source/NativeMetadataSupport/IReconcile.cpp exempi-2.6.1/XMPFiles/source/NativeMetadataSupport/IReconcile.cpp --- exempi-2.5.2/XMPFiles/source/NativeMetadataSupport/IReconcile.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/NativeMetadataSupport/IReconcile.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "XMPFiles/source/NativeMetadataSupport/IReconcile.h" @@ -355,7 +355,7 @@ try { - value = SXMPUtils::ConvertToInt( xmpValue ); + value = (XMP_Int32)SXMPUtils::ConvertToInt( xmpValue ); } catch( XMP_Error& e ) { @@ -385,7 +385,7 @@ try { - value = SXMPUtils::ConvertToInt( xmpValue ); + value = (XMP_Int32)SXMPUtils::ConvertToInt( xmpValue ); } catch( XMP_Error& e ) { @@ -415,7 +415,7 @@ try { - value = SXMPUtils::ConvertToInt( xmpValue ); + value = (XMP_Int32)SXMPUtils::ConvertToInt( xmpValue ); } catch( XMP_Error& e ) { diff -Nru exempi-2.5.2/XMPFiles/source/NativeMetadataSupport/IReconcile.h exempi-2.6.1/XMPFiles/source/NativeMetadataSupport/IReconcile.h --- exempi-2.5.2/XMPFiles/source/NativeMetadataSupport/IReconcile.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/NativeMetadataSupport/IReconcile.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _IReconcile_h_ diff -Nru exempi-2.5.2/XMPFiles/source/NativeMetadataSupport/Makefile.in exempi-2.6.1/XMPFiles/source/NativeMetadataSupport/Makefile.in --- exempi-2.5.2/XMPFiles/source/NativeMetadataSupport/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/NativeMetadataSupport/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -366,6 +366,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/XMPFiles/source/NativeMetadataSupport/MetadataSet.cpp exempi-2.6.1/XMPFiles/source/NativeMetadataSupport/MetadataSet.cpp --- exempi-2.5.2/XMPFiles/source/NativeMetadataSupport/MetadataSet.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/NativeMetadataSupport/MetadataSet.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "XMPFiles/source/NativeMetadataSupport/MetadataSet.h" diff -Nru exempi-2.5.2/XMPFiles/source/NativeMetadataSupport/MetadataSet.h exempi-2.6.1/XMPFiles/source/NativeMetadataSupport/MetadataSet.h --- exempi-2.5.2/XMPFiles/source/NativeMetadataSupport/MetadataSet.h 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/NativeMetadataSupport/MetadataSet.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _MetadataSet_h_ diff -Nru exempi-2.5.2/XMPFiles/source/NativeMetadataSupport/ValueObject.h exempi-2.6.1/XMPFiles/source/NativeMetadataSupport/ValueObject.h --- exempi-2.5.2/XMPFiles/source/NativeMetadataSupport/ValueObject.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/NativeMetadataSupport/ValueObject.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2010 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2010 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _ValueObject_h_ diff -Nru exempi-2.5.2/XMPFiles/source/PluginHandler/FileHandler.h exempi-2.6.1/XMPFiles/source/PluginHandler/FileHandler.h --- exempi-2.5.2/XMPFiles/source/PluginHandler/FileHandler.h 2016-12-07 05:07:54.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/PluginHandler/FileHandler.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef PLUGINHANDLER_H diff -Nru exempi-2.5.2/XMPFiles/source/PluginHandler/FileHandlerInstance.cpp exempi-2.6.1/XMPFiles/source/PluginHandler/FileHandlerInstance.cpp --- exempi-2.5.2/XMPFiles/source/PluginHandler/FileHandlerInstance.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/PluginHandler/FileHandlerInstance.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,14 +1,14 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "FileHandlerInstance.h" - +#if EnablePluginManager namespace XMP_PLUGIN { @@ -23,8 +23,9 @@ FileHandlerInstance::~FileHandlerInstance() { WXMP_Error error; - mHandler->getModule()->getPluginAPIs()->mTerminateSessionProc( this->mObject, &error ); - PluginManager::removeHandlerInstance( this->mObject ); + + PluginManager::removeHandlerInstance(this->mObject); + mHandler->getModule()->getPluginAPIs()->mTerminateSessionProc(this->mObject, &error); CheckError( error ); } @@ -79,8 +80,8 @@ { XMP_StringPtr xmpStr = this->xmpPacket.c_str(); XMP_StringPtr oldPacketPtr = NULL; - XMP_PacketInfo packetInfo; - mHandler->getModule()->getPluginAPIs()->mImportToXMPStringWithPacketProc( this->mObject, &xmpStr, &error, &oldPacketPtr, &packetInfo ); + XMP_PacketInfo packetInfo_; + mHandler->getModule()->getPluginAPIs()->mImportToXMPStringWithPacketProc( this->mObject, &xmpStr, &error, &oldPacketPtr, &packetInfo_ ); if( xmpStr != NULL && xmpStr != this->xmpPacket.c_str() ) { @@ -97,7 +98,7 @@ { this->xmpPacket.resize( strlen( oldPacketPtr ) ); this->xmpPacket.assign( oldPacketPtr ); - this->packetInfo = packetInfo; + this->packetInfo = packetInfo_; // Note: Freeing memory would not create any problem as plugin would have allocated memory using Host library function free( ( void * ) oldPacketPtr ); @@ -250,3 +251,4 @@ } } //namespace XMP_PLUGIN +#endif diff -Nru exempi-2.5.2/XMPFiles/source/PluginHandler/FileHandlerInstance.h exempi-2.6.1/XMPFiles/source/PluginHandler/FileHandlerInstance.h --- exempi-2.5.2/XMPFiles/source/PluginHandler/FileHandlerInstance.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/PluginHandler/FileHandlerInstance.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef PLUGINHANDLERINSTANCE_H diff -Nru exempi-2.5.2/XMPFiles/source/PluginHandler/HostAPIImpl.cpp exempi-2.6.1/XMPFiles/source/PluginHandler/HostAPIImpl.cpp --- exempi-2.5.2/XMPFiles/source/PluginHandler/HostAPIImpl.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/PluginHandler/HostAPIImpl.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "HostAPI.h" @@ -13,6 +13,7 @@ #include "source/XIO.hpp" #include "XMPFiles/source/HandlerRegistry.h" +#if EnablePluginManager using namespace Common; namespace XMP_PLUGIN @@ -1128,3 +1129,4 @@ } } //namespace XMP_PLUGIN +#endif \ No newline at end of file diff -Nru exempi-2.5.2/XMPFiles/source/PluginHandler/Makefile.in exempi-2.6.1/XMPFiles/source/PluginHandler/Makefile.in --- exempi-2.5.2/XMPFiles/source/PluginHandler/Makefile.in 2020-06-24 01:39:51.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/PluginHandler/Makefile.in 2022-02-13 05:34:25.000000000 +0000 @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -375,6 +375,7 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff -Nru exempi-2.5.2/XMPFiles/source/PluginHandler/Module.cpp exempi-2.6.1/XMPFiles/source/PluginHandler/Module.cpp --- exempi-2.5.2/XMPFiles/source/PluginHandler/Module.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/PluginHandler/Module.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,15 +1,15 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "Module.h" #include "HostAPI.h" - +#if EnablePluginManager namespace XMP_PLUGIN { @@ -276,3 +276,4 @@ } } //namespace XMP_PLUGIN +#endif \ No newline at end of file diff -Nru exempi-2.5.2/XMPFiles/source/PluginHandler/Module.h exempi-2.6.1/XMPFiles/source/PluginHandler/Module.h --- exempi-2.5.2/XMPFiles/source/PluginHandler/Module.h 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/PluginHandler/Module.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef MODULE_H diff -Nru exempi-2.5.2/XMPFiles/source/PluginHandler/ModuleUtils.h exempi-2.6.1/XMPFiles/source/PluginHandler/ModuleUtils.h --- exempi-2.5.2/XMPFiles/source/PluginHandler/ModuleUtils.h 2020-02-09 05:11:52.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/PluginHandler/ModuleUtils.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef MODULEUTILS_H @@ -21,6 +21,9 @@ #elif XMP_UNIXBuild #include typedef void* OS_ModuleRef; +#elif XMP_AndroidBuild +#include +typedef void* OS_ModuleRef; #else #error Unsupported operating system #endif diff -Nru exempi-2.5.2/XMPFiles/source/PluginHandler/OS_Utils_Linux.cpp exempi-2.6.1/XMPFiles/source/PluginHandler/OS_Utils_Linux.cpp --- exempi-2.5.2/XMPFiles/source/PluginHandler/OS_Utils_Linux.cpp 2020-02-09 05:11:52.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/PluginHandler/OS_Utils_Linux.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "ModuleUtils.h" diff -Nru exempi-2.5.2/XMPFiles/source/PluginHandler/OS_Utils_Mac.cpp exempi-2.6.1/XMPFiles/source/PluginHandler/OS_Utils_Mac.cpp --- exempi-2.5.2/XMPFiles/source/PluginHandler/OS_Utils_Mac.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/PluginHandler/OS_Utils_Mac.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "ModuleUtils.h" diff -Nru exempi-2.5.2/XMPFiles/source/PluginHandler/OS_Utils_WIN.cpp exempi-2.6.1/XMPFiles/source/PluginHandler/OS_Utils_WIN.cpp --- exempi-2.5.2/XMPFiles/source/PluginHandler/OS_Utils_WIN.cpp 2016-12-01 01:44:02.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/PluginHandler/OS_Utils_WIN.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,15 +1,16 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "ModuleUtils.h" #include "source/UnicodeConversions.hpp" +#if EnablePluginManager namespace XMP_PLUGIN { @@ -63,4 +64,5 @@ return false; } -} //namespace XMP_PLUGIN \ No newline at end of file +} //namespace XMP_PLUGIN +#endif \ No newline at end of file diff -Nru exempi-2.5.2/XMPFiles/source/PluginHandler/PluginManager.cpp exempi-2.6.1/XMPFiles/source/PluginHandler/PluginManager.cpp --- exempi-2.5.2/XMPFiles/source/PluginHandler/PluginManager.cpp 2020-02-09 17:20:22.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/PluginHandler/PluginManager.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "PluginManager.h" @@ -19,7 +19,7 @@ using namespace std; // ================================================================================================= - +#if EnablePluginManager namespace XMP_PLUGIN { @@ -52,7 +52,7 @@ SessionRef object; WXMP_Error error; - if( (handler == 0) || (! handler->load()) ) + if( (handler == libcppNULL) || (! handler->load()) ) { XMP_Throw ( "Plugin not loaded", kXMPErr_InternalFailure ); } @@ -85,7 +85,7 @@ static bool Plugin_CheckFileFormat ( FileHandlerSharedPtr handler, XMP_StringPtr filePath, XMP_IO * fileRef, XMPFiles * /*parent*/ ) { - if ( handler != 0 ) { + if ( handler != libcppNULL ) { // call into plugin if owning handler or if manifest has no CheckFormat entry if ( fileRef == 0 || handler->getCheckFormatSize() == 0) { @@ -190,7 +190,7 @@ { XMP_Bool result = false; - if ( handler != 0 ) + if ( handler != libcppNULL ) { WXMP_Error error; CheckSessionFolderFormatProc checkProc = handler->getModule()->getPluginAPIs()->mCheckFolderFormatProc; @@ -256,7 +256,7 @@ if ( ! mPluginDir.empty() && Host_IO::Exists( mPluginDir.c_str() ) ) { XMP_StringPtr strPtr = plugins.c_str(); - size_t pos = 0; + size_t posn = 0; size_t length = 0; for ( ; ; ++strPtr, ++length ) { @@ -266,13 +266,13 @@ if ( length != 0 ) { //Remove white spaces from front - while ( plugins[pos] == ' ' ) { - ++pos; + while ( plugins[posn] == ' ' ) { + ++posn; --length; } std::string pluginName; - pluginName.assign ( plugins, pos, length ); + pluginName.assign ( plugins, posn, length ); //Remove extension from the plugin name size_t found = pluginName.find ( '.' ); @@ -286,7 +286,7 @@ mPluginsNeeded.push_back ( pluginName ); //Reset for next plugin - pos = pos + length + 1; + posn = posn + length + 1; length = 0; } @@ -401,12 +401,12 @@ XMP_FileFormat format = it->first; FileHandlerPair handlers = it->second; - if( handlers.mStandardHandler != NULL ) + if( handlers.mStandardHandler != libcppNULL ) { registerHandler( format, handlers.mStandardHandler ); } - if( handlers.mReplacementHandler != NULL ) + if( handlers.mReplacementHandler != libcppNULL ) { registerHandler( format, handlers.mReplacementHandler ); } @@ -824,3 +824,4 @@ } } // namespace XMP_PLUGIN +#endif \ No newline at end of file diff -Nru exempi-2.5.2/XMPFiles/source/PluginHandler/PluginManager.h exempi-2.6.1/XMPFiles/source/PluginHandler/PluginManager.h --- exempi-2.5.2/XMPFiles/source/PluginHandler/PluginManager.h 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/PluginHandler/PluginManager.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef PLUGINMANAGER_H @@ -14,7 +14,6 @@ #include "XMPCommon/XMPCommonDefines.h" - #if SUPPORT_SHARED_POINTERS_IN_STD #include #include diff -Nru exempi-2.5.2/XMPFiles/source/PluginHandler/XMPAtoms.cpp exempi-2.6.1/XMPFiles/source/PluginHandler/XMPAtoms.cpp --- exempi-2.5.2/XMPFiles/source/PluginHandler/XMPAtoms.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/PluginHandler/XMPAtoms.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,17 +1,17 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "XMPAtoms.h" #include "XMPFiles/source/HandlerRegistry.h" using namespace Common; - +#if EnablePluginManager namespace XMP_PLUGIN { @@ -427,3 +427,4 @@ } } //namespace XMP_PLUGIN +#endif diff -Nru exempi-2.5.2/XMPFiles/source/PluginHandler/XMPAtoms.h exempi-2.6.1/XMPFiles/source/PluginHandler/XMPAtoms.h --- exempi-2.5.2/XMPFiles/source/PluginHandler/XMPAtoms.h 2016-12-07 05:07:54.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/PluginHandler/XMPAtoms.h 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2011 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2011 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #ifndef _H_XMPATOMS diff -Nru exempi-2.5.2/XMPFiles/source/WXMPFiles.cpp exempi-2.6.1/XMPFiles/source/WXMPFiles.cpp --- exempi-2.5.2/XMPFiles/source/WXMPFiles.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/WXMPFiles.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2004 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2004 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" @@ -321,12 +321,15 @@ StartPerfCheck ( kAPIPerf_GetXMP, "" ); bool hasXMP = false; - XMP_StringPtr packetStr; - XMP_StringLen packetLen; - - if ( xmpRef == 0 ) { + XMP_StringPtr packetStr = NULL; + XMP_StringLen packetLen = 0; + /*Adding check to handle case where a client might not send XMPMetaRef but still want xmp packet in return. eg. CTECHXMP-4170329*/ + if ( xmpRef == 0 && clientPacket != 0 ) { hasXMP = thiz->GetXMP ( 0, &packetStr, &packetLen, packetInfo ); - } else { + } else if ( xmpRef == 0 && clientPacket == 0 ) { + hasXMP = thiz->GetXMP( 0, 0, 0, packetInfo ); + } + else { SXMPMeta xmpObj ( xmpRef ); hasXMP = thiz->GetXMP ( &xmpObj, &packetStr, &packetLen, packetInfo ); } diff -Nru exempi-2.5.2/XMPFiles/source/XMPFiles.cpp exempi-2.6.1/XMPFiles/source/XMPFiles.cpp --- exempi-2.5.2/XMPFiles/source/XMPFiles.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/XMPFiles.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2004 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2004 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! Must be the first #include! @@ -375,7 +375,7 @@ // ================================================================================================= -XMPFiles::~XMPFiles() +XMPFiles::~XMPFiles() NO_EXCEPT_FALSE { XMP_FILES_START XMP_Assert ( this->clientRefs <= 0 ); @@ -1083,7 +1083,7 @@ if ( handler->containsXMP ) FillPacketInfo ( handler->xmpPacket, &handler->packetInfo ); - if ( (! (openFlags & kXMPFiles_OpenForUpdate)) && (! (handlerFlags & kXMPFiles_HandlerOwnsFile)) ) { + if ( (! (openFlags & kXMPFiles_OpenForUpdate)) && (! (handlerFlags & kXMPFiles_HandlerOwnsFile)) && (!(handlerFlags & kXMPFiles_NeedsLocalFileOpened)) ){ // Close the disk file now if opened for read-only access. CloseLocalFile ( thiz ); } @@ -1146,7 +1146,7 @@ FillPacketInfo( handler->xmpPacket, &handler->packetInfo ); } - if( (! (openFlags & kXMPFiles_OpenForUpdate)) && (! (handlerFlags & kXMPFiles_HandlerOwnsFile)) ) + if( (! (openFlags & kXMPFiles_OpenForUpdate)) && (! (handlerFlags & kXMPFiles_HandlerOwnsFile)) && (!(handlerFlags & kXMPFiles_NeedsLocalFileOpened)) ) { // Close the disk file now if opened for read-only access. CloseLocalFile ( thiz ); @@ -1172,11 +1172,11 @@ bool XMPFiles::OpenFile ( XMP_StringPtr clientPath, - XMP_FileFormat format1 /* = kXMP_UnknownFile */, - XMP_OptionBits openFlags1 /* = 0 */ ) + XMP_FileFormat _format /* = kXMP_UnknownFile */, + XMP_OptionBits _openFlags /* = 0 */ ) { XMP_FILES_START - return DoOpenFile ( this, 0, clientPath, format1, openFlags1 ); + return DoOpenFile ( this, 0, clientPath, _format, _openFlags ); XMP_FILES_END2 ( clientPath, kXMPErrSev_FileFatal ) return false; } @@ -1187,12 +1187,12 @@ bool XMPFiles::OpenFile ( XMP_IO* clientIO, - XMP_FileFormat format1 /* = kXMP_UnknownFile */, - XMP_OptionBits openFlags1 /* = 0 */ ) + XMP_FileFormat _format /* = kXMP_UnknownFile */, + XMP_OptionBits _openFlags /* = 0 */ ) { XMP_FILES_START this->progressTracker = 0; // Progress tracking is not supported for client-managed I/O. - return DoOpenFile ( this, clientIO, "", format1, openFlags1 ); + return DoOpenFile ( this, clientIO, "", _format, _openFlags ); XMP_FILES_END1 ( kXMPErrSev_FileFatal ) return false; @@ -1200,11 +1200,11 @@ bool XMPFiles::OpenFile ( const Common::XMPFileHandlerInfo& hdlInfo, XMP_IO* clientIO, - XMP_OptionBits openFlags1 /*= 0*/ ) + XMP_OptionBits _openFlags /*= 0*/ ) { XMP_FILES_START this->progressTracker = 0; // Progress tracking is not supported for client-managed I/O. - return DoOpenFile ( this, hdlInfo, clientIO, NULL, openFlags1 ); + return DoOpenFile ( this, hdlInfo, clientIO, NULL, _openFlags ); XMP_FILES_END1 ( kXMPErrSev_FileFatal ) return false; @@ -1215,12 +1215,12 @@ // ================================================================================================= bool XMPFiles::OpenFile ( const Common::XMPFileHandlerInfo& hdlInfo, - XMP_StringPtr filePath1, - XMP_OptionBits openFlags1 /*= 0*/ ) + XMP_StringPtr _filePath, + XMP_OptionBits _openFlags /*= 0*/ ) { XMP_FILES_START - return DoOpenFile ( this, hdlInfo, NULL, filePath1, openFlags1 ); - XMP_FILES_END2 (filePath1, kXMPErrSev_FileFatal ) + return DoOpenFile ( this, hdlInfo, NULL, _filePath, _openFlags ); + XMP_FILES_END2 (_filePath, kXMPErrSev_FileFatal ) return false; } @@ -1387,26 +1387,31 @@ // ================================================================================================= bool -XMPFiles::GetFileInfo ( XMP_StringPtr * filePath1 /* = 0 */, +XMPFiles::GetFileInfo ( XMP_StringPtr * _filePath /* = 0 */, XMP_StringLen * pathLen /* = 0 */, - XMP_OptionBits * openFlags1 /* = 0 */, - XMP_FileFormat * format1 /* = 0 */, + XMP_OptionBits * _openFlags /* = 0 */, + XMP_FileFormat * _format /* = 0 */, XMP_OptionBits * handlerFlags /* = 0 */ ) const { XMP_FILES_START if ( this->handler == 0 ) return false; - /*XMPFileHandler * handler = this->handler;*/ + //XMPFileHandler * handler = this->handler; - if ( filePath1 == 0 ) filePath1 = &voidStringPtr; + XMP_StringPtr voidStringPtr = 0; + XMP_StringLen voidStringLen = 0; + XMP_OptionBits voidOptionBits = 0; + XMP_FileFormat voidFileFormat = 0; + + if ( _filePath == 0 ) _filePath = &voidStringPtr; if ( pathLen == 0 ) pathLen = &voidStringLen; - if ( openFlags1 == 0 ) openFlags1 = &voidOptionBits; - if ( format1 == 0 ) format1 = &voidFileFormat; + if ( _openFlags == 0 ) _openFlags = &voidOptionBits; + if ( _format == 0 ) _format = &voidFileFormat; if ( handlerFlags == 0 ) handlerFlags = &voidOptionBits; - *filePath1 = this->filePath.c_str(); + *_filePath = this->filePath.c_str(); *pathLen = (XMP_StringLen) this->filePath.size(); - *openFlags1 = this->openFlags; - *format1 = this->format; + *_openFlags = this->openFlags; + *_format = this->format; *handlerFlags = this->handler->handlerFlags; XMP_FILES_END1 ( kXMPErrSev_FileFatal ) return true; @@ -1416,14 +1421,14 @@ // ================================================================================================= void -XMPFiles::SetAbortProc ( XMP_AbortProc abortProc1, - void * abortArg1 ) +XMPFiles::SetAbortProc ( XMP_AbortProc _abortProc, + void * _abortArg ) { XMP_FILES_START - this->abortProc = abortProc1; - this->abortArg = abortArg1; + this->abortProc = _abortProc; + this->abortArg = _abortArg; - XMP_Assert ( (abortProc1 != (XMP_AbortProc)0) || (abortArg1 != (void*)(unsigned long long)0xDEADBEEFULL) ); // Hack to test the assert callback. + XMP_Assert ( (_abortProc != (XMP_AbortProc)0) || (_abortArg != (void*)(unsigned long long)0xDEADBEEFULL) ); // Hack to test the assert callback. XMP_FILES_END1 ( kXMPErrSev_OperationFatal ) } // XMPFiles::SetAbortProc @@ -1464,6 +1469,27 @@ XMP_FILES_START if ( this->handler == 0 ) XMP_Throw ( "XMPFiles::GetXMP - No open file", kXMPErr_BadObject ); + /* + Sometimes XMP can be very huge See : CTECHXMP-4170126 + Client needs to know the length of XMP packet in file, so they can + decide whether they want to process XMP packet or not. + + This is possible, if format knows the length of XMP packet in file during CacheFileData. + So, if client pass only XMP_PacketInfo and does not pass meta object and xmp packet length is + known during CacheFileData, we can provide this info to client without processing xmp. + */ + + if(! this->handler->processedXMP && !xmpObj && !(this->handler->xmpPacket.empty()) && packetInfo) + { + /*CTECHXMP-4170329: xmppacket and xmpPacketLen will only be populated if client has explicitly requested for xmp packet*/ + if ( xmpPacket != 0 ) *xmpPacket = this->handler->xmpPacket.c_str(); + if ( xmpPacketLen != 0 ) *xmpPacketLen = (XMP_StringLen)this->handler->xmpPacket.size(); + + SetClientPacketInfo(packetInfo, this->handler->packetInfo, + this->handler->xmpPacket, this->handler->needsUpdate ); + return true; + } + XMP_OptionBits applyTemplateFlags = kXMPTemplate_AddNewProperties | kXMPTemplate_IncludeInternalProperties; if ( ! this->handler->processedXMP ) { @@ -1482,6 +1508,9 @@ this->handler->xmpPacket, this->handler->needsUpdate ); throw; } + if ((this->handler->handlerFlags & kXMPFiles_NeedsLocalFileOpened) && !(this->openFlags & kXMPFiles_OpenForUpdate)) { + CloseLocalFile(this); + } } if ( ! this->handler->containsXMP ) return false; @@ -1771,13 +1800,13 @@ // This is const just to be usable from const XMPMeta functions. bool - XMPFiles::ErrorCallbackInfo::ClientCallbackWrapper ( XMP_StringPtr filePath1, + XMPFiles::ErrorCallbackInfo::ClientCallbackWrapper ( XMP_StringPtr _filePath, XMP_ErrorSeverity severity, XMP_Int32 cause, XMP_StringPtr messsage ) const { - XMP_StringPtr filePathPtr = filePath1; + XMP_StringPtr filePathPtr = _filePath; if ( filePathPtr == 0 ) { filePathPtr = this->filePath.c_str(); } diff -Nru exempi-2.5.2/XMPFiles/source/XMPFiles.hpp exempi-2.6.1/XMPFiles/source/XMPFiles.hpp --- exempi-2.5.2/XMPFiles/source/XMPFiles.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/XMPFiles.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __XMPFiles_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2004 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2004 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! This must be the first include. @@ -213,7 +213,7 @@ XMP_Uns32 limit); XMPFiles(); - virtual ~XMPFiles(); + virtual ~XMPFiles() NO_EXCEPT_FALSE; bool OpenFile(XMP_StringPtr filePath, XMP_FileFormat format = kXMP_UnknownFile, XMP_OptionBits openFlags = 0); bool OpenFile(const Common::XMPFileHandlerInfo & hdlInfo, XMP_StringPtr filePath, XMP_OptionBits openFlags = 0); diff -Nru exempi-2.5.2/XMPFiles/source/XMPFiles_Impl.cpp exempi-2.6.1/XMPFiles/source/XMPFiles_Impl.cpp --- exempi-2.5.2/XMPFiles/source/XMPFiles_Impl.cpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/XMPFiles_Impl.cpp 2021-11-18 03:53:54.000000000 +0000 @@ -1,10 +1,10 @@ // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2004 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2004 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header. @@ -19,7 +19,7 @@ using namespace std; -// Internal code should be using #if with XMP_MacBuild, XMP_WinBuild, or XMP_UNIXBuild. +// Internal code should be using #if with XMP_MacBuild, XMP_WinBuild, XMP_AndroidBuild, or XMP_UNIXBuild. // This is a sanity check in case of accidental use of *_ENV. Some clients use the poor // practice of defining the *_ENV macro with an empty value. #if defined ( MAC_ENV ) @@ -34,6 +34,10 @@ #if ! UNIX_ENV #error "UNIX_ENV must be defined so that \"#if UNIX_ENV\" is true" #endif +#elif defined ( ANDROID_ENV ) + #if ! ANDROID_ENV + #error "ANDROID_ENV must be defined so that \"#if ANDROID_ENV\" is true" + #endif #endif // ================================================================================================= @@ -43,10 +47,7 @@ /// This file ... /// // ================================================================================================= - -#if ! XMP_StaticBuild - #include "public/include/XMP.incl_cpp" -#endif +#include "public/include/XMP.incl_cpp" #if XMP_WinBuild #pragma warning ( disable : 4290 ) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) @@ -57,13 +58,15 @@ XMP_FileFormat voidFileFormat = 0; // Used as sink for unwanted output parameters. -#if ! XMP_StaticBuild - XMP_PacketInfo voidPacketInfo; - void * voidVoidPtr = 0; - XMP_StringPtr voidStringPtr = 0; - XMP_StringLen voidStringLen = 0; - XMP_OptionBits voidOptionBits = 0; -#endif +//***** see CTECHXMP-4169947 ***** + +//#if ! XMP_StaticBuild +// XMP_PacketInfo voidPacketInfo; +// void * voidVoidPtr = 0; +// XMP_StringPtr voidStringPtr = 0; +// XMP_StringLen voidStringLen = 0; +// XMP_OptionBits voidOptionBits = 0; +//#endif // ================================================================================================= @@ -100,6 +103,7 @@ { "f4v", kXMP_MPEG4File }, { "3gp", kXMP_MPEG4File }, { "3g2", kXMP_MPEG4File }, + { "crm", kXMP_MPEG4File }, { "ses", kXMP_SESFile }, { "cel", kXMP_CELFile }, { "wma", kXMP_WMAVFile }, @@ -121,6 +125,9 @@ { "vob", kXMP_MPEGFile }, { "ms-pvr", kXMP_MPEGFile }, { "dvr-ms", kXMP_MPEGFile }, + { "heic", kXMP_HEIFFile }, + { "heif", kXMP_HEIFFile }, + { "avc1", kXMP_HEIFFile }, { "html", kXMP_HTMLFile }, { "xml", kXMP_XMLFile }, diff -Nru exempi-2.5.2/XMPFiles/source/XMPFiles_Impl.hpp exempi-2.6.1/XMPFiles/source/XMPFiles_Impl.hpp --- exempi-2.5.2/XMPFiles/source/XMPFiles_Impl.hpp 2019-07-28 02:00:48.000000000 +0000 +++ exempi-2.6.1/XMPFiles/source/XMPFiles_Impl.hpp 2021-11-18 03:53:54.000000000 +0000 @@ -2,12 +2,12 @@ #define __XMPFiles_Impl_hpp__ 1 // ================================================================================================= -// ADOBE SYSTEMS INCORPORATED -// Copyright 2004 Adobe Systems Incorporated +// Copyright Adobe +// Copyright 2004 Adobe // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms -// of the Adobe license agreement accompanying it. +// of the Adobe license agreement accompanying it. // ================================================================================================= #include "public/include/XMP_Environment.h" // ! Must be the first #include! @@ -76,7 +76,7 @@ #endif #ifndef EnablePluginManager - #if XMP_iOSBuild + #if (XMP_iOSBuild) || (XMP_UWP) #define EnablePluginManager 0 #else #define EnablePluginManager 1 @@ -142,12 +142,15 @@ #endif -extern XMP_FileFormat voidFileFormat; // Used as sink for unwanted output parameters. -extern XMP_PacketInfo voidPacketInfo; -extern void * voidVoidPtr; -extern XMP_StringPtr voidStringPtr; -extern XMP_StringLen voidStringLen; -extern XMP_OptionBits voidOptionBits; +// **** See CTECHXMP-4169947 ***** + +//extern XMP_FileFormat voidFileFormat; // Used as sink for unwanted output parameters. +//extern XMP_PacketInfo voidPacketInfo; +//extern void * voidVoidPtr; +//extern XMP_StringPtr voidStringPtr; +//extern XMP_StringLen voidStringLen; +//extern XMP_OptionBits voidOptionBits; + #define kUTF8_PacketStart (const XMP_Uns8 *)"