Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- local-test-libexif-delta-01-exif-003/afc-libexif/auto-m4/.gitignore +1 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/binary-dist/.gitignore +2 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/binary-dist/Makefile.am +13 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/contrib/.gitignore +2 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/contrib/Makefile.am +7 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/contrib/aolserver/nsexif.c +143 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/contrib/c++/exif.hxx +536 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/contrib/c++/exif_module.cxx +524 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/contrib/examples/.gitignore +2 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/contrib/examples/Makefile.am +11 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/contrib/examples/cam_features.c +175 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/contrib/examples/photographer.c +125 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/contrib/examples/thumbnail.c +66 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/contrib/examples/write-exif.c +301 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/contrib/watcom/_stdint.h +13 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/doc/.gitignore +8 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/doc/Doxyfile-internals.in +0 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/doc/Doxyfile.in +0 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/doc/Makefile.am +113 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/doc/README.apidocs +7 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/doc/footer.html +12 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/.gitignore +10 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/Makefile.am +73 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/apple/.gitignore +6 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/apple/Makefile-files +7 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/apple/exif-mnote-data-apple.c +288 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/apple/exif-mnote-data-apple.h +44 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/apple/mnote-apple-entry.c +155 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/apple/mnote-apple-entry.h +41 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/apple/mnote-apple-tag.c +89 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/apple/mnote-apple-tag.h +46 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/canon/.gitignore +6 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/canon/Makefile-files +7 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/canon/exif-mnote-data-canon.c +433 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/canon/exif-mnote-data-canon.h +58 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/canon/mnote-canon-entry.c +822 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/canon/mnote-canon-entry.h +44 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/canon/mnote-canon-tag.c +201 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/canon/mnote-canon-tag.h +59 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-byte-order.c +39 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-byte-order.h +48 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-content.c +333 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-content.h +181 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-data-type.h +46 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-data.c +1348 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-data.h +267 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-entry.c +1809 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-entry.h +186 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-format.c +74 -0
- local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-format.h +65 -0
local-test-libexif-delta-01-exif-003/afc-libexif/auto-m4/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
*.m4
|
local-test-libexif-delta-01-exif-003/afc-libexif/binary-dist/.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Makefile
|
| 2 |
+
Makefile.in
|
local-test-libexif-delta-01-exif-003/afc-libexif/binary-dist/Makefile.am
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
if SHIP_BINARIES
|
| 2 |
+
|
| 3 |
+
EXTRA_DIST = include bin
|
| 4 |
+
|
| 5 |
+
SH_DIST_HOOK = dist-ship-binary-hook
|
| 6 |
+
dist-ship-binary-hook include bin:
|
| 7 |
+
cd "$(top_builddir)" && $(MAKE) includedir="$(PWD)/include" DESTDIR="" prefix="$(PWD)/tmp" install
|
| 8 |
+
$(MKDIR_P) "$(PWD)/bin"
|
| 9 |
+
cp "$(PWD)/tmp/bin/"*.dll "bin/"
|
| 10 |
+
|
| 11 |
+
endif
|
| 12 |
+
|
| 13 |
+
dist-hook: $(SH_DIST_HOOK)
|
local-test-libexif-delta-01-exif-003/afc-libexif/contrib/.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Makefile
|
| 2 |
+
Makefile.in
|
local-test-libexif-delta-01-exif-003/afc-libexif/contrib/Makefile.am
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
SUBDIRS = examples
|
| 2 |
+
|
| 3 |
+
# The c++ and aolserver contrib directories are out of date and are
|
| 4 |
+
# are pointless to distribute in the offical source release.
|
| 5 |
+
|
| 6 |
+
EXTRA_DIST = watcom/Makefile watcom/_stdint.h
|
| 7 |
+
|
local-test-libexif-delta-01-exif-003/afc-libexif/contrib/aolserver/nsexif.c
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2000 Curtis Galloway
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining
|
| 6 |
+
a copy of this software and associated documentation files (the
|
| 7 |
+
"Software"), to deal in the Software without restriction, including
|
| 8 |
+
without limitation the rights to use, copy, modify, merge, publish,
|
| 9 |
+
distribute, sublicense, and/or sell copies of the Software, and to
|
| 10 |
+
permit persons to whom the Software is furnished to do so, subject to
|
| 11 |
+
the following conditions:
|
| 12 |
+
|
| 13 |
+
The above copyright notice and this permission notice shall be
|
| 14 |
+
included in all copies or substantial portions of the Software.
|
| 15 |
+
|
| 16 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 17 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 18 |
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 19 |
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
| 20 |
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
| 21 |
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
| 22 |
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 23 |
+
|
| 24 |
+
This is a loadable module for the AOLserver web server that provides
|
| 25 |
+
an interface to the EXIF tag parsing library.
|
| 26 |
+
|
| 27 |
+
It adds one Tcl command into the AOLserver Tcl interpreter:
|
| 28 |
+
|
| 29 |
+
ns_exif <file>
|
| 30 |
+
|
| 31 |
+
It returns the ID of an ns_set that contains the tag names and values
|
| 32 |
+
from the EXIF file.
|
| 33 |
+
|
| 34 |
+
*/
|
| 35 |
+
|
| 36 |
+
#include "ns.h"
|
| 37 |
+
|
| 38 |
+
#include "exif.h"
|
| 39 |
+
|
| 40 |
+
#define BUFSIZE 1024
|
| 41 |
+
|
| 42 |
+
static void
|
| 43 |
+
rec_put(Ns_Set *set, exif_record_t *rec)
|
| 44 |
+
{
|
| 45 |
+
char buf[BUFSIZE];
|
| 46 |
+
char *str = buf;
|
| 47 |
+
|
| 48 |
+
switch (rec->rec_type) {
|
| 49 |
+
case 's':
|
| 50 |
+
str = rec->rec_data.s;
|
| 51 |
+
break;
|
| 52 |
+
case 'f':
|
| 53 |
+
snprintf(buf, BUFSIZE, "%f", rec->rec_data.f);
|
| 54 |
+
break;
|
| 55 |
+
case 'g':
|
| 56 |
+
snprintf(buf, BUFSIZE, "%g", rec->rec_data.f);
|
| 57 |
+
break;
|
| 58 |
+
case 'l':
|
| 59 |
+
snprintf(buf, BUFSIZE, "%ld", rec->rec_data.l);
|
| 60 |
+
break;
|
| 61 |
+
case 'r':
|
| 62 |
+
snprintf(buf, BUFSIZE, "%d/%d", rec->rec_data.r.num,
|
| 63 |
+
rec->rec_data.r.denom);
|
| 64 |
+
break;
|
| 65 |
+
default:
|
| 66 |
+
snprintf(buf, BUFSIZE, "<Unknown record type '%c'>", rec->rec_type);
|
| 67 |
+
break;
|
| 68 |
+
}
|
| 69 |
+
Ns_SetPut(set, rec->rec_name, str);
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
static int
|
| 73 |
+
Tcl_ReadExifDataCmd (
|
| 74 |
+
ClientData clientData,
|
| 75 |
+
Tcl_Interp *interp,
|
| 76 |
+
int argc,
|
| 77 |
+
char **argv)
|
| 78 |
+
{
|
| 79 |
+
exif_data_t *d;
|
| 80 |
+
int i;
|
| 81 |
+
Ns_Set *rset;
|
| 82 |
+
|
| 83 |
+
d = exif_parse_file(argv[1]);
|
| 84 |
+
if (d == NULL) {
|
| 85 |
+
Tcl_AppendResult(interp, "Could not process file '", argv[1], "'", NULL);
|
| 86 |
+
return TCL_ERROR;
|
| 87 |
+
}
|
| 88 |
+
rset = Ns_SetCreate("exif");
|
| 89 |
+
|
| 90 |
+
for (i=0; i<d->n_recs; i++) {
|
| 91 |
+
rec_put(rset, &d->recs[i]);
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
Ns_TclEnterSet(interp, rset, NS_TCL_SET_TEMPORARY | NS_TCL_SET_DYNAMIC);
|
| 95 |
+
exif_free_data(d);
|
| 96 |
+
return TCL_OK;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
/*----------------------------------------------------------------------
|
| 101 |
+
*
|
| 102 |
+
* Tcl_InitExif --
|
| 103 |
+
*
|
| 104 |
+
* Initialize the Tcl command.
|
| 105 |
+
*
|
| 106 |
+
*----------------------------------------------------------------------
|
| 107 |
+
*/
|
| 108 |
+
void
|
| 109 |
+
Tcl_InitExif (interp)
|
| 110 |
+
Tcl_Interp *interp;
|
| 111 |
+
{
|
| 112 |
+
Tcl_CreateCommand (interp, "ns_exif", Tcl_ReadExifDataCmd,
|
| 113 |
+
NULL, NULL);
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
static int
|
| 117 |
+
nsexif_interp_init (Tcl_Interp *interp, void *dummy)
|
| 118 |
+
{
|
| 119 |
+
Tcl_InitExif(interp);
|
| 120 |
+
return TCL_OK;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
int
|
| 125 |
+
Ns_ModuleInit(char *hServer, char *hModule)
|
| 126 |
+
{
|
| 127 |
+
char *configPath;
|
| 128 |
+
|
| 129 |
+
Ns_Log( Notice, "%s module starting", hModule);
|
| 130 |
+
|
| 131 |
+
exif_init((void *(*)(int))Ns_Malloc,
|
| 132 |
+
(void (*)(void *))Ns_Free,
|
| 133 |
+
(void *(*)(void *, int))Ns_Realloc);
|
| 134 |
+
|
| 135 |
+
configPath = Ns_ConfigGetPath(hServer, hModule, NULL);
|
| 136 |
+
/* if (!Ns_ConfigGetBool (configPath, "Debug", &debug_p))
|
| 137 |
+
debug_p = DEFAULT_DEBUG; */
|
| 138 |
+
|
| 139 |
+
Ns_TclInitInterps (hServer, nsexif_interp_init, NULL);
|
| 140 |
+
return NS_OK;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
int Ns_ModuleVersion = 1;
|
local-test-libexif-delta-01-exif-003/afc-libexif/contrib/c++/exif.hxx
ADDED
|
@@ -0,0 +1,536 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* exif.hxx
|
| 2 |
+
*
|
| 3 |
+
* Copyright 2002,2003 Hans Meine <[email protected]>
|
| 4 |
+
*
|
| 5 |
+
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef EXIF_HXX
|
| 22 |
+
#define EXIF_HXX
|
| 23 |
+
|
| 24 |
+
#include <libexif/exif-entry.h>
|
| 25 |
+
#include <libexif/exif-content.h>
|
| 26 |
+
#include <libexif/exif-ifd.h>
|
| 27 |
+
#include <libexif/exif-data.h>
|
| 28 |
+
#include <libexif/exif-format.h>
|
| 29 |
+
#include <libexif/exif-utils.h>
|
| 30 |
+
#include <stdexcept>
|
| 31 |
+
#include <string>
|
| 32 |
+
|
| 33 |
+
namespace Exif {
|
| 34 |
+
|
| 35 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 36 |
+
struct InvalidIndex : std::runtime_error
|
| 37 |
+
{
|
| 38 |
+
InvalidIndex(const std::string& s)
|
| 39 |
+
: std::runtime_error(s) {}
|
| 40 |
+
};
|
| 41 |
+
|
| 42 |
+
struct InvalidFormat : std::runtime_error
|
| 43 |
+
{
|
| 44 |
+
InvalidFormat(const std::string& s)
|
| 45 |
+
: std::runtime_error(s) {}
|
| 46 |
+
};
|
| 47 |
+
|
| 48 |
+
struct IOError : std::runtime_error
|
| 49 |
+
{
|
| 50 |
+
IOError(const std::string& s)
|
| 51 |
+
: std::runtime_error(s) {}
|
| 52 |
+
};
|
| 53 |
+
#endif // EXIF_NO_EXCEPTIONS
|
| 54 |
+
|
| 55 |
+
struct Entry
|
| 56 |
+
{
|
| 57 |
+
ExifEntry *entry_;
|
| 58 |
+
|
| 59 |
+
// construct an empty entry, FIXME: is this needed in the public API?
|
| 60 |
+
Entry()
|
| 61 |
+
: entry_(exif_entry_new())
|
| 62 |
+
{}
|
| 63 |
+
|
| 64 |
+
// construct an entry for the given tag
|
| 65 |
+
Entry(ExifTag tag)
|
| 66 |
+
: entry_(exif_entry_new())
|
| 67 |
+
{
|
| 68 |
+
exif_entry_initialize(entry_, tag);
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
// copy constructor
|
| 72 |
+
Entry(Entry const &other)
|
| 73 |
+
: entry_(other.entry_)
|
| 74 |
+
{
|
| 75 |
+
exif_entry_ref(entry_);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
// internal, do not use directly
|
| 79 |
+
Entry(ExifEntry *entry)
|
| 80 |
+
: entry_(entry)
|
| 81 |
+
{
|
| 82 |
+
exif_entry_ref(entry_);
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
~Entry()
|
| 86 |
+
{
|
| 87 |
+
exif_entry_unref(entry_);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
Entry &operator=(Entry const &other)
|
| 91 |
+
{
|
| 92 |
+
exif_entry_unref(entry_);
|
| 93 |
+
entry_ = other.entry_;
|
| 94 |
+
exif_entry_ref(entry_);
|
| 95 |
+
return *this;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
ExifTag tag() const
|
| 99 |
+
{
|
| 100 |
+
return entry_->tag;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
/*
|
| 104 |
+
void setTag(ExifTag tag)
|
| 105 |
+
{
|
| 106 |
+
entry_->tag = tag;
|
| 107 |
+
}
|
| 108 |
+
*/
|
| 109 |
+
|
| 110 |
+
ExifFormat format() const
|
| 111 |
+
{
|
| 112 |
+
return entry_->format;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
/*
|
| 116 |
+
void setFormat(ExifFormat format)
|
| 117 |
+
{
|
| 118 |
+
entry_->format = format;
|
| 119 |
+
}
|
| 120 |
+
*/
|
| 121 |
+
|
| 122 |
+
unsigned long components() const
|
| 123 |
+
{
|
| 124 |
+
return entry_->components;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
/*
|
| 128 |
+
void setComponents(unsigned long components)
|
| 129 |
+
{
|
| 130 |
+
entry_->components = components;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
void initialize(ExifTag tag)
|
| 134 |
+
{
|
| 135 |
+
exif_entry_initialize(entry_, tag);
|
| 136 |
+
}
|
| 137 |
+
*/
|
| 138 |
+
|
| 139 |
+
ExifByte getByte(unsigned int index) const
|
| 140 |
+
{
|
| 141 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 142 |
+
if(entry_->format != EXIF_FORMAT_BYTE)
|
| 143 |
+
throw InvalidFormat(
|
| 144 |
+
"Exif::Entry::getByte(): Format is not EXIF_FORMAT_BYTE");
|
| 145 |
+
if(index >= components())
|
| 146 |
+
throw InvalidIndex(
|
| 147 |
+
"Exif::getByte: component index out of range");
|
| 148 |
+
#endif
|
| 149 |
+
return *(entry_->data
|
| 150 |
+
+ index * exif_format_get_size(entry_->format));
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
const ExifAscii getAscii() const
|
| 154 |
+
{
|
| 155 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 156 |
+
if(entry_->format != EXIF_FORMAT_ASCII)
|
| 157 |
+
throw InvalidFormat(
|
| 158 |
+
"Exif::Entry::getAscii(): Format is not EXIF_FORMAT_ASCII");
|
| 159 |
+
#endif
|
| 160 |
+
return (ExifAscii)entry_->data;
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
ExifShort getShort(unsigned int index) const
|
| 164 |
+
{
|
| 165 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 166 |
+
if(entry_->format != EXIF_FORMAT_SHORT)
|
| 167 |
+
throw InvalidFormat(
|
| 168 |
+
"Exif::Entry::getShort(): Format is not EXIF_FORMAT_SHORT");
|
| 169 |
+
if(index >= components())
|
| 170 |
+
throw InvalidIndex(
|
| 171 |
+
"Exif::getShort: component index out of range");
|
| 172 |
+
#endif
|
| 173 |
+
return exif_get_short(entry_->data
|
| 174 |
+
+ index * exif_format_get_size(entry_->format),
|
| 175 |
+
exif_data_get_byte_order(entry_->parent->parent));
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
ExifLong getLong(unsigned int index) const
|
| 179 |
+
{
|
| 180 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 181 |
+
if(entry_->format != EXIF_FORMAT_LONG)
|
| 182 |
+
throw InvalidFormat(
|
| 183 |
+
"Exif::Entry::getLong(): Format is not EXIF_FORMAT_LONG");
|
| 184 |
+
if(index >= components())
|
| 185 |
+
throw InvalidIndex(
|
| 186 |
+
"Exif::getLong: component index out of range");
|
| 187 |
+
#endif
|
| 188 |
+
return exif_get_long(entry_->data
|
| 189 |
+
+ index * exif_format_get_size(entry_->format),
|
| 190 |
+
exif_data_get_byte_order(entry_->parent->parent));
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
ExifSLong getSLong(unsigned int index) const
|
| 194 |
+
{
|
| 195 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 196 |
+
if(entry_->format != EXIF_FORMAT_SLONG)
|
| 197 |
+
throw InvalidFormat(
|
| 198 |
+
"Exif::Entry::getSLong(): Format is not EXIF_FORMAT_SLONG");
|
| 199 |
+
if(index >= components())
|
| 200 |
+
throw InvalidIndex(
|
| 201 |
+
"Exif::getSLong: component index out of range");
|
| 202 |
+
#endif
|
| 203 |
+
return exif_get_slong(entry_->data
|
| 204 |
+
+ index * exif_format_get_size(entry_->format),
|
| 205 |
+
exif_data_get_byte_order(entry_->parent->parent));
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
ExifRational getRational(unsigned int index) const
|
| 209 |
+
{
|
| 210 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 211 |
+
if(entry_->format != EXIF_FORMAT_RATIONAL)
|
| 212 |
+
throw InvalidFormat(
|
| 213 |
+
"Exif::Entry::getRational(): Format is not EXIF_FORMAT_RATIONAL");
|
| 214 |
+
if(index >= components())
|
| 215 |
+
throw InvalidIndex(
|
| 216 |
+
"Exif::getRational: component index out of range");
|
| 217 |
+
#endif
|
| 218 |
+
return exif_get_rational(entry_->data
|
| 219 |
+
+ index * exif_format_get_size(entry_->format),
|
| 220 |
+
exif_data_get_byte_order(entry_->parent->parent));
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
ExifSRational getSRational(unsigned int index) const
|
| 224 |
+
{
|
| 225 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 226 |
+
if(entry_->format != EXIF_FORMAT_SRATIONAL)
|
| 227 |
+
throw InvalidFormat(
|
| 228 |
+
"Exif::Entry::getSRational(): Format is not EXIF_FORMAT_SRATIONAL");
|
| 229 |
+
if(index >= components())
|
| 230 |
+
throw InvalidIndex(
|
| 231 |
+
"Exif::getSRational: component index out of range");
|
| 232 |
+
#endif
|
| 233 |
+
return exif_get_srational(entry_->data
|
| 234 |
+
+ index * exif_format_get_size(entry_->format),
|
| 235 |
+
exif_data_get_byte_order(entry_->parent->parent));
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
void setByte(unsigned int index, ExifByte value) const
|
| 239 |
+
{
|
| 240 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 241 |
+
if(entry_->format != EXIF_FORMAT_BYTE)
|
| 242 |
+
throw InvalidFormat(
|
| 243 |
+
"Exif::Entry::setByte(): Format is not EXIF_FORMAT_BYTE");
|
| 244 |
+
if(index >= components())
|
| 245 |
+
throw InvalidIndex(
|
| 246 |
+
"Exif::setByte: component index out of range");
|
| 247 |
+
#endif
|
| 248 |
+
*(entry_->data
|
| 249 |
+
+ index * exif_format_get_size(entry_->format)) = value;
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
/*
|
| 253 |
+
const ExifAscii setAscii() const
|
| 254 |
+
{
|
| 255 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 256 |
+
if(entry_->format != EXIF_FORMAT_ASCII)
|
| 257 |
+
throw InvalidFormat(
|
| 258 |
+
"Exif::Entry::setAscii(): Format is not EXIF_FORMAT_ASCII");
|
| 259 |
+
#endif
|
| 260 |
+
return (ExifAscii)entry_->data;
|
| 261 |
+
}
|
| 262 |
+
*/
|
| 263 |
+
|
| 264 |
+
void setShort(unsigned int index, ExifShort value) const
|
| 265 |
+
{
|
| 266 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 267 |
+
if(entry_->format != EXIF_FORMAT_SHORT)
|
| 268 |
+
throw InvalidFormat(
|
| 269 |
+
"Exif::Entry::setShort(): Format is not EXIF_FORMAT_SHORT");
|
| 270 |
+
if(index >= components())
|
| 271 |
+
throw InvalidIndex(
|
| 272 |
+
"Exif::setShort: component index out of range");
|
| 273 |
+
#endif
|
| 274 |
+
return exif_set_short(entry_->data
|
| 275 |
+
+ index * exif_format_get_size(entry_->format),
|
| 276 |
+
exif_data_get_byte_order(entry_->parent->parent),
|
| 277 |
+
value);
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
void setLong(unsigned int index, ExifLong value) const
|
| 281 |
+
{
|
| 282 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 283 |
+
if(entry_->format != EXIF_FORMAT_LONG)
|
| 284 |
+
throw InvalidFormat(
|
| 285 |
+
"Exif::Entry::setLong(): Format is not EXIF_FORMAT_LONG");
|
| 286 |
+
if(index >= components())
|
| 287 |
+
throw InvalidIndex(
|
| 288 |
+
"Exif::setLong: component index out of range");
|
| 289 |
+
#endif
|
| 290 |
+
return exif_set_long(entry_->data
|
| 291 |
+
+ index * exif_format_get_size(entry_->format),
|
| 292 |
+
exif_data_get_byte_order(entry_->parent->parent),
|
| 293 |
+
value);
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
void setSLong(unsigned int index, ExifSLong value) const
|
| 297 |
+
{
|
| 298 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 299 |
+
if(entry_->format != EXIF_FORMAT_SLONG)
|
| 300 |
+
throw InvalidFormat(
|
| 301 |
+
"Exif::Entry::setSLong(): Format is not EXIF_FORMAT_SLONG");
|
| 302 |
+
if(index >= components())
|
| 303 |
+
throw InvalidIndex(
|
| 304 |
+
"Exif::setSLong: component index out of range");
|
| 305 |
+
#endif
|
| 306 |
+
return exif_set_slong(entry_->data
|
| 307 |
+
+ index * exif_format_get_size(entry_->format),
|
| 308 |
+
exif_data_get_byte_order(entry_->parent->parent),
|
| 309 |
+
value);
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
void setRational(unsigned int index, ExifRational value) const
|
| 313 |
+
{
|
| 314 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 315 |
+
if(entry_->format != EXIF_FORMAT_RATIONAL)
|
| 316 |
+
throw InvalidFormat(
|
| 317 |
+
"Exif::Entry::setRational(): Format is not EXIF_FORMAT_RATIONAL");
|
| 318 |
+
if(index >= components())
|
| 319 |
+
throw InvalidIndex(
|
| 320 |
+
"Exif::setRational: component index out of range");
|
| 321 |
+
#endif
|
| 322 |
+
return exif_set_rational(entry_->data
|
| 323 |
+
+ index * exif_format_get_size(entry_->format),
|
| 324 |
+
exif_data_get_byte_order(entry_->parent->parent),
|
| 325 |
+
value);
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
void setSRational(unsigned int index, ExifSRational value) const
|
| 329 |
+
{
|
| 330 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 331 |
+
if(entry_->format != EXIF_FORMAT_SRATIONAL)
|
| 332 |
+
throw InvalidFormat(
|
| 333 |
+
"Exif::Entry::setSRational(): Format is not EXIF_FORMAT_SRATIONAL");
|
| 334 |
+
if(index >= components())
|
| 335 |
+
throw InvalidIndex(
|
| 336 |
+
"Exif::setSRational: component index out of range");
|
| 337 |
+
#endif
|
| 338 |
+
return exif_set_srational(entry_->data
|
| 339 |
+
+ index * exif_format_get_size(entry_->format),
|
| 340 |
+
exif_data_get_byte_order(entry_->parent->parent),
|
| 341 |
+
value);
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
const char *value()
|
| 345 |
+
{
|
| 346 |
+
return exif_entry_get_value(entry_);
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
const char *briefValue()
|
| 350 |
+
{
|
| 351 |
+
return exif_entry_get_value_brief(entry_);
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
void dump(unsigned int indent = 0) const
|
| 355 |
+
{
|
| 356 |
+
exif_entry_dump(entry_, indent);
|
| 357 |
+
}
|
| 358 |
+
};
|
| 359 |
+
|
| 360 |
+
struct Content
|
| 361 |
+
{
|
| 362 |
+
ExifContent *content_;
|
| 363 |
+
|
| 364 |
+
Content()
|
| 365 |
+
: content_(exif_content_new())
|
| 366 |
+
{}
|
| 367 |
+
|
| 368 |
+
Content(Content const &other)
|
| 369 |
+
: content_(other.content_)
|
| 370 |
+
{
|
| 371 |
+
exif_content_ref(content_);
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
// internal, do not use directly
|
| 375 |
+
Content(ExifContent *content)
|
| 376 |
+
: content_(content)
|
| 377 |
+
{
|
| 378 |
+
exif_content_ref(content_);
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
~Content()
|
| 382 |
+
{
|
| 383 |
+
exif_content_unref(content_);
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
Content &operator=(Content const &other)
|
| 387 |
+
{
|
| 388 |
+
exif_content_unref(content_);
|
| 389 |
+
content_ = other.content_;
|
| 390 |
+
exif_content_ref(content_);
|
| 391 |
+
return *this;
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
Entry operator[](ExifTag tag)
|
| 395 |
+
{
|
| 396 |
+
ExifEntry *result = exif_content_get_entry(content_, tag);
|
| 397 |
+
if(result)
|
| 398 |
+
return Entry(result);
|
| 399 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 400 |
+
throw InvalidIndex(
|
| 401 |
+
"Exif::Content: IFD does not contain given tag");
|
| 402 |
+
#endif
|
| 403 |
+
return Entry();
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
Entry operator[](unsigned int index)
|
| 407 |
+
{
|
| 408 |
+
if(index < size())
|
| 409 |
+
return Entry(content_->entries[index]);
|
| 410 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 411 |
+
throw InvalidIndex(
|
| 412 |
+
"Exif::Content: numeric entry index out of range");
|
| 413 |
+
#endif // EXIF_NO_EXCEPTIONS
|
| 414 |
+
return Entry();
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
unsigned int size() const
|
| 418 |
+
{
|
| 419 |
+
// FIXME: content_ should never be NULL, so this is unneeded!?
|
| 420 |
+
return content_ ? content_->count : 0;
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
void add(Entry &entry)
|
| 424 |
+
{
|
| 425 |
+
exif_content_add_entry(content_, entry.entry_);
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
void remove(Entry &entry)
|
| 429 |
+
{
|
| 430 |
+
exif_content_remove_entry(content_, entry.entry_);
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
// for your convenience
|
| 434 |
+
const char *value(ExifTag tag)
|
| 435 |
+
{
|
| 436 |
+
return exif_content_get_value(content_, tag);
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
// for your convenience
|
| 440 |
+
const char *briefValue(ExifTag tag)
|
| 441 |
+
{
|
| 442 |
+
return exif_content_get_value_brief(content_, tag);
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
void dump(unsigned int indent = 0) const
|
| 446 |
+
{
|
| 447 |
+
exif_content_dump(content_, indent);
|
| 448 |
+
}
|
| 449 |
+
};
|
| 450 |
+
|
| 451 |
+
struct Data
|
| 452 |
+
{
|
| 453 |
+
ExifData *data_;
|
| 454 |
+
|
| 455 |
+
Data()
|
| 456 |
+
: data_(exif_data_new())
|
| 457 |
+
{}
|
| 458 |
+
|
| 459 |
+
Data(const char *path, bool *success = 0)
|
| 460 |
+
: data_(exif_data_new_from_file(path))
|
| 461 |
+
{
|
| 462 |
+
if(success)
|
| 463 |
+
*success = data_;
|
| 464 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 465 |
+
else
|
| 466 |
+
if(!data_)
|
| 467 |
+
throw IOError("Exif::Data: Could not load file");
|
| 468 |
+
#endif // EXIF_NO_EXCEPTIONS
|
| 469 |
+
if(!data_)
|
| 470 |
+
exif_data_new();
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
Data(const unsigned char *data,
|
| 474 |
+
unsigned int size)
|
| 475 |
+
: data_(exif_data_new_from_data(data, size))
|
| 476 |
+
{}
|
| 477 |
+
|
| 478 |
+
Data(Data const &other)
|
| 479 |
+
: data_(other.data_)
|
| 480 |
+
{
|
| 481 |
+
exif_data_ref(data_);
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
~Data()
|
| 485 |
+
{
|
| 486 |
+
exif_data_unref(data_);
|
| 487 |
+
}
|
| 488 |
+
|
| 489 |
+
Data &operator=(Data const &other)
|
| 490 |
+
{
|
| 491 |
+
exif_data_unref(data_);
|
| 492 |
+
data_ = other.data_;
|
| 493 |
+
exif_data_ref(data_);
|
| 494 |
+
return *this;
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
void save(unsigned char **d, unsigned int *size)
|
| 498 |
+
{
|
| 499 |
+
exif_data_save_data(data_, d, size);
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
unsigned int size() const
|
| 503 |
+
{
|
| 504 |
+
return EXIF_IFD_COUNT;
|
| 505 |
+
}
|
| 506 |
+
|
| 507 |
+
Content operator[](unsigned int index)
|
| 508 |
+
{
|
| 509 |
+
if(index < size())
|
| 510 |
+
return Content(data_->ifd[index]);
|
| 511 |
+
#ifndef EXIF_NO_EXCEPTIONS
|
| 512 |
+
throw InvalidIndex(
|
| 513 |
+
"Exif::Data: IFD index out of range");
|
| 514 |
+
#endif // EXIF_NO_EXCEPTIONS
|
| 515 |
+
return Content();
|
| 516 |
+
}
|
| 517 |
+
|
| 518 |
+
ExifByteOrder byteOrder() const
|
| 519 |
+
{
|
| 520 |
+
return exif_data_get_byte_order(data_);
|
| 521 |
+
}
|
| 522 |
+
|
| 523 |
+
void setByteOrder(ExifByteOrder bo) const
|
| 524 |
+
{
|
| 525 |
+
exif_data_set_byte_order(data_, bo);
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
void dump()
|
| 529 |
+
{
|
| 530 |
+
exif_data_dump(data_);
|
| 531 |
+
}
|
| 532 |
+
};
|
| 533 |
+
|
| 534 |
+
} // namespace Exif
|
| 535 |
+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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* exif-content.c
|
| 2 |
+
*
|
| 3 |
+
* Copyright 2002,2003 Hans Meine <[email protected]>
|
| 4 |
+
*
|
| 5 |
+
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#include "exif.hxx"
|
| 22 |
+
#include <string>
|
| 23 |
+
#include <iostream>
|
| 24 |
+
|
| 25 |
+
#include <Python.h>
|
| 26 |
+
#include <boost/python.hpp>
|
| 27 |
+
using namespace boost::python;
|
| 28 |
+
|
| 29 |
+
template<class Wrapper, class Pointer>
|
| 30 |
+
struct WrappedObjectIterator
|
| 31 |
+
{
|
| 32 |
+
//typedef Wrapper value_type;
|
| 33 |
+
Pointer *it_, *end_;
|
| 34 |
+
|
| 35 |
+
WrappedObjectIterator(Pointer *it, Pointer *end)
|
| 36 |
+
: it_(it), end_(end)
|
| 37 |
+
{}
|
| 38 |
+
|
| 39 |
+
Wrapper next()
|
| 40 |
+
{
|
| 41 |
+
if(it_ == end_)
|
| 42 |
+
{
|
| 43 |
+
PyErr_SetString(PyExc_StopIteration, "iterator exhausted");
|
| 44 |
+
throw_error_already_set();
|
| 45 |
+
}
|
| 46 |
+
return Wrapper(*it_++);
|
| 47 |
+
}
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
struct PythonEntry : public Exif::Entry
|
| 51 |
+
{
|
| 52 |
+
PythonEntry() {}
|
| 53 |
+
PythonEntry(Exif::Entry const &other) : Exif::Entry(other) {}
|
| 54 |
+
|
| 55 |
+
object component(long index) const
|
| 56 |
+
{
|
| 57 |
+
switch(format())
|
| 58 |
+
{
|
| 59 |
+
case EXIF_FORMAT_BYTE:
|
| 60 |
+
return object(getByte(index));
|
| 61 |
+
case EXIF_FORMAT_SHORT:
|
| 62 |
+
return object(getShort(index));
|
| 63 |
+
case EXIF_FORMAT_LONG:
|
| 64 |
+
return object(getLong(index));
|
| 65 |
+
case EXIF_FORMAT_SLONG:
|
| 66 |
+
return object(getSLong(index));
|
| 67 |
+
case EXIF_FORMAT_RATIONAL:
|
| 68 |
+
return object(getRational(index));
|
| 69 |
+
case EXIF_FORMAT_SRATIONAL:
|
| 70 |
+
return object(getSRational(index));
|
| 71 |
+
case EXIF_FORMAT_ASCII:
|
| 72 |
+
//std::cerr << "returning " << entry_->size << " bytes of data..\n";
|
| 73 |
+
//std::cerr << " (copied into " << std::string((char *)data, entry_->size).size() << "-character string)\n";
|
| 74 |
+
return object(std::string((char *)entry_->data, entry_->size));
|
| 75 |
+
default:
|
| 76 |
+
break;
|
| 77 |
+
}
|
| 78 |
+
return object();
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
object data() const
|
| 82 |
+
{
|
| 83 |
+
if((format() == EXIF_FORMAT_ASCII) || (components()==1))
|
| 84 |
+
return component(0);
|
| 85 |
+
else
|
| 86 |
+
{
|
| 87 |
+
list result;
|
| 88 |
+
for(unsigned int i=0; i<components(); ++i)
|
| 89 |
+
result.append(component(i));
|
| 90 |
+
return result;
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
template<class Type>
|
| 95 |
+
Type extractComponent(unsigned int index, object value,
|
| 96 |
+
const char *errorString)
|
| 97 |
+
{
|
| 98 |
+
extract<Type> extr(value);
|
| 99 |
+
if(!extr.check())
|
| 100 |
+
{
|
| 101 |
+
PyErr_SetString(PyExc_TypeError, errorString);
|
| 102 |
+
throw_error_already_set();
|
| 103 |
+
}
|
| 104 |
+
return extr();
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
void setComponent(unsigned int index, object value)
|
| 108 |
+
{
|
| 109 |
+
unsigned char *data= entry_->data
|
| 110 |
+
+ index * exif_format_get_size(format());
|
| 111 |
+
ExifByteOrder bo = exif_data_get_byte_order(entry_->parent->parent);
|
| 112 |
+
|
| 113 |
+
switch(format())
|
| 114 |
+
{
|
| 115 |
+
case EXIF_FORMAT_BYTE:
|
| 116 |
+
*data= extractComponent<ExifByte>(index, value, "invalid assignment to data: could not convert value to byte format");
|
| 117 |
+
break;
|
| 118 |
+
case EXIF_FORMAT_SHORT:
|
| 119 |
+
exif_set_short(data, bo, extractComponent<ExifShort>(index, value, "invalid assignment to data: could not convert value to short format"));
|
| 120 |
+
break;
|
| 121 |
+
case EXIF_FORMAT_LONG:
|
| 122 |
+
exif_set_long(data, bo, extractComponent<ExifLong>(index, value, "invalid assignment to data: could not convert value to long format"));
|
| 123 |
+
break;
|
| 124 |
+
case EXIF_FORMAT_SLONG:
|
| 125 |
+
exif_set_slong(data, bo, extractComponent<ExifSLong>(index, value, "invalid assignment to data: could not convert value to signed long format"));
|
| 126 |
+
break;
|
| 127 |
+
case EXIF_FORMAT_RATIONAL:
|
| 128 |
+
exif_set_rational(data, bo, extractComponent<ExifRational>(index, value, "invalid assignment to data: could not convert value to rational format (2-tuple expected)"));
|
| 129 |
+
break;
|
| 130 |
+
case EXIF_FORMAT_SRATIONAL:
|
| 131 |
+
exif_set_srational(data, bo, extractComponent<ExifSRational>(index, value, "invalid assignment to data: could not convert value to signed rational format (2-tuple expected)"));
|
| 132 |
+
break;
|
| 133 |
+
case EXIF_FORMAT_ASCII: // handled in setData directly
|
| 134 |
+
case EXIF_FORMAT_UNDEFINED:
|
| 135 |
+
break;
|
| 136 |
+
}
|
| 137 |
+
return;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
void setData(object data)
|
| 141 |
+
{
|
| 142 |
+
if(format() == EXIF_FORMAT_ASCII)
|
| 143 |
+
{
|
| 144 |
+
extract<std::string> xstr(data);
|
| 145 |
+
if(xstr.check())
|
| 146 |
+
{
|
| 147 |
+
std::string s= xstr();
|
| 148 |
+
if(entry_->data)
|
| 149 |
+
free(entry_->data);
|
| 150 |
+
entry_->components= s.size();
|
| 151 |
+
//std::cerr << "assigning " << s.size() << "-character string..\n";
|
| 152 |
+
entry_->size=
|
| 153 |
+
exif_format_get_size(format()) * entry_->components;
|
| 154 |
+
entry_->data= (unsigned char *)malloc(entry_->size);
|
| 155 |
+
memcpy(entry_->data, s.data(), entry_->size);
|
| 156 |
+
entry_->data[entry_->size]= 0;
|
| 157 |
+
}
|
| 158 |
+
else
|
| 159 |
+
{
|
| 160 |
+
PyErr_SetString(PyExc_TypeError,
|
| 161 |
+
"invalid assignment to data of ASCII format entry: string expected");
|
| 162 |
+
throw_error_already_set();
|
| 163 |
+
}
|
| 164 |
+
}
|
| 165 |
+
else
|
| 166 |
+
{
|
| 167 |
+
if(components()==1)
|
| 168 |
+
setComponent(0, data);
|
| 169 |
+
else
|
| 170 |
+
{
|
| 171 |
+
extract<list> xlist(data);
|
| 172 |
+
if(xlist.check())
|
| 173 |
+
{
|
| 174 |
+
list l= xlist();
|
| 175 |
+
for(unsigned i=0; i<components(); ++i)
|
| 176 |
+
setComponent(i, l[i]);
|
| 177 |
+
}
|
| 178 |
+
else
|
| 179 |
+
{
|
| 180 |
+
PyErr_SetString(PyExc_TypeError,
|
| 181 |
+
"invalid assignment to data of entry with more than one component: list expected");
|
| 182 |
+
throw_error_already_set();
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
}
|
| 186 |
+
}
|
| 187 |
+
};
|
| 188 |
+
|
| 189 |
+
struct PythonContent : public Exif::Content
|
| 190 |
+
{
|
| 191 |
+
typedef WrappedObjectIterator<PythonEntry, ExifEntry *> iterator;
|
| 192 |
+
|
| 193 |
+
PythonContent() {}
|
| 194 |
+
PythonContent(Exif::Content const &other) : Exif::Content(other) {}
|
| 195 |
+
|
| 196 |
+
PythonEntry entry(object index)
|
| 197 |
+
{
|
| 198 |
+
// TODO: use Exif::Content::entry() functions
|
| 199 |
+
|
| 200 |
+
extract<ExifTag> xtag(index);
|
| 201 |
+
if(xtag.check())
|
| 202 |
+
{
|
| 203 |
+
ExifTag index= xtag();
|
| 204 |
+
for(unsigned int i=0; i<size(); i++)
|
| 205 |
+
{
|
| 206 |
+
if(content_->entries[i]->tag == index)
|
| 207 |
+
return Exif::Entry(content_->entries[i]);
|
| 208 |
+
}
|
| 209 |
+
PyErr_SetString(PyExc_KeyError,
|
| 210 |
+
"tag not present in IFD content");
|
| 211 |
+
throw_error_already_set();
|
| 212 |
+
}
|
| 213 |
+
extract<int> xint(index);
|
| 214 |
+
if(xint.check())
|
| 215 |
+
{
|
| 216 |
+
int index= xint();
|
| 217 |
+
if((index>=0) && (index<(long)size()))
|
| 218 |
+
return Exif::Entry(content_->entries[index]);
|
| 219 |
+
if((index<0) && (index>=-(long)size()))
|
| 220 |
+
return Exif::Entry(content_->entries[size()+index]);
|
| 221 |
+
PyErr_SetString(PyExc_IndexError,
|
| 222 |
+
"invalid integer index into IFD content");
|
| 223 |
+
throw_error_already_set();
|
| 224 |
+
}
|
| 225 |
+
PyErr_SetString(PyExc_TypeError,
|
| 226 |
+
"invalid index into EXIF data (integer or IFD expected)");
|
| 227 |
+
throw_error_already_set();
|
| 228 |
+
return Exif::Entry(); // never reached
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
iterator __iter__()
|
| 232 |
+
{
|
| 233 |
+
// FIXME: the public API is exif_content_foreach,
|
| 234 |
+
// relying on memory layout here!
|
| 235 |
+
return iterator(content_->entries,
|
| 236 |
+
content_->entries + content_->count);
|
| 237 |
+
}
|
| 238 |
+
};
|
| 239 |
+
|
| 240 |
+
struct PythonData : public Exif::Data
|
| 241 |
+
{
|
| 242 |
+
typedef WrappedObjectIterator<PythonContent, ExifContent *> iterator;
|
| 243 |
+
bool success_;
|
| 244 |
+
|
| 245 |
+
PythonData() {}
|
| 246 |
+
PythonData(const char *path)
|
| 247 |
+
: Exif::Data(path, &success_)
|
| 248 |
+
{
|
| 249 |
+
if(!success_)
|
| 250 |
+
{
|
| 251 |
+
PyErr_SetFromErrno(PyExc_IOError);
|
| 252 |
+
//PyErr_SetString(PyExc_IOError, "");
|
| 253 |
+
throw_error_already_set();
|
| 254 |
+
}
|
| 255 |
+
}
|
| 256 |
+
PythonData(const unsigned char *data,
|
| 257 |
+
unsigned int size) : Exif::Data(data, size) {}
|
| 258 |
+
PythonData(Exif::Data const &other) : Exif::Data(other) {}
|
| 259 |
+
|
| 260 |
+
PythonContent ifdContent(object index)
|
| 261 |
+
{
|
| 262 |
+
extract<ExifIfd> xifd(index);
|
| 263 |
+
if(xifd.check())
|
| 264 |
+
{
|
| 265 |
+
ExifIfd index= xifd();
|
| 266 |
+
if(index<EXIF_IFD_COUNT)
|
| 267 |
+
return Exif::Content(data_->ifd[index]);
|
| 268 |
+
PyErr_SetString(PyExc_IndexError,
|
| 269 |
+
"invalid IFD index into EXIF data");
|
| 270 |
+
throw_error_already_set();
|
| 271 |
+
}
|
| 272 |
+
extract<int> xint(index);
|
| 273 |
+
if(xint.check())
|
| 274 |
+
{
|
| 275 |
+
int index= xint();
|
| 276 |
+
if((index>=0) && (index<(long)size()))
|
| 277 |
+
return Exif::Content(data_->ifd[index]);
|
| 278 |
+
if((index<0) && (index>=-(long)size()))
|
| 279 |
+
return Exif::Content(data_->ifd[size()+index]);
|
| 280 |
+
PyErr_SetString(PyExc_IndexError,
|
| 281 |
+
"invalid integer index into EXIF data");
|
| 282 |
+
throw_error_already_set();
|
| 283 |
+
}
|
| 284 |
+
PyErr_SetString(PyExc_TypeError,
|
| 285 |
+
"invalid index into EXIF data (integer or IFD expected)");
|
| 286 |
+
throw_error_already_set();
|
| 287 |
+
return Exif::Content(); // never reached
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
iterator __iter__()
|
| 291 |
+
{
|
| 292 |
+
return iterator(data_->ifd, data_->ifd + EXIF_IFD_COUNT);
|
| 293 |
+
}
|
| 294 |
+
};
|
| 295 |
+
|
| 296 |
+
template<class Rational, class Component>
|
| 297 |
+
struct RationalConverter
|
| 298 |
+
{
|
| 299 |
+
RationalConverter()
|
| 300 |
+
{
|
| 301 |
+
converter::registry::insert(&convertible, &construct,
|
| 302 |
+
type_id<Rational>());
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
static void* convertible(PyObject* obj)
|
| 306 |
+
{
|
| 307 |
+
extract<tuple> xtup(obj);
|
| 308 |
+
if(xtup.check())
|
| 309 |
+
{
|
| 310 |
+
tuple t= xtup();
|
| 311 |
+
if((t.attr("__len__")() == 2) &&
|
| 312 |
+
extract<Component>(t[0]).check() &&
|
| 313 |
+
extract<Component>(t[1]).check())
|
| 314 |
+
{
|
| 315 |
+
Rational *result = new Rational;
|
| 316 |
+
result->numerator = extract<Component>(t[0])();
|
| 317 |
+
result->denominator = extract<Component>(t[1])();
|
| 318 |
+
return result;
|
| 319 |
+
}
|
| 320 |
+
}
|
| 321 |
+
return NULL;
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
static void construct(PyObject* obj, converter::rvalue_from_python_stage1_data* data)
|
| 325 |
+
{
|
| 326 |
+
Rational const* r =
|
| 327 |
+
static_cast<Rational*>(data->convertible);
|
| 328 |
+
void* storage =
|
| 329 |
+
((converter::rvalue_from_python_storage<Rational>*)data)->storage.bytes;
|
| 330 |
+
new (storage) Rational();
|
| 331 |
+
((Rational*)storage)->numerator = r->numerator;
|
| 332 |
+
((Rational*)storage)->denominator = r->denominator;
|
| 333 |
+
data->convertible = storage;
|
| 334 |
+
delete r;
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
static PyObject *convert(Rational r)
|
| 338 |
+
{
|
| 339 |
+
tuple t= make_tuple(r.numerator, r.denominator);
|
| 340 |
+
PyObject *result= t.ptr();
|
| 341 |
+
Py_INCREF(result);
|
| 342 |
+
return result;
|
| 343 |
+
}
|
| 344 |
+
};
|
| 345 |
+
|
| 346 |
+
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(entrydumps, Exif::Entry::dump, 0, 1)
|
| 347 |
+
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(contentdumps, Exif::Content::dump, 0, 1)
|
| 348 |
+
|
| 349 |
+
BOOST_PYTHON_MODULE(exif)
|
| 350 |
+
{
|
| 351 |
+
RationalConverter<ExifRational, ExifLong>();
|
| 352 |
+
RationalConverter<ExifSRational, ExifSLong>();
|
| 353 |
+
to_python_converter<ExifRational,
|
| 354 |
+
RationalConverter<ExifRational, ExifLong> >();
|
| 355 |
+
to_python_converter<ExifSRational,
|
| 356 |
+
RationalConverter<ExifSRational, ExifSLong> >();
|
| 357 |
+
|
| 358 |
+
enum_<ExifByteOrder>("ByteOrder")
|
| 359 |
+
.value("MOTOROLA", EXIF_BYTE_ORDER_MOTOROLA)
|
| 360 |
+
.value("INTEL", EXIF_BYTE_ORDER_INTEL);
|
| 361 |
+
|
| 362 |
+
def("name", &exif_byte_order_get_name);
|
| 363 |
+
|
| 364 |
+
enum_<ExifIfd>("IFD")
|
| 365 |
+
.value("ZERO", EXIF_IFD_0)
|
| 366 |
+
.value("ONE", EXIF_IFD_1)
|
| 367 |
+
.value("EXIF", EXIF_IFD_EXIF)
|
| 368 |
+
.value("GPS", EXIF_IFD_GPS)
|
| 369 |
+
.value("INTEROPERABILITY", EXIF_IFD_INTEROPERABILITY);
|
| 370 |
+
//.value("COUNT", EXIF_IFD_COUNT)
|
| 371 |
+
|
| 372 |
+
def("name", &exif_ifd_get_name);
|
| 373 |
+
|
| 374 |
+
enum_<ExifFormat>("Format")
|
| 375 |
+
.value("BYTE", EXIF_FORMAT_BYTE)
|
| 376 |
+
.value("ASCII", EXIF_FORMAT_ASCII)
|
| 377 |
+
.value("SHORT", EXIF_FORMAT_SHORT)
|
| 378 |
+
.value("LONG", EXIF_FORMAT_LONG)
|
| 379 |
+
.value("RATIONAL", EXIF_FORMAT_RATIONAL)
|
| 380 |
+
.value("UNDEFINED", EXIF_FORMAT_UNDEFINED)
|
| 381 |
+
.value("SLONG", EXIF_FORMAT_SLONG)
|
| 382 |
+
.value("SRATIONAL", EXIF_FORMAT_SRATIONAL);
|
| 383 |
+
|
| 384 |
+
def("name", &exif_format_get_name);
|
| 385 |
+
def("size", &exif_format_get_size);
|
| 386 |
+
|
| 387 |
+
enum_<ExifTag>("Tag")
|
| 388 |
+
.value("INTEROPERABILITY_INDEX", EXIF_TAG_INTEROPERABILITY_INDEX)
|
| 389 |
+
.value("INTEROPERABILITY_VERSION", EXIF_TAG_INTEROPERABILITY_VERSION)
|
| 390 |
+
.value("IMAGE_WIDTH", EXIF_TAG_IMAGE_WIDTH)
|
| 391 |
+
.value("IMAGE_LENGTH", EXIF_TAG_IMAGE_LENGTH)
|
| 392 |
+
.value("BITS_PER_SAMPLE", EXIF_TAG_BITS_PER_SAMPLE)
|
| 393 |
+
.value("COMPRESSION", EXIF_TAG_COMPRESSION)
|
| 394 |
+
.value("PHOTOMETRIC_INTERPRETATION", EXIF_TAG_PHOTOMETRIC_INTERPRETATION)
|
| 395 |
+
.value("FILL_ORDER", EXIF_TAG_FILL_ORDER)
|
| 396 |
+
.value("DOCUMENT_NAME", EXIF_TAG_DOCUMENT_NAME)
|
| 397 |
+
.value("IMAGE_DESCRIPTION", EXIF_TAG_IMAGE_DESCRIPTION)
|
| 398 |
+
.value("MAKE", EXIF_TAG_MAKE)
|
| 399 |
+
.value("MODEL", EXIF_TAG_MODEL)
|
| 400 |
+
.value("STRIP_OFFSETS", EXIF_TAG_STRIP_OFFSETS)
|
| 401 |
+
.value("ORIENTATION", EXIF_TAG_ORIENTATION)
|
| 402 |
+
.value("SAMPLES_PER_PIXEL", EXIF_TAG_SAMPLES_PER_PIXEL)
|
| 403 |
+
.value("ROWS_PER_STRIP", EXIF_TAG_ROWS_PER_STRIP)
|
| 404 |
+
.value("STRIP_BYTE_COUNTS", EXIF_TAG_STRIP_BYTE_COUNTS)
|
| 405 |
+
.value("X_RESOLUTION", EXIF_TAG_X_RESOLUTION)
|
| 406 |
+
.value("Y_RESOLUTION", EXIF_TAG_Y_RESOLUTION)
|
| 407 |
+
.value("PLANAR_CONFIGURATION", EXIF_TAG_PLANAR_CONFIGURATION)
|
| 408 |
+
.value("RESOLUTION_UNIT", EXIF_TAG_RESOLUTION_UNIT)
|
| 409 |
+
.value("TRANSFER_FUNCTION", EXIF_TAG_TRANSFER_FUNCTION)
|
| 410 |
+
.value("SOFTWARE", EXIF_TAG_SOFTWARE)
|
| 411 |
+
.value("DATE_TIME", EXIF_TAG_DATE_TIME)
|
| 412 |
+
.value("ARTIST", EXIF_TAG_ARTIST)
|
| 413 |
+
.value("WHITE_POINT", EXIF_TAG_WHITE_POINT)
|
| 414 |
+
.value("PRIMARY_CHROMATICITIES", EXIF_TAG_PRIMARY_CHROMATICITIES)
|
| 415 |
+
.value("TRANSFER_RANGE", EXIF_TAG_TRANSFER_RANGE)
|
| 416 |
+
.value("JPEG_PROC", EXIF_TAG_JPEG_PROC)
|
| 417 |
+
.value("JPEG_INTERCHANGE_FORMAT", EXIF_TAG_JPEG_INTERCHANGE_FORMAT)
|
| 418 |
+
.value("JPEG_INTERCHANGE_FORMAT_LENGTH", EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH)
|
| 419 |
+
.value("YCBCR_COEFFICIENTS", EXIF_TAG_YCBCR_COEFFICIENTS)
|
| 420 |
+
.value("YCBCR_SUB_SAMPLING", EXIF_TAG_YCBCR_SUB_SAMPLING)
|
| 421 |
+
.value("YCBCR_POSITIONING", EXIF_TAG_YCBCR_POSITIONING)
|
| 422 |
+
.value("REFERENCE_BLACK_WHITE", EXIF_TAG_REFERENCE_BLACK_WHITE)
|
| 423 |
+
.value("RELATED_IMAGE_FILE_FORMAT", EXIF_TAG_RELATED_IMAGE_FILE_FORMAT)
|
| 424 |
+
.value("RELATED_IMAGE_WIDTH", EXIF_TAG_RELATED_IMAGE_WIDTH)
|
| 425 |
+
.value("RELATED_IMAGE_LENGTH", EXIF_TAG_RELATED_IMAGE_LENGTH)
|
| 426 |
+
.value("CFA_REPEAT_PATTERN_DIM", EXIF_TAG_CFA_REPEAT_PATTERN_DIM)
|
| 427 |
+
.value("CFA_PATTERN", EXIF_TAG_CFA_PATTERN)
|
| 428 |
+
.value("BATTERY_LEVEL", EXIF_TAG_BATTERY_LEVEL)
|
| 429 |
+
.value("COPYRIGHT", EXIF_TAG_COPYRIGHT)
|
| 430 |
+
.value("EXPOSURE_TIME", EXIF_TAG_EXPOSURE_TIME)
|
| 431 |
+
.value("FNUMBER", EXIF_TAG_FNUMBER)
|
| 432 |
+
.value("IPTC_NAA", EXIF_TAG_IPTC_NAA)
|
| 433 |
+
.value("EXIF_IFD_POINTER", EXIF_TAG_EXIF_IFD_POINTER)
|
| 434 |
+
.value("INTER_COLOR_PROFILE", EXIF_TAG_INTER_COLOR_PROFILE)
|
| 435 |
+
.value("EXPOSURE_PROGRAM", EXIF_TAG_EXPOSURE_PROGRAM)
|
| 436 |
+
.value("SPECTRAL_SENSITIVITY", EXIF_TAG_SPECTRAL_SENSITIVITY)
|
| 437 |
+
.value("GPS_INFO_IFD_POINTER", EXIF_TAG_GPS_INFO_IFD_POINTER)
|
| 438 |
+
.value("ISO_SPEED_RATINGS", EXIF_TAG_ISO_SPEED_RATINGS)
|
| 439 |
+
.value("OECF", EXIF_TAG_OECF)
|
| 440 |
+
.value("EXIF_VERSION", EXIF_TAG_EXIF_VERSION)
|
| 441 |
+
.value("DATE_TIME_ORIGINAL", EXIF_TAG_DATE_TIME_ORIGINAL)
|
| 442 |
+
.value("DATE_TIME_DIGITIZED", EXIF_TAG_DATE_TIME_DIGITIZED)
|
| 443 |
+
.value("COMPONENTS_CONFIGURATION", EXIF_TAG_COMPONENTS_CONFIGURATION)
|
| 444 |
+
.value("COMPRESSED_BITS_PER_PIXEL", EXIF_TAG_COMPRESSED_BITS_PER_PIXEL)
|
| 445 |
+
.value("SHUTTER_SPEED_VALUE", EXIF_TAG_SHUTTER_SPEED_VALUE)
|
| 446 |
+
.value("APERTURE_VALUE", EXIF_TAG_APERTURE_VALUE)
|
| 447 |
+
.value("BRIGHTNESS_VALUE", EXIF_TAG_BRIGHTNESS_VALUE)
|
| 448 |
+
.value("EXPOSURE_BIAS_VALUE", EXIF_TAG_EXPOSURE_BIAS_VALUE)
|
| 449 |
+
.value("MAX_APERTURE_VALUE", EXIF_TAG_MAX_APERTURE_VALUE)
|
| 450 |
+
.value("SUBJECT_DISTANCE", EXIF_TAG_SUBJECT_DISTANCE)
|
| 451 |
+
.value("METERING_MODE", EXIF_TAG_METERING_MODE)
|
| 452 |
+
.value("LIGHT_SOURCE", EXIF_TAG_LIGHT_SOURCE)
|
| 453 |
+
.value("FLASH", EXIF_TAG_FLASH)
|
| 454 |
+
.value("FOCAL_LENGTH", EXIF_TAG_FOCAL_LENGTH)
|
| 455 |
+
.value("SUBJECT_AREA", EXIF_TAG_SUBJECT_AREA)
|
| 456 |
+
.value("MAKER_NOTE", EXIF_TAG_MAKER_NOTE)
|
| 457 |
+
.value("USER_COMMENT", EXIF_TAG_USER_COMMENT)
|
| 458 |
+
.value("SUBSEC_TIME", EXIF_TAG_SUBSEC_TIME)
|
| 459 |
+
.value("SUB_SEC_TIME_ORIGINAL", EXIF_TAG_SUB_SEC_TIME_ORIGINAL)
|
| 460 |
+
.value("SUB_SEC_TIME_DIGITIZED", EXIF_TAG_SUB_SEC_TIME_DIGITIZED)
|
| 461 |
+
.value("FLASH_PIX_VERSION", EXIF_TAG_FLASH_PIX_VERSION)
|
| 462 |
+
.value("COLOR_SPACE", EXIF_TAG_COLOR_SPACE)
|
| 463 |
+
.value("PIXEL_X_DIMENSION", EXIF_TAG_PIXEL_X_DIMENSION)
|
| 464 |
+
.value("PIXEL_Y_DIMENSION", EXIF_TAG_PIXEL_Y_DIMENSION)
|
| 465 |
+
.value("RELATED_SOUND_FILE", EXIF_TAG_RELATED_SOUND_FILE)
|
| 466 |
+
.value("INTEROPERABILITY_IFD_POINTER", EXIF_TAG_INTEROPERABILITY_IFD_POINTER)
|
| 467 |
+
.value("FLASH_ENERGY", EXIF_TAG_FLASH_ENERGY)
|
| 468 |
+
.value("SPATIAL_FREQUENCY_RESPONSE", EXIF_TAG_SPATIAL_FREQUENCY_RESPONSE)
|
| 469 |
+
.value("FOCAL_PLANE_X_RESOLUTION", EXIF_TAG_FOCAL_PLANE_X_RESOLUTION)
|
| 470 |
+
.value("FOCAL_PLANE_Y_RESOLUTION", EXIF_TAG_FOCAL_PLANE_Y_RESOLUTION)
|
| 471 |
+
.value("FOCAL_PLANE_RESOLUTION_UNIT", EXIF_TAG_FOCAL_PLANE_RESOLUTION_UNIT)
|
| 472 |
+
.value("SUBJECT_LOCATION", EXIF_TAG_SUBJECT_LOCATION)
|
| 473 |
+
.value("EXPOSURE_INDEX", EXIF_TAG_EXPOSURE_INDEX)
|
| 474 |
+
.value("SENSING_METHOD", EXIF_TAG_SENSING_METHOD)
|
| 475 |
+
.value("FILE_SOURCE", EXIF_TAG_FILE_SOURCE)
|
| 476 |
+
.value("SCENE_TYPE", EXIF_TAG_SCENE_TYPE)
|
| 477 |
+
.value("NEW_CFA_PATTERN", EXIF_TAG_NEW_CFA_PATTERN)
|
| 478 |
+
.value("CUSTOM_RENDERED", EXIF_TAG_CUSTOM_RENDERED)
|
| 479 |
+
.value("EXPOSURE_MODE", EXIF_TAG_EXPOSURE_MODE)
|
| 480 |
+
.value("WHITE_BALANCE", EXIF_TAG_WHITE_BALANCE)
|
| 481 |
+
.value("DIGITAL_ZOOM_RATIO", EXIF_TAG_DIGITAL_ZOOM_RATIO)
|
| 482 |
+
.value("FOCAL_LENGTH_IN_35MM_FILM", EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM)
|
| 483 |
+
.value("SCENE_CAPTURE_TYPE", EXIF_TAG_SCENE_CAPTURE_TYPE)
|
| 484 |
+
.value("GAIN_CONTROL", EXIF_TAG_GAIN_CONTROL)
|
| 485 |
+
.value("CONTRAST", EXIF_TAG_CONTRAST)
|
| 486 |
+
.value("SATURATION", EXIF_TAG_SATURATION)
|
| 487 |
+
.value("SHARPNESS", EXIF_TAG_SHARPNESS)
|
| 488 |
+
.value("DEVICE_SETTING_DESCRIPTION", EXIF_TAG_DEVICE_SETTING_DESCRIPTION)
|
| 489 |
+
.value("SUBJECT_DISTANCE_RANGE", EXIF_TAG_SUBJECT_DISTANCE_RANGE)
|
| 490 |
+
.value("IMAGE_UNIQUE_ID", EXIF_TAG_IMAGE_UNIQUE_ID);
|
| 491 |
+
|
| 492 |
+
def("name", &exif_tag_get_name);
|
| 493 |
+
def("title", &exif_tag_get_title);
|
| 494 |
+
def("description", &exif_tag_get_description);
|
| 495 |
+
|
| 496 |
+
class_<PythonEntry>("Entry")
|
| 497 |
+
.add_property("tag", &Exif::Entry::tag)
|
| 498 |
+
.add_property("format", &Exif::Entry::format)
|
| 499 |
+
.add_property("components", &Exif::Entry::components)
|
| 500 |
+
.add_property("data", &PythonEntry::data,
|
| 501 |
+
&PythonEntry::setData)
|
| 502 |
+
.def("value", &Exif::Entry::value)
|
| 503 |
+
.def("briefValue", &Exif::Entry::briefValue)
|
| 504 |
+
.def("dump", &Exif::Entry::dump);//, entrydumps());
|
| 505 |
+
|
| 506 |
+
class_<PythonContent::iterator>("ContentIterator", no_init)
|
| 507 |
+
.def("next", &PythonContent::iterator::next);
|
| 508 |
+
class_<PythonContent>("Content")
|
| 509 |
+
.def("__len__", &Exif::Content::size)
|
| 510 |
+
.def("__getitem__", &PythonContent::entry)
|
| 511 |
+
.def("__iter__", &PythonContent::__iter__)
|
| 512 |
+
.def("dump", &Exif::Content::dump);//, contentdumps());
|
| 513 |
+
|
| 514 |
+
class_<PythonData::iterator>("DataIterator", no_init)
|
| 515 |
+
.def("next", &PythonData::iterator::next);
|
| 516 |
+
class_<PythonData>("Data")
|
| 517 |
+
.def(init<const char *>())
|
| 518 |
+
.def(init<const unsigned char *, unsigned int>())
|
| 519 |
+
.def("__len__", &Exif::Data::size)
|
| 520 |
+
.def("__getitem__", &PythonData::ifdContent)
|
| 521 |
+
.def("__iter__", &PythonData::__iter__)
|
| 522 |
+
.def("byteOrder", &Exif::Data::byteOrder)
|
| 523 |
+
.def("dump", &Exif::Data::dump);
|
| 524 |
+
}
|
local-test-libexif-delta-01-exif-003/afc-libexif/contrib/examples/.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Makefile
|
| 2 |
+
Makefile.in
|
local-test-libexif-delta-01-exif-003/afc-libexif/contrib/examples/Makefile.am
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Simple example programs
|
| 2 |
+
check_PROGRAMS = photographer thumbnail write-exif
|
| 3 |
+
|
| 4 |
+
# Example programs with dependencies other than plain libexif
|
| 5 |
+
COMPLICATED_EXAMPLES = cam_features.c
|
| 6 |
+
|
| 7 |
+
# Build just the simple examples as a sanity check, but include them all in
|
| 8 |
+
# the source archive
|
| 9 |
+
|
| 10 |
+
EXTRA_DIST = $(COMPLICATED_EXAMPLES)
|
| 11 |
+
LDADD = $(top_builddir)/libexif/libexif.la
|
local-test-libexif-delta-01-exif-003/afc-libexif/contrib/examples/cam_features.c
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
| 1 |
+
/***************************************************************************
|
| 2 |
+
* cam_features.c
|
| 3 |
+
*
|
| 4 |
+
* Wed Jul 27 11:25:09 2005
|
| 5 |
+
* Copyright 2005 User: Naysawn Naderi
|
| 6 |
+
* Email: ndn at xiphos dot ca
|
| 7 |
+
*
|
| 8 |
+
* Uses libdc1394 and libraw1394
|
| 9 |
+
****************************************************************************/
|
| 10 |
+
|
| 11 |
+
#include <stdio.h>
|
| 12 |
+
#include <stdlib.h>
|
| 13 |
+
#include <time.h>
|
| 14 |
+
#include <sys/times.h>
|
| 15 |
+
#include <errno.h>
|
| 16 |
+
|
| 17 |
+
#include <libraw1394/raw1394.h>
|
| 18 |
+
#include <libdc1394/dc1394_control.h>
|
| 19 |
+
#include <libdc1394/dc1394_register.h>
|
| 20 |
+
|
| 21 |
+
//EXIF includes
|
| 22 |
+
#include <libexif/exif-data.h>
|
| 23 |
+
#include <libexif/exif-ifd.h>
|
| 24 |
+
#include <libexif/exif-loader.h>
|
| 25 |
+
|
| 26 |
+
// Part of the exif command-line source package
|
| 27 |
+
#include "libjpeg/jpeg-data.h"
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
#define FILENAME "test.jpg"
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
static int createEXIF(dc1394featureset_t *xFeatures, ExifData ** pParentEd);
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
int main(int argc, char *argv[])
|
| 37 |
+
{ dc1394camera_t *pCamera, **pCameras=NULL;
|
| 38 |
+
int iNumCameras;
|
| 39 |
+
dc1394featureset_t xFeatures;
|
| 40 |
+
int i;
|
| 41 |
+
int err=dc1394_find_cameras(&pCameras, &iNumCameras);
|
| 42 |
+
|
| 43 |
+
//EXIF STUFF
|
| 44 |
+
JPEGData *pData;
|
| 45 |
+
//float fOnefloat;
|
| 46 |
+
ExifData * pEd;
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
if (err!=DC1394_SUCCESS) {
|
| 50 |
+
fprintf( stderr, "Unable to look for cameras\n\n"
|
| 51 |
+
"Please check \n"
|
| 52 |
+
" - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n"
|
| 53 |
+
" - if you have read/write access to /dev/raw1394\n\n");
|
| 54 |
+
exit(1);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
/*-----------------------------------------------------------------------
|
| 59 |
+
* Initialize the camera
|
| 60 |
+
*-----------------------------------------------------------------------*/
|
| 61 |
+
if (iNumCameras<1) {
|
| 62 |
+
fprintf(stderr, "no cameras found :(\n");
|
| 63 |
+
exit(1);
|
| 64 |
+
}
|
| 65 |
+
pCamera=pCameras[0];
|
| 66 |
+
for (i=1;i<iNumCameras;i++)
|
| 67 |
+
dc1394_free_camera(pCameras[i]);
|
| 68 |
+
free(pCameras);
|
| 69 |
+
|
| 70 |
+
if(dc1394_get_camera_feature_set(pCamera, &xFeatures)!=DC1394_SUCCESS)
|
| 71 |
+
fprintf(stdout, "unable to get feature set\n");
|
| 72 |
+
else
|
| 73 |
+
printf("camera's feature set retrieved\n");
|
| 74 |
+
|
| 75 |
+
createEXIF(&xFeatures, &pEd); //tag the file with the settings of the camera
|
| 76 |
+
|
| 77 |
+
//exif_data_dump (pEd);
|
| 78 |
+
|
| 79 |
+
//write the Exif data to a jpeg file
|
| 80 |
+
pData = jpeg_data_new_from_file (FILENAME); //input data
|
| 81 |
+
if (!pData) {
|
| 82 |
+
printf ("Could not load '%s'!\n", FILENAME);
|
| 83 |
+
return (-1);
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
printf("Saving EXIF data to jpeg file\n");
|
| 87 |
+
jpeg_data_set_exif_data (pData, pEd);
|
| 88 |
+
printf("Set the data\n");
|
| 89 |
+
jpeg_data_save_file(pData, "foobar2.jpg");
|
| 90 |
+
|
| 91 |
+
return 0;
|
| 92 |
+
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
int createEXIF(dc1394featureset_t *xFeatures, ExifData ** pParentEd)
|
| 97 |
+
{
|
| 98 |
+
ExifEntry *pE;
|
| 99 |
+
ExifData * pEd;
|
| 100 |
+
int i = !xFeatures->feature[DC1394_FEATURE_WHITE_BALANCE - DC1394_FEATURE_MIN].auto_active;
|
| 101 |
+
|
| 102 |
+
ExifSRational xR = {xFeatures->feature[DC1394_FEATURE_BRIGHTNESS - DC1394_FEATURE_MIN].value, xFeatures->feature[DC1394_FEATURE_BRIGHTNESS - DC1394_FEATURE_MIN].max};;
|
| 103 |
+
|
| 104 |
+
printf ("Creating EXIF data...\n");
|
| 105 |
+
pEd = exif_data_new ();
|
| 106 |
+
|
| 107 |
+
/*
|
| 108 |
+
|
| 109 |
+
Things to tag:
|
| 110 |
+
|
| 111 |
+
EXIF_TAG_MAKE = 0x010f,
|
| 112 |
+
EXIF_TAG_MODEL = 0x0110,
|
| 113 |
+
EXIF_TAG_EXPOSURE_TIME = 0x829a,
|
| 114 |
+
EXIF_TAG_BRIGHTNESS_VALUE = 0x9203,
|
| 115 |
+
EXIF_TAG_WHITE_BALANCE = 0xa403,
|
| 116 |
+
EXIF_TAG_GAIN_CONTROL = 0xa407,
|
| 117 |
+
EXIF_TAG_CONTRAST = 0xa408,
|
| 118 |
+
EXIF_TAG_SATURATION = 0xa409,
|
| 119 |
+
EXIF_TAG_SHARPNESS = 0xa40a,
|
| 120 |
+
EXIF_TAG_USER_COMMENT
|
| 121 |
+
*/
|
| 122 |
+
|
| 123 |
+
printf ("Adding a Make reference\n");
|
| 124 |
+
pE = exif_entry_new ();
|
| 125 |
+
exif_content_add_entry (pEd->ifd[EXIF_IFD_0], pE);
|
| 126 |
+
exif_entry_initialize (pE, EXIF_TAG_MAKE);
|
| 127 |
+
pE->data="AVT";
|
| 128 |
+
exif_entry_unref (pE);
|
| 129 |
+
|
| 130 |
+
printf ("Adding a Model reference\n");
|
| 131 |
+
pE = exif_entry_new ();
|
| 132 |
+
exif_content_add_entry (pEd->ifd[EXIF_IFD_0], pE);
|
| 133 |
+
exif_entry_initialize (pE, EXIF_TAG_MODEL);
|
| 134 |
+
pE->data="510c";
|
| 135 |
+
exif_entry_unref (pE);
|
| 136 |
+
|
| 137 |
+
printf ("Adding a Tag to reference # samples per pixel\n");
|
| 138 |
+
pE = exif_entry_new ();
|
| 139 |
+
exif_content_add_entry (pEd->ifd[EXIF_IFD_0], pE);
|
| 140 |
+
exif_entry_initialize (pE, EXIF_TAG_SAMPLES_PER_PIXEL); //by default is 3
|
| 141 |
+
exif_entry_unref (pE);
|
| 142 |
+
|
| 143 |
+
printf ("Adding a White Balance Reference\n");
|
| 144 |
+
pE = exif_entry_new ();
|
| 145 |
+
exif_content_add_entry (pEd->ifd[EXIF_IFD_0], pE);
|
| 146 |
+
exif_entry_initialize (pE, EXIF_TAG_WHITE_BALANCE);
|
| 147 |
+
exif_set_short(pE->data, exif_data_get_byte_order (pEd), i); //0=auto white balance, 1 = manual white balance
|
| 148 |
+
exif_entry_unref (pE);
|
| 149 |
+
|
| 150 |
+
//need to create logic according to the value of the sharpness
|
| 151 |
+
printf ("Adding a Sharpness Reference\n");
|
| 152 |
+
pE = exif_entry_new ();
|
| 153 |
+
exif_content_add_entry (pEd->ifd[EXIF_IFD_0], pE);
|
| 154 |
+
exif_entry_initialize (pE, EXIF_TAG_SHARPNESS);
|
| 155 |
+
exif_set_short(pE->data, exif_data_get_byte_order (pEd), 0);
|
| 156 |
+
exif_entry_unref (pE);
|
| 157 |
+
|
| 158 |
+
printf ("Adding a Brightness reference\n");
|
| 159 |
+
|
| 160 |
+
//try to get brightness
|
| 161 |
+
//printf("Float Value: %i\n",xFeatures->feature[DC1394_FEATURE_BRIGHTNESS - DC1394_FEATURE_MIN].value);
|
| 162 |
+
|
| 163 |
+
pE = exif_entry_new ();
|
| 164 |
+
exif_content_add_entry (pEd->ifd[EXIF_IFD_0], pE);
|
| 165 |
+
exif_entry_initialize (pE, EXIF_TAG_BRIGHTNESS_VALUE);
|
| 166 |
+
exif_set_srational (pE->data, exif_data_get_byte_order (pEd), xR);
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
//exif_data_dump (ed);
|
| 170 |
+
//exif_data_dump (pEd);
|
| 171 |
+
*pParentEd = pEd;
|
| 172 |
+
printf("Done!\n");
|
| 173 |
+
|
| 174 |
+
return 0;
|
| 175 |
+
}
|
local-test-libexif-delta-01-exif-003/afc-libexif/contrib/examples/photographer.c
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* libexif example program to display the contents of a number of specific
|
| 3 |
+
* EXIF and MakerNote tags. The tags selected are those that may aid in
|
| 4 |
+
* identification of the photographer who took the image.
|
| 5 |
+
*
|
| 6 |
+
* Placed into the public domain by Dan Fandrich
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
#include <stdio.h>
|
| 10 |
+
#include <string.h>
|
| 11 |
+
#include <libexif/exif-data.h>
|
| 12 |
+
|
| 13 |
+
/* Remove spaces on the right of the string */
|
| 14 |
+
static void trim_spaces(char *buf)
|
| 15 |
+
{
|
| 16 |
+
char *s = buf-1;
|
| 17 |
+
for (; *buf; ++buf) {
|
| 18 |
+
if (*buf != ' ')
|
| 19 |
+
s = buf;
|
| 20 |
+
}
|
| 21 |
+
*++s = 0; /* nul terminate the string on the first of the final spaces */
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
/* Show the tag name and contents if the tag exists */
|
| 25 |
+
static void show_tag(ExifData *d, ExifIfd ifd, ExifTag tag)
|
| 26 |
+
{
|
| 27 |
+
/* See if this tag exists */
|
| 28 |
+
ExifEntry *entry = exif_content_get_entry(d->ifd[ifd],tag);
|
| 29 |
+
if (entry) {
|
| 30 |
+
char buf[1024];
|
| 31 |
+
|
| 32 |
+
/* Get the contents of the tag in human-readable form */
|
| 33 |
+
exif_entry_get_value(entry, buf, sizeof(buf));
|
| 34 |
+
|
| 35 |
+
/* Don't bother printing it if it's entirely blank */
|
| 36 |
+
trim_spaces(buf);
|
| 37 |
+
if (*buf) {
|
| 38 |
+
printf("%s: %s\n", exif_tag_get_name_in_ifd(tag,ifd), buf);
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
/* Show the given MakerNote tag if it exists */
|
| 44 |
+
static void show_mnote_tag(ExifData *d, unsigned tag)
|
| 45 |
+
{
|
| 46 |
+
ExifMnoteData *mn = exif_data_get_mnote_data(d);
|
| 47 |
+
if (mn) {
|
| 48 |
+
int num = exif_mnote_data_count(mn);
|
| 49 |
+
int i;
|
| 50 |
+
|
| 51 |
+
/* Loop through all MakerNote tags, searching for the desired one */
|
| 52 |
+
for (i=0; i < num; ++i) {
|
| 53 |
+
char buf[1024];
|
| 54 |
+
if (exif_mnote_data_get_id(mn, i) == tag) {
|
| 55 |
+
if (exif_mnote_data_get_value(mn, i, buf, sizeof(buf))) {
|
| 56 |
+
/* Don't bother printing it if it's entirely blank */
|
| 57 |
+
trim_spaces(buf);
|
| 58 |
+
if (*buf) {
|
| 59 |
+
printf("%s: %s\n", exif_mnote_data_get_title(mn, i),
|
| 60 |
+
buf);
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
int main(int argc, char **argv)
|
| 69 |
+
{
|
| 70 |
+
ExifData *ed;
|
| 71 |
+
ExifEntry *entry;
|
| 72 |
+
|
| 73 |
+
if (argc < 2) {
|
| 74 |
+
printf("Usage: %s image.jpg\n", argv[0]);
|
| 75 |
+
printf("Displays tags potentially relating to ownership "
|
| 76 |
+
"of the image.\n");
|
| 77 |
+
return 1;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
/* Load an ExifData object from an EXIF file */
|
| 81 |
+
ed = exif_data_new_from_file(argv[1]);
|
| 82 |
+
if (!ed) {
|
| 83 |
+
printf("File not readable or no EXIF data in file %s\n", argv[1]);
|
| 84 |
+
return 2;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/* Show all the tags that might contain information about the
|
| 88 |
+
* photographer
|
| 89 |
+
*/
|
| 90 |
+
show_tag(ed, EXIF_IFD_0, EXIF_TAG_ARTIST);
|
| 91 |
+
show_tag(ed, EXIF_IFD_0, EXIF_TAG_XP_AUTHOR);
|
| 92 |
+
show_tag(ed, EXIF_IFD_0, EXIF_TAG_COPYRIGHT);
|
| 93 |
+
|
| 94 |
+
/* These are much less likely to be useful */
|
| 95 |
+
show_tag(ed, EXIF_IFD_EXIF, EXIF_TAG_USER_COMMENT);
|
| 96 |
+
show_tag(ed, EXIF_IFD_0, EXIF_TAG_IMAGE_DESCRIPTION);
|
| 97 |
+
show_tag(ed, EXIF_IFD_1, EXIF_TAG_IMAGE_DESCRIPTION);
|
| 98 |
+
|
| 99 |
+
/* A couple of MakerNote tags can contain useful data. Read the
|
| 100 |
+
* manufacturer tag to see if this image could have one of the recognized
|
| 101 |
+
* MakerNote tags.
|
| 102 |
+
*/
|
| 103 |
+
entry = exif_content_get_entry(ed->ifd[EXIF_IFD_0], EXIF_TAG_MAKE);
|
| 104 |
+
if (entry) {
|
| 105 |
+
char buf[64];
|
| 106 |
+
|
| 107 |
+
/* Get the contents of the manufacturer tag as a string */
|
| 108 |
+
if (exif_entry_get_value(entry, buf, sizeof(buf))) {
|
| 109 |
+
trim_spaces(buf);
|
| 110 |
+
|
| 111 |
+
if (!strcmp(buf, "Canon")) {
|
| 112 |
+
show_mnote_tag(ed, 9); /* MNOTE_CANON_TAG_OWNER */
|
| 113 |
+
|
| 114 |
+
} else if (!strcmp(buf, "Asahi Optical Co.,Ltd.") ||
|
| 115 |
+
!strcmp(buf, "PENTAX Corporation")) {
|
| 116 |
+
show_mnote_tag(ed, 0x23); /* MNOTE_PENTAX2_TAG_HOMETOWN_CITY */
|
| 117 |
+
}
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
/* Free the EXIF data */
|
| 122 |
+
exif_data_unref(ed);
|
| 123 |
+
|
| 124 |
+
return 0;
|
| 125 |
+
}
|
local-test-libexif-delta-01-exif-003/afc-libexif/contrib/examples/thumbnail.c
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* libexif example program to extract an EXIF thumbnail from an image
|
| 3 |
+
* and save it into a new file.
|
| 4 |
+
*
|
| 5 |
+
* Placed into the public domain by Dan Fandrich
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
#include <stdio.h>
|
| 9 |
+
#include <libexif/exif-loader.h>
|
| 10 |
+
|
| 11 |
+
int main(int argc, char **argv)
|
| 12 |
+
{
|
| 13 |
+
int rc = 1;
|
| 14 |
+
ExifLoader *l;
|
| 15 |
+
|
| 16 |
+
if (argc < 2) {
|
| 17 |
+
printf("Usage: %s image.jpg\n", argv[0]);
|
| 18 |
+
printf("Extracts a thumbnail from the given EXIF image.\n");
|
| 19 |
+
return rc;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
/* Create an ExifLoader object to manage the EXIF loading process */
|
| 23 |
+
l = exif_loader_new();
|
| 24 |
+
if (l) {
|
| 25 |
+
ExifData *ed;
|
| 26 |
+
|
| 27 |
+
/* Load the EXIF data from the image file */
|
| 28 |
+
exif_loader_write_file(l, argv[1]);
|
| 29 |
+
|
| 30 |
+
/* Get a pointer to the EXIF data */
|
| 31 |
+
ed = exif_loader_get_data(l);
|
| 32 |
+
|
| 33 |
+
/* The loader is no longer needed--free it */
|
| 34 |
+
exif_loader_unref(l);
|
| 35 |
+
l = NULL;
|
| 36 |
+
if (ed) {
|
| 37 |
+
/* Make sure the image had a thumbnail before trying to write it */
|
| 38 |
+
if (ed->data && ed->size) {
|
| 39 |
+
FILE *thumb;
|
| 40 |
+
char thumb_name[1024];
|
| 41 |
+
|
| 42 |
+
/* Try to create a unique name for the thumbnail file */
|
| 43 |
+
snprintf(thumb_name, sizeof(thumb_name),
|
| 44 |
+
"%s_thumb.jpg", argv[1]);
|
| 45 |
+
|
| 46 |
+
thumb = fopen(thumb_name, "wb");
|
| 47 |
+
if (thumb) {
|
| 48 |
+
/* Write the thumbnail image to the file */
|
| 49 |
+
fwrite(ed->data, 1, ed->size, thumb);
|
| 50 |
+
fclose(thumb);
|
| 51 |
+
printf("Wrote thumbnail to %s\n", thumb_name);
|
| 52 |
+
rc = 0;
|
| 53 |
+
} else {
|
| 54 |
+
printf("Could not create file %s\n", thumb_name);
|
| 55 |
+
rc = 2;
|
| 56 |
+
}
|
| 57 |
+
} else {
|
| 58 |
+
printf("No EXIF thumbnail in file %s\n", argv[1]);
|
| 59 |
+
rc = 1;
|
| 60 |
+
}
|
| 61 |
+
/* Free the EXIF data */
|
| 62 |
+
exif_data_unref(ed);
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
return rc;
|
| 66 |
+
}
|
local-test-libexif-delta-01-exif-003/afc-libexif/contrib/examples/write-exif.c
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* write-exif.c
|
| 3 |
+
*
|
| 4 |
+
* Placed into the public domain by Daniel Fandrich
|
| 5 |
+
*
|
| 6 |
+
* Create a new EXIF data block and write it into a JPEG image file.
|
| 7 |
+
*
|
| 8 |
+
* The JPEG image data used in this example is fixed and is guaranteed not
|
| 9 |
+
* to contain an EXIF tag block already, so it is easy to precompute where
|
| 10 |
+
* in the file the EXIF data should be. In real life, a library like
|
| 11 |
+
* libjpeg (included with the exif command-line tool source code) would
|
| 12 |
+
* be used to write to an existing JPEG file.
|
| 13 |
+
*/
|
| 14 |
+
|
| 15 |
+
#include <stdio.h>
|
| 16 |
+
#include <stdlib.h>
|
| 17 |
+
#include <string.h>
|
| 18 |
+
#include <assert.h>
|
| 19 |
+
#include <libexif/exif-data.h>
|
| 20 |
+
|
| 21 |
+
/* this file will be unilaterally overwritten */
|
| 22 |
+
#define FILE_NAME "write-exif.jpg"
|
| 23 |
+
|
| 24 |
+
/* raw JPEG image data */
|
| 25 |
+
static const unsigned char image_jpg[] = {
|
| 26 |
+
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01,
|
| 27 |
+
0x01, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43,
|
| 28 |
+
0x00, 0x14, 0x0e, 0x0f, 0x12, 0x0f, 0x0d, 0x14, 0x12, 0x10, 0x12, 0x17,
|
| 29 |
+
0x15, 0x14, 0x18, 0x1e, 0x32, 0x21, 0x1e, 0x1c, 0x1c, 0x1e, 0x3d, 0x2c,
|
| 30 |
+
0x2e, 0x24, 0x32, 0x49, 0x40, 0x4c, 0x4b, 0x47, 0x40, 0x46, 0x45, 0x50,
|
| 31 |
+
0x5a, 0x73, 0x62, 0x50, 0x55, 0x6d, 0x56, 0x45, 0x46, 0x64, 0x88, 0x65,
|
| 32 |
+
0x6d, 0x77, 0x7b, 0x81, 0x82, 0x81, 0x4e, 0x60, 0x8d, 0x97, 0x8c, 0x7d,
|
| 33 |
+
0x96, 0x73, 0x7e, 0x81, 0x7c, 0xff, 0xc0, 0x00, 0x0b, 0x08, 0x00, 0x40,
|
| 34 |
+
0x00, 0x40, 0x01, 0x01, 0x11, 0x00, 0xff, 0xc4, 0x00, 0x1b, 0x00, 0x00,
|
| 35 |
+
0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
| 36 |
+
0x00, 0x00, 0x00, 0x00, 0x05, 0x06, 0x04, 0x03, 0x07, 0x02, 0x01, 0xff,
|
| 37 |
+
0xc4, 0x00, 0x2f, 0x10, 0x00, 0x01, 0x03, 0x03, 0x02, 0x05, 0x03, 0x03,
|
| 38 |
+
0x03, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x11,
|
| 39 |
+
0x00, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x81, 0x61, 0x71,
|
| 40 |
+
0x91, 0x13, 0x32, 0xa1, 0x14, 0x22, 0xc1, 0x15, 0x23, 0x52, 0xd1, 0xf0,
|
| 41 |
+
0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xb3, 0xa2,
|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 0x6b, 0x3b,
|
| 96 |
+
0xa8, 0xf7, 0x3e, 0x9d, 0x87, 0x4a, 0x63, 0x45, 0x14, 0x51, 0x45, 0x14,
|
| 97 |
+
0x51, 0x45, 0x7f, 0xff, 0xd9
|
| 98 |
+
};
|
| 99 |
+
|
| 100 |
+
/* length of data in image_jpg */
|
| 101 |
+
static const unsigned int image_jpg_len = sizeof(image_jpg);
|
| 102 |
+
|
| 103 |
+
/* dimensions of image */
|
| 104 |
+
static const unsigned int image_jpg_x = 64;
|
| 105 |
+
static const unsigned int image_jpg_y = 64;
|
| 106 |
+
|
| 107 |
+
/* start of JPEG image data section */
|
| 108 |
+
static const unsigned int image_data_offset = 20;
|
| 109 |
+
#define image_data_len (image_jpg_len - image_data_offset)
|
| 110 |
+
|
| 111 |
+
/* raw EXIF header data */
|
| 112 |
+
static const unsigned char exif_header[] = {
|
| 113 |
+
0xff, 0xd8, 0xff, 0xe1
|
| 114 |
+
};
|
| 115 |
+
/* length of data in exif_header */
|
| 116 |
+
static const unsigned int exif_header_len = sizeof(exif_header);
|
| 117 |
+
|
| 118 |
+
/* byte order to use in the EXIF block */
|
| 119 |
+
#define FILE_BYTE_ORDER EXIF_BYTE_ORDER_INTEL
|
| 120 |
+
|
| 121 |
+
/* comment to write into the EXIF block */
|
| 122 |
+
#define FILE_COMMENT "libexif demonstration image"
|
| 123 |
+
|
| 124 |
+
/* special header required for EXIF_TAG_USER_COMMENT */
|
| 125 |
+
#define ASCII_COMMENT "ASCII\0\0\0"
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
/* Get an existing tag, or create one if it doesn't exist */
|
| 129 |
+
static ExifEntry *init_tag(ExifData *exif, ExifIfd ifd, ExifTag tag)
|
| 130 |
+
{
|
| 131 |
+
ExifEntry *entry;
|
| 132 |
+
/* Return an existing tag if one exists */
|
| 133 |
+
if (!((entry = exif_content_get_entry (exif->ifd[ifd], tag)))) {
|
| 134 |
+
/* Allocate a new entry */
|
| 135 |
+
entry = exif_entry_new ();
|
| 136 |
+
assert(entry != NULL); /* catch an out of memory condition */
|
| 137 |
+
entry->tag = tag; /* tag must be set before calling
|
| 138 |
+
exif_content_add_entry */
|
| 139 |
+
|
| 140 |
+
/* Attach the ExifEntry to an IFD */
|
| 141 |
+
exif_content_add_entry (exif->ifd[ifd], entry);
|
| 142 |
+
|
| 143 |
+
/* Allocate memory for the entry and fill with default data */
|
| 144 |
+
exif_entry_initialize (entry, tag);
|
| 145 |
+
|
| 146 |
+
/* Ownership of the ExifEntry has now been passed to the IFD.
|
| 147 |
+
* One must be very careful in accessing a structure after
|
| 148 |
+
* unref'ing it; in this case, we know "entry" won't be freed
|
| 149 |
+
* because the reference count was bumped when it was added to
|
| 150 |
+
* the IFD.
|
| 151 |
+
*/
|
| 152 |
+
exif_entry_unref(entry);
|
| 153 |
+
}
|
| 154 |
+
return entry;
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
/* Create a brand-new tag with a data field of the given length, in the
|
| 158 |
+
* given IFD. This is needed when exif_entry_initialize() isn't able to create
|
| 159 |
+
* this type of tag itself, or the default data length it creates isn't the
|
| 160 |
+
* correct length.
|
| 161 |
+
*/
|
| 162 |
+
static ExifEntry *create_tag(ExifData *exif, ExifIfd ifd, ExifTag tag, size_t len)
|
| 163 |
+
{
|
| 164 |
+
void *buf;
|
| 165 |
+
ExifEntry *entry;
|
| 166 |
+
|
| 167 |
+
/* Create a memory allocator to manage this ExifEntry */
|
| 168 |
+
ExifMem *mem = exif_mem_new_default();
|
| 169 |
+
assert(mem != NULL); /* catch an out of memory condition */
|
| 170 |
+
|
| 171 |
+
/* Create a new ExifEntry using our allocator */
|
| 172 |
+
entry = exif_entry_new_mem (mem);
|
| 173 |
+
assert(entry != NULL);
|
| 174 |
+
|
| 175 |
+
/* Allocate memory to use for holding the tag data */
|
| 176 |
+
buf = exif_mem_alloc(mem, len);
|
| 177 |
+
assert(buf != NULL);
|
| 178 |
+
|
| 179 |
+
/* Fill in the entry */
|
| 180 |
+
entry->data = buf;
|
| 181 |
+
entry->size = len;
|
| 182 |
+
entry->tag = tag;
|
| 183 |
+
entry->components = len;
|
| 184 |
+
entry->format = EXIF_FORMAT_UNDEFINED;
|
| 185 |
+
|
| 186 |
+
/* Attach the ExifEntry to an IFD */
|
| 187 |
+
exif_content_add_entry (exif->ifd[ifd], entry);
|
| 188 |
+
|
| 189 |
+
/* The ExifMem and ExifEntry are now owned elsewhere */
|
| 190 |
+
exif_mem_unref(mem);
|
| 191 |
+
exif_entry_unref(entry);
|
| 192 |
+
|
| 193 |
+
return entry;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
int main ()
|
| 197 |
+
{
|
| 198 |
+
int rc = 1;
|
| 199 |
+
FILE *f;
|
| 200 |
+
unsigned char *exif_data;
|
| 201 |
+
unsigned int exif_data_len;
|
| 202 |
+
ExifEntry *entry;
|
| 203 |
+
ExifData *exif = exif_data_new();
|
| 204 |
+
if (!exif) {
|
| 205 |
+
fprintf(stderr, "Out of memory\n");
|
| 206 |
+
return 2;
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
/* Set the image options */
|
| 210 |
+
exif_data_set_option(exif, EXIF_DATA_OPTION_FOLLOW_SPECIFICATION);
|
| 211 |
+
exif_data_set_data_type(exif, EXIF_DATA_TYPE_COMPRESSED);
|
| 212 |
+
exif_data_set_byte_order(exif, FILE_BYTE_ORDER);
|
| 213 |
+
|
| 214 |
+
/* Create the mandatory EXIF fields with default data */
|
| 215 |
+
exif_data_fix(exif);
|
| 216 |
+
|
| 217 |
+
/* All these tags are created with default values by exif_data_fix() */
|
| 218 |
+
/* Change the data to the correct values for this image. */
|
| 219 |
+
entry = init_tag(exif, EXIF_IFD_EXIF, EXIF_TAG_PIXEL_X_DIMENSION);
|
| 220 |
+
exif_set_long(entry->data, FILE_BYTE_ORDER, image_jpg_x);
|
| 221 |
+
|
| 222 |
+
entry = init_tag(exif, EXIF_IFD_EXIF, EXIF_TAG_PIXEL_Y_DIMENSION);
|
| 223 |
+
exif_set_long(entry->data, FILE_BYTE_ORDER, image_jpg_y);
|
| 224 |
+
|
| 225 |
+
entry = init_tag(exif, EXIF_IFD_EXIF, EXIF_TAG_COLOR_SPACE);
|
| 226 |
+
exif_set_short(entry->data, FILE_BYTE_ORDER, 1);
|
| 227 |
+
|
| 228 |
+
/* Create a EXIF_TAG_USER_COMMENT tag. This one must be handled
|
| 229 |
+
* differently because that tag isn't automatically created and
|
| 230 |
+
* allocated by exif_data_fix(), nor can it be created using
|
| 231 |
+
* exif_entry_initialize() so it must be explicitly allocated here.
|
| 232 |
+
*/
|
| 233 |
+
entry = create_tag(exif, EXIF_IFD_EXIF, EXIF_TAG_USER_COMMENT,
|
| 234 |
+
sizeof(ASCII_COMMENT) + sizeof(FILE_COMMENT) - 2);
|
| 235 |
+
/* Write the special header needed for a comment tag */
|
| 236 |
+
memcpy(entry->data, ASCII_COMMENT, sizeof(ASCII_COMMENT)-1);
|
| 237 |
+
/* Write the actual comment text, without the trailing NUL character */
|
| 238 |
+
memcpy(entry->data+8, FILE_COMMENT, sizeof(FILE_COMMENT)-1);
|
| 239 |
+
/* create_tag() happens to set the format and components correctly for
|
| 240 |
+
* EXIF_TAG_USER_COMMENT, so there is nothing more to do. */
|
| 241 |
+
|
| 242 |
+
/* Create a EXIF_TAG_SUBJECT_AREA tag */
|
| 243 |
+
entry = create_tag(exif, EXIF_IFD_EXIF, EXIF_TAG_SUBJECT_AREA,
|
| 244 |
+
4 * exif_format_get_size(EXIF_FORMAT_SHORT));
|
| 245 |
+
entry->format = EXIF_FORMAT_SHORT;
|
| 246 |
+
entry->components = 4;
|
| 247 |
+
exif_set_short(entry->data, FILE_BYTE_ORDER, image_jpg_x / 2);
|
| 248 |
+
exif_set_short(entry->data+2, FILE_BYTE_ORDER, image_jpg_y / 2);
|
| 249 |
+
exif_set_short(entry->data+4, FILE_BYTE_ORDER, image_jpg_x);
|
| 250 |
+
exif_set_short(entry->data+6, FILE_BYTE_ORDER, image_jpg_y);
|
| 251 |
+
|
| 252 |
+
/* Get a pointer to the EXIF data block we just created */
|
| 253 |
+
exif_data_save_data(exif, &exif_data, &exif_data_len);
|
| 254 |
+
assert(exif_data != NULL);
|
| 255 |
+
|
| 256 |
+
f = fopen(FILE_NAME, "wb");
|
| 257 |
+
if (!f) {
|
| 258 |
+
fprintf(stderr, "Error creating file %s\n", FILE_NAME);
|
| 259 |
+
exif_data_unref(exif);
|
| 260 |
+
return rc;
|
| 261 |
+
}
|
| 262 |
+
/* Write EXIF header */
|
| 263 |
+
if (fwrite(exif_header, exif_header_len, 1, f) != 1) {
|
| 264 |
+
fprintf(stderr, "Error writing to file %s\n", FILE_NAME);
|
| 265 |
+
goto errout;
|
| 266 |
+
}
|
| 267 |
+
/* Write EXIF block length in big-endian order */
|
| 268 |
+
if (fputc((exif_data_len+2) >> 8, f) < 0) {
|
| 269 |
+
fprintf(stderr, "Error writing to file %s\n", FILE_NAME);
|
| 270 |
+
goto errout;
|
| 271 |
+
}
|
| 272 |
+
if (fputc((exif_data_len+2) & 0xff, f) < 0) {
|
| 273 |
+
fprintf(stderr, "Error writing to file %s\n", FILE_NAME);
|
| 274 |
+
goto errout;
|
| 275 |
+
}
|
| 276 |
+
/* Write EXIF data block */
|
| 277 |
+
if (fwrite(exif_data, exif_data_len, 1, f) != 1) {
|
| 278 |
+
fprintf(stderr, "Error writing to file %s\n", FILE_NAME);
|
| 279 |
+
goto errout;
|
| 280 |
+
}
|
| 281 |
+
/* Write JPEG image data, skipping the non-EXIF header */
|
| 282 |
+
if (fwrite(image_jpg+image_data_offset, image_data_len, 1, f) != 1) {
|
| 283 |
+
fprintf(stderr, "Error writing to file %s\n", FILE_NAME);
|
| 284 |
+
goto errout;
|
| 285 |
+
}
|
| 286 |
+
printf("Wrote file %s\n", FILE_NAME);
|
| 287 |
+
rc = 0;
|
| 288 |
+
|
| 289 |
+
errout:
|
| 290 |
+
if (fclose(f)) {
|
| 291 |
+
fprintf(stderr, "Error writing to file %s\n", FILE_NAME);
|
| 292 |
+
rc = 1;
|
| 293 |
+
}
|
| 294 |
+
/* The allocator we're using for ExifData is the standard one, so use
|
| 295 |
+
* it directly to free this pointer.
|
| 296 |
+
*/
|
| 297 |
+
free(exif_data);
|
| 298 |
+
exif_data_unref(exif);
|
| 299 |
+
|
| 300 |
+
return rc;
|
| 301 |
+
}
|
local-test-libexif-delta-01-exif-003/afc-libexif/contrib/watcom/_stdint.h
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifndef __STDINT_H
|
| 2 |
+
#define __STDINT_H
|
| 3 |
+
#include <sys/types.h>
|
| 4 |
+
typedef unsigned char uint8_t;
|
| 5 |
+
typedef unsigned short uint16_t;
|
| 6 |
+
typedef unsigned long uint32_t;
|
| 7 |
+
|
| 8 |
+
typedef signed char int8_t;
|
| 9 |
+
typedef signed short int16_t;
|
| 10 |
+
typedef signed long int32_t;
|
| 11 |
+
#endif
|
| 12 |
+
|
| 13 |
+
|
local-test-libexif-delta-01-exif-003/afc-libexif/doc/.gitignore
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Makefile
|
| 2 |
+
Makefile.in
|
| 3 |
+
.libs
|
| 4 |
+
.deps
|
| 5 |
+
*.o
|
| 6 |
+
*.lo
|
| 7 |
+
Doxyfile
|
| 8 |
+
Doxyfile-internals
|
local-test-libexif-delta-01-exif-003/afc-libexif/doc/Doxyfile-internals.in
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
local-test-libexif-delta-01-exif-003/afc-libexif/doc/Doxyfile.in
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
local-test-libexif-delta-01-exif-003/afc-libexif/doc/Makefile.am
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
########################################################################
|
| 2 |
+
# Conditional rules, depending on tool availability
|
| 3 |
+
########################################################################
|
| 4 |
+
|
| 5 |
+
DOXYGEN_FILES =
|
| 6 |
+
DOXYGEN_STAMPS =
|
| 7 |
+
DOXYGEN_UPLOAD =
|
| 8 |
+
|
| 9 |
+
DOXYGEN_INSTALL_TARGETS =
|
| 10 |
+
DOXYGEN_UNINSTALL_TARGETS =
|
| 11 |
+
|
| 12 |
+
DOXYGEN_CLEAN_TARGETS =
|
| 13 |
+
|
| 14 |
+
DOXYGEN_TARBALLS =
|
| 15 |
+
|
| 16 |
+
# FIXME: Depending on the source files would be sufficient, but only
|
| 17 |
+
# maintainable with a completely non-recursive build.
|
| 18 |
+
# Depending on libexif.la works at least.
|
| 19 |
+
$(top_builddir)/libexif/libexif.la:
|
| 20 |
+
cd $(top_builddir)/libexif && $(MAKE) libexif.la
|
| 21 |
+
|
| 22 |
+
if BUILD_DOCS
|
| 23 |
+
if HAVE_DOXYGEN
|
| 24 |
+
|
| 25 |
+
DOXYGEN_UPLOAD += $(HTML_APIDOC_DIR).uploaded
|
| 26 |
+
|
| 27 |
+
DOXYGEN_STAMPS += $(HTML_APIDOC_DIR).stamp
|
| 28 |
+
$(HTML_APIDOC_DIR).stamp: Doxyfile $(top_builddir)/libexif/libexif.la
|
| 29 |
+
$(DOXYGEN) $<
|
| 30 |
+
echo > $@
|
| 31 |
+
|
| 32 |
+
DOXYGEN_TARBALLS += $(HTML_APIDOC_DIR).tar.gz
|
| 33 |
+
$(HTML_APIDOC_DIR).tar.gz: $(HTML_APIDOC_DIR).stamp
|
| 34 |
+
(cd $(DOXYGEN_OUTPUT_DIR) && $(AMTAR) chof - $(HTML_APIDOC_DIR) | GZIP=--best gzip -c) > $@
|
| 35 |
+
|
| 36 |
+
if ENABLE_INTERNAL_DOCS
|
| 37 |
+
DOXYGEN_UPLOAD += $(HTML_APIDOC_INTERNALS_DIR).uploaded
|
| 38 |
+
|
| 39 |
+
DOXYGEN_STAMPS += $(HTML_APIDOC_INTERNALS_DIR).stamp
|
| 40 |
+
$(HTML_APIDOC_INTERNALS_DIR).stamp: Doxyfile-internals $(top_builddir)/libexif/libexif.la
|
| 41 |
+
$(DOXYGEN) $<
|
| 42 |
+
echo > $@
|
| 43 |
+
|
| 44 |
+
DOXYGEN_TARBALLS += $(HTML_APIDOC_INTERNALS_DIR).tar.gz
|
| 45 |
+
$(HTML_APIDOC_INTERNALS_DIR).tar.gz: $(HTML_APIDOC_INTERNALS_DIR).stamp
|
| 46 |
+
(cd $(DOXYGEN_OUTPUT_DIR) && $(AMTAR) chof - $(HTML_APIDOC_INTERNALS_DIR) | GZIP=--best gzip -c) > $@
|
| 47 |
+
|
| 48 |
+
DOXYGEN_INSTALL_TARGETS += install-apidocs-internals
|
| 49 |
+
install-apidocs-internals: $(HTML_APIDOC_INTERNALS_DIR).stamp
|
| 50 |
+
mkdir -p "$(DESTDIR)$(docdir)"
|
| 51 |
+
find "$(DOXYGEN_OUTPUT_DIR)/$(HTML_APIDOC_INTERNALS_DIR)" \
|
| 52 |
+
\( -type d -exec chmod 0755 {} \; \) -or \
|
| 53 |
+
\( -type f -exec chmod 0644 {} \; \)
|
| 54 |
+
(unset CDPATH; cd "$(DOXYGEN_OUTPUT_DIR)" && tar cpf - "$(HTML_APIDOC_INTERNALS_DIR)") \
|
| 55 |
+
| (cd "$(DESTDIR)$(docdir)" && tar xpf -)
|
| 56 |
+
|
| 57 |
+
DOXYGEN_UNINSTALL_TARGETS += uninstall-apidocs-internals
|
| 58 |
+
uninstall-apidocs-internals:
|
| 59 |
+
rm -rf "$(DESTDIR)$(docdir)/$(HTML_APIDOC_INTERNALS_DIR)"
|
| 60 |
+
|
| 61 |
+
endif
|
| 62 |
+
|
| 63 |
+
DOXYGEN_INSTALL_TARGETS += install-apidocs
|
| 64 |
+
install-apidocs: $(HTML_APIDOC_DIR).stamp
|
| 65 |
+
mkdir -p "$(DESTDIR)$(docdir)"
|
| 66 |
+
find "$(DOXYGEN_OUTPUT_DIR)/$(HTML_APIDOC_DIR)" \
|
| 67 |
+
\( -type d -exec chmod 0755 {} \; \) -or \
|
| 68 |
+
\( -type f -exec chmod 0644 {} \; \)
|
| 69 |
+
(unset CDPATH; cd "$(DOXYGEN_OUTPUT_DIR)" && tar cpf - "$(HTML_APIDOC_DIR)") \
|
| 70 |
+
| (cd "$(DESTDIR)$(docdir)" && tar xpf -)
|
| 71 |
+
|
| 72 |
+
DOXYGEN_UNINSTALL_TARGETS += uninstall-apidocs
|
| 73 |
+
uninstall-apidocs:
|
| 74 |
+
rm -rf "$(DESTDIR)$(docdir)/$(HTML_APIDOC_DIR)"
|
| 75 |
+
|
| 76 |
+
DOXYGEN_CLEAN_TARGETS += clean-apidocs
|
| 77 |
+
clean-apidocs:
|
| 78 |
+
rm -rf $(DOXYGEN_OUTPUT_DIR)
|
| 79 |
+
rm -f $(HTML_APIDOC_DIR).tar.gz $(HTML_APIDOC_INTERNALS_DIR).tar.gz
|
| 80 |
+
|
| 81 |
+
$(DOXYGEN_UPLOAD): $(DOXYGEN_STAMPS)
|
| 82 |
+
find $(DOXYGEN_OUTPUT_DIR) \( -type d -exec chmod a+rx,go-w,g+s {} \; \) \
|
| 83 |
+
-or \( -type f -exec chmod a+r {} \; \)
|
| 84 |
+
rsync -avz --progress $(DOXYGEN_OUTPUT_DIR)/$(HTML_APIDOC_DIR)/ sf:/home/users/h/hu/hun/libexif/htdocs/api/
|
| 85 |
+
if ENABLE_INTERNAL_DOCS
|
| 86 |
+
rsync -avz --progress $(DOXYGEN_OUTPUT_DIR)/$(HTML_APIDOC_INTERNALS_DIR)/ sf:/home/users/h/hu/hun/libexif/htdocs/internals/
|
| 87 |
+
endif
|
| 88 |
+
ssh "sf" "find /home/groups/l/li/libexif/htdocs/internals /home/groups/l/li/libexif/htdocs/api \( -type d -exec chgrp libexif {} \; -exec chmod g+rwxs,a+rx {} \; \) -or \( -type f -exec chgrp libexif {} \; -exec chmod g+rw {} \; \( -name '*.html' -or -name '*.png' -or -name '*.php' -or -name '*.jpg' -or -name '*.css' -name '*.dot' -name '*.map' \) -exec chmod a+r {} \; \)"
|
| 89 |
+
|
| 90 |
+
endif # HAVE_DOXYGEN
|
| 91 |
+
endif # BUILD_DOCS
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
########################################################################
|
| 95 |
+
# Common part
|
| 96 |
+
########################################################################
|
| 97 |
+
|
| 98 |
+
EXTRA_DIST = Doxyfile.in Doxyfile-internals.in footer.html README.apidocs $(HTML_APIDOC_DIR).tar.gz
|
| 99 |
+
|
| 100 |
+
doc_DATA = $(DOXYGEN_FILES)
|
| 101 |
+
|
| 102 |
+
all-local: $(DOXYGEN_STAMPS)
|
| 103 |
+
|
| 104 |
+
install-data-local: $(DOXYGEN_INSTALL_TARGETS)
|
| 105 |
+
|
| 106 |
+
uninstall-local: $(DOXYGEN_UNINSTALL_TARGETS)
|
| 107 |
+
|
| 108 |
+
clean-local: $(DOXYGEN_CLEAN_TARGETS)
|
| 109 |
+
|
| 110 |
+
upload: $(DOXYGEN_UPLOAD)
|
| 111 |
+
|
| 112 |
+
CLEANFILES = $(DOXYGEN_FILES) $(DOXYGEN_STAMPS)
|
| 113 |
+
|
local-test-libexif-delta-01-exif-003/afc-libexif/doc/README.apidocs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Rules for the API docs:
|
| 2 |
+
|
| 3 |
+
1. Clearly distinguish between internal and the external API/ABI.
|
| 4 |
+
2. Mark internal stuff with \internal.
|
| 5 |
+
3. If this has been solved, start documenting the external interface.
|
| 6 |
+
|
| 7 |
+
Thank you.
|
local-test-libexif-delta-01-exif-003/afc-libexif/doc/footer.html
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
<hr size="1">
|
| 4 |
+
<address style="text-align: right;">
|
| 5 |
+
<a href="https://libexif.github.io" target="_top">libexif</a>
|
| 6 |
+
|
| 7 |
+
<small>Generated by <a href="http://www.doxygen.org/" target="_top"><img src="doxygen.png" alt="doxygen" align="middle" border="0">
|
| 8 |
+
</a>
|
| 9 |
+
</small></address>
|
| 10 |
+
</body>
|
| 11 |
+
</html>
|
| 12 |
+
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/.gitignore
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Makefile
|
| 2 |
+
Makefile.in
|
| 3 |
+
.libs
|
| 4 |
+
.deps
|
| 5 |
+
libexif.la
|
| 6 |
+
*.o
|
| 7 |
+
*.lo
|
| 8 |
+
*.la
|
| 9 |
+
libexif.pc
|
| 10 |
+
_stdint.h
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/Makefile.am
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
EXTRA_DIST =
|
| 2 |
+
lib_LTLIBRARIES =
|
| 3 |
+
noinst_LTLIBRARIES =
|
| 4 |
+
|
| 5 |
+
include apple/Makefile-files
|
| 6 |
+
include canon/Makefile-files
|
| 7 |
+
include fuji/Makefile-files
|
| 8 |
+
include olympus/Makefile-files
|
| 9 |
+
include pentax/Makefile-files
|
| 10 |
+
|
| 11 |
+
# The -no-undefined makes it possible to build DLLs for Windows,
|
| 12 |
+
# or shared libraries for Tru64 or AIX (according to the autobook
|
| 13 |
+
# chapter on "Portable Library Design"). It doesn't seem to hurt
|
| 14 |
+
# elsewhere, so we can leave it in.
|
| 15 |
+
lib_LTLIBRARIES += libexif.la
|
| 16 |
+
libexif_la_LDFLAGS = \
|
| 17 |
+
-export-symbols $(srcdir)/libexif.sym \
|
| 18 |
+
-no-undefined -version-info @LIBEXIF_VERSION_INFO@
|
| 19 |
+
libexif_la_SOURCES = \
|
| 20 |
+
exif-byte-order.c \
|
| 21 |
+
exif-content.c \
|
| 22 |
+
exif-data.c \
|
| 23 |
+
exif-entry.c \
|
| 24 |
+
exif-format.c \
|
| 25 |
+
exif-ifd.c \
|
| 26 |
+
exif-loader.c \
|
| 27 |
+
exif-log.c \
|
| 28 |
+
exif-mem.c \
|
| 29 |
+
exif-mnote-data.c \
|
| 30 |
+
exif-mnote-data-priv.h \
|
| 31 |
+
exif-tag.c \
|
| 32 |
+
exif-utils.c \
|
| 33 |
+
i18n.h \
|
| 34 |
+
exif-gps-ifd.c \
|
| 35 |
+
exif-gps-ifd.h
|
| 36 |
+
|
| 37 |
+
libexif_la_DEPENDENCIES = \
|
| 38 |
+
$(srcdir)/libexif.sym \
|
| 39 |
+
libmnote-apple.la \
|
| 40 |
+
libmnote-canon.la \
|
| 41 |
+
libmnote-fuji.la \
|
| 42 |
+
libmnote-olympus.la \
|
| 43 |
+
libmnote-pentax.la
|
| 44 |
+
libexif_la_LIBADD = \
|
| 45 |
+
$(LTLIBINTL) \
|
| 46 |
+
libmnote-apple.la \
|
| 47 |
+
libmnote-canon.la \
|
| 48 |
+
libmnote-fuji.la \
|
| 49 |
+
libmnote-olympus.la \
|
| 50 |
+
libmnote-pentax.la
|
| 51 |
+
|
| 52 |
+
libexifincludedir = $(includedir)/libexif
|
| 53 |
+
libexifinclude_HEADERS = \
|
| 54 |
+
exif-byte-order.h \
|
| 55 |
+
exif-content.h \
|
| 56 |
+
exif-data.h \
|
| 57 |
+
exif-data-type.h \
|
| 58 |
+
exif-entry.h \
|
| 59 |
+
exif-format.h \
|
| 60 |
+
exif-ifd.h \
|
| 61 |
+
exif-loader.h \
|
| 62 |
+
exif-log.h \
|
| 63 |
+
exif-mem.h \
|
| 64 |
+
exif-mnote-data.h \
|
| 65 |
+
exif-tag.h \
|
| 66 |
+
exif-utils.h \
|
| 67 |
+
_stdint.h
|
| 68 |
+
|
| 69 |
+
EXTRA_DIST += exif-system.h exif.h
|
| 70 |
+
|
| 71 |
+
EXTRA_DIST += libexif.sym
|
| 72 |
+
|
| 73 |
+
DISTCLEANFILES = _stdint.h
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/apple/.gitignore
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Makefile
|
| 2 |
+
Makefile.in
|
| 3 |
+
.deps
|
| 4 |
+
.libs
|
| 5 |
+
*.la
|
| 6 |
+
*.lo
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/apple/Makefile-files
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- Makefile -*-
|
| 2 |
+
noinst_LTLIBRARIES += libmnote-apple.la
|
| 3 |
+
libmnote_apple_la_SOURCES = \
|
| 4 |
+
apple/mnote-apple-entry.c apple/mnote-apple-entry.h \
|
| 5 |
+
apple/exif-mnote-data-apple.c apple/exif-mnote-data-apple.h \
|
| 6 |
+
apple/mnote-apple-tag.c apple/mnote-apple-tag.h
|
| 7 |
+
libmnote_apple_la_LIBADD = $(LTLIBINTL)
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/apple/exif-mnote-data-apple.c
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* exif-mnote-data-apple.c
|
| 2 |
+
*
|
| 3 |
+
* Copyright (c) 2018 zhanwang-sky <[email protected]>
|
| 4 |
+
*
|
| 5 |
+
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#include <config.h>
|
| 22 |
+
#include "exif-mnote-data-apple.h"
|
| 23 |
+
|
| 24 |
+
#include <stdio.h>
|
| 25 |
+
#include <stdlib.h>
|
| 26 |
+
#include <string.h>
|
| 27 |
+
|
| 28 |
+
#include <libexif/exif-data.h>
|
| 29 |
+
#include <libexif/exif-utils.h>
|
| 30 |
+
|
| 31 |
+
static void
|
| 32 |
+
exif_mnote_data_apple_free(ExifMnoteData *md) {
|
| 33 |
+
ExifMnoteDataApple *d = (ExifMnoteDataApple *) md;
|
| 34 |
+
unsigned int i;
|
| 35 |
+
|
| 36 |
+
/*printf("%s\n", __FUNCTION__);*/
|
| 37 |
+
|
| 38 |
+
if (!d) {
|
| 39 |
+
return;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
if (d->entries) {
|
| 43 |
+
for (i = 0; i < d->count; i++) {
|
| 44 |
+
if (d->entries[i].data) {
|
| 45 |
+
exif_mem_free(md->mem, d->entries[i].data);
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
exif_mem_free(md->mem, d->entries);
|
| 49 |
+
d->entries = NULL;
|
| 50 |
+
d->count = 0;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
return;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
static void
|
| 57 |
+
exif_mnote_data_apple_load(ExifMnoteData *md, const unsigned char *buf, unsigned int buf_size) {
|
| 58 |
+
ExifMnoteDataApple *d = (ExifMnoteDataApple *) md;
|
| 59 |
+
unsigned int tcount, i;
|
| 60 |
+
unsigned int dsize;
|
| 61 |
+
unsigned int ofs, dofs;
|
| 62 |
+
|
| 63 |
+
/*printf("%s\n", __FUNCTION__);*/
|
| 64 |
+
|
| 65 |
+
if (!d || !buf || (buf_size < 6 + 16)) {
|
| 66 |
+
exif_log(md->log, EXIF_LOG_CODE_CORRUPT_DATA,
|
| 67 |
+
"ExifMnoteDataApple", "Short MakerNote");
|
| 68 |
+
return;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
/* Start of interesting data */
|
| 72 |
+
ofs = d->offset + 6;
|
| 73 |
+
|
| 74 |
+
if ((buf[ofs + 12] == 'M') && (buf[ofs + 13] == 'M')) {
|
| 75 |
+
d->order = EXIF_BYTE_ORDER_MOTOROLA;
|
| 76 |
+
} else if ((buf[ofs + 12] == 'I') && (buf[ofs + 13] == 'I')) {
|
| 77 |
+
d->order = EXIF_BYTE_ORDER_INTEL;
|
| 78 |
+
} else {
|
| 79 |
+
exif_log(md->log, EXIF_LOG_CODE_CORRUPT_DATA,
|
| 80 |
+
"ExifMnoteDataApple", "Unrecognized byte order");
|
| 81 |
+
/*printf("%s(%d)\n", __FUNCTION__, __LINE__);*/
|
| 82 |
+
return;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
tcount = (unsigned int) exif_get_short(buf + ofs + 14, d->order);
|
| 86 |
+
|
| 87 |
+
/* Sanity check the offset */
|
| 88 |
+
if (buf_size < d->offset + 6 + 16 + tcount * 12 + 4) {
|
| 89 |
+
exif_log(md->log, EXIF_LOG_CODE_CORRUPT_DATA,
|
| 90 |
+
"ExifMnoteDataApple", "Short MakerNote");
|
| 91 |
+
/*printf("%s(%d)\n", __FUNCTION__, __LINE__);*/
|
| 92 |
+
return;
|
| 93 |
+
}
|
| 94 |
+
memset(d->entries, 0, sizeof(MnoteAppleEntry) * tcount);
|
| 95 |
+
|
| 96 |
+
/* printf("%s(%d): total %d tags\n", __FUNCTION__, __LINE__, tcount); */
|
| 97 |
+
|
| 98 |
+
ofs += 16;
|
| 99 |
+
|
| 100 |
+
exif_mnote_data_apple_free(md);
|
| 101 |
+
|
| 102 |
+
/* Reserve enough space for all the possible MakerNote tags */
|
| 103 |
+
d->entries = exif_mem_alloc(md->mem, sizeof(MnoteAppleEntry) * tcount);
|
| 104 |
+
if (!d->entries) {
|
| 105 |
+
EXIF_LOG_NO_MEMORY(md->log, "ExifMnoteApple", sizeof(MnoteAppleEntry) * tcount);
|
| 106 |
+
/*printf("%s(%d)\n", __FUNCTION__, __LINE__);*/
|
| 107 |
+
return;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
for (i = 0; i < tcount; i++) {
|
| 111 |
+
if (ofs + 12 > buf_size) {
|
| 112 |
+
exif_log (md->log, EXIF_LOG_CODE_CORRUPT_DATA,
|
| 113 |
+
"ExifMnoteApplet", "Tag size overflow detected (%u vs size %u)", ofs + 12, buf_size);
|
| 114 |
+
break;
|
| 115 |
+
}
|
| 116 |
+
d->entries[i].tag = exif_get_short(buf + ofs, d->order);
|
| 117 |
+
d->entries[i].format = exif_get_short(buf + ofs + 2, d->order);
|
| 118 |
+
d->entries[i].components = exif_get_long(buf + ofs + 4, d->order);
|
| 119 |
+
d->entries[i].order = d->order;
|
| 120 |
+
dsize = exif_format_get_size(d->entries[i].format) * d->entries[i].components;
|
| 121 |
+
if (dsize > 4) {
|
| 122 |
+
dofs = d->offset + exif_get_long(buf + ofs + 8, d->order);
|
| 123 |
+
} else {
|
| 124 |
+
dofs = ofs + 8;
|
| 125 |
+
}
|
| 126 |
+
if (dofs > buf_size) {
|
| 127 |
+
exif_log (md->log, EXIF_LOG_CODE_CORRUPT_DATA,
|
| 128 |
+
"ExifMnoteApplet", "Tag size overflow detected (%u vs size %u)", dofs, buf_size);
|
| 129 |
+
continue;
|
| 130 |
+
}
|
| 131 |
+
ofs += 12;
|
| 132 |
+
d->entries[i].data = exif_mem_alloc(md->mem, dsize);
|
| 133 |
+
if (!d->entries[i].data) {
|
| 134 |
+
EXIF_LOG_NO_MEMORY(md->log, "ExifMnoteApple", dsize);
|
| 135 |
+
continue;
|
| 136 |
+
}
|
| 137 |
+
if (dofs + dsize > buf_size) {
|
| 138 |
+
exif_log(md->log, EXIF_LOG_CODE_CORRUPT_DATA,
|
| 139 |
+
"ExifMnoteApplet", "Tag size overflow detected (%u vs size %u)", dofs + dsize, buf_size);
|
| 140 |
+
continue;
|
| 141 |
+
}
|
| 142 |
+
memcpy(d->entries[i].data, buf + dofs, dsize);
|
| 143 |
+
d->entries[i].size = dsize;
|
| 144 |
+
}
|
| 145 |
+
d->count = tcount;
|
| 146 |
+
|
| 147 |
+
return;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
static void
|
| 151 |
+
exif_mnote_data_apple_set_offset(ExifMnoteData *md, unsigned int o) {
|
| 152 |
+
/*printf("%s\n", __FUNCTION__);*/
|
| 153 |
+
|
| 154 |
+
if (md) {
|
| 155 |
+
((ExifMnoteDataApple *) md)->offset = o;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
return;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
static void
|
| 162 |
+
exif_mnote_data_apple_set_byte_order(ExifMnoteData *md , ExifByteOrder o) {
|
| 163 |
+
ExifMnoteDataApple *d = (ExifMnoteDataApple *) md;
|
| 164 |
+
unsigned int i;
|
| 165 |
+
|
| 166 |
+
/*printf("%s\n", __FUNCTION__);*/
|
| 167 |
+
|
| 168 |
+
if (!d || d->order == o) {
|
| 169 |
+
return;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
for (i = 0; i < d->count; i++) {
|
| 173 |
+
if (d->entries[i].components && (d->entries[i].size/d->entries[i].components < exif_format_get_size (d->entries[i].format)))
|
| 174 |
+
continue;
|
| 175 |
+
exif_array_set_byte_order(d->entries[i].format, d->entries[i].data,
|
| 176 |
+
d->entries[i].components, d->entries[i].order, o);
|
| 177 |
+
d->entries[i].order = o;
|
| 178 |
+
}
|
| 179 |
+
d->order = o;
|
| 180 |
+
|
| 181 |
+
return;
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
static unsigned int
|
| 185 |
+
exif_mnote_data_apple_count(ExifMnoteData *md){
|
| 186 |
+
/*printf("%s\n", __FUNCTION__);*/
|
| 187 |
+
|
| 188 |
+
return md ? ((ExifMnoteDataApple *) md)->count : 0;
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
static unsigned int
|
| 192 |
+
exif_mnote_data_apple_get_id(ExifMnoteData *md, unsigned int i) {
|
| 193 |
+
ExifMnoteDataApple *d = (ExifMnoteDataApple *) md;
|
| 194 |
+
|
| 195 |
+
if (!d || (d->count <= i)) {
|
| 196 |
+
return 0;
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
return d->entries[i].tag;
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
static const char *
|
| 203 |
+
exif_mnote_data_apple_get_name(ExifMnoteData *md, unsigned int i) {
|
| 204 |
+
ExifMnoteDataApple *d = (ExifMnoteDataApple *) md;
|
| 205 |
+
|
| 206 |
+
if (!d || (d->count <= i)) {
|
| 207 |
+
return NULL;
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
return mnote_apple_tag_get_name(d->entries[i].tag);
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
static const char *
|
| 214 |
+
exif_mnote_data_apple_get_title(ExifMnoteData *md, unsigned int i) {
|
| 215 |
+
ExifMnoteDataApple *d = (ExifMnoteDataApple *) md;
|
| 216 |
+
|
| 217 |
+
if (!d || (d->count <= i)) {
|
| 218 |
+
return NULL;
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
return mnote_apple_tag_get_title(d->entries[i].tag);
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
static const char *
|
| 225 |
+
exif_mnote_data_apple_get_description(ExifMnoteData *md, unsigned int i) {
|
| 226 |
+
ExifMnoteDataApple *d = (ExifMnoteDataApple *) md;
|
| 227 |
+
|
| 228 |
+
if (!d || (d->count <= i)) {
|
| 229 |
+
return NULL;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
return mnote_apple_tag_get_description(d->entries[i].tag);
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
static char *
|
| 236 |
+
exif_mnote_data_apple_get_value(ExifMnoteData *md, unsigned int i, char *val, unsigned int maxlen) {
|
| 237 |
+
ExifMnoteDataApple *d = (ExifMnoteDataApple *) md;
|
| 238 |
+
|
| 239 |
+
if (!val || !d || (d->count <= i)) {
|
| 240 |
+
return NULL;
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
return mnote_apple_entry_get_value(&d->entries[i], val, maxlen);
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
int
|
| 247 |
+
exif_mnote_data_apple_identify(const ExifData *ed, const ExifEntry *e) {
|
| 248 |
+
int variant;
|
| 249 |
+
|
| 250 |
+
if (!strcmp((const char *) e->data, "Apple iOS")) {
|
| 251 |
+
variant = 1;
|
| 252 |
+
} else {
|
| 253 |
+
variant = 0;
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
return variant;
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
ExifMnoteData *
|
| 260 |
+
exif_mnote_data_apple_new(ExifMem *mem) {
|
| 261 |
+
ExifMnoteData *md;
|
| 262 |
+
|
| 263 |
+
/*printf("%s\n", __FUNCTION__);*/
|
| 264 |
+
|
| 265 |
+
if (!mem) {
|
| 266 |
+
return NULL;
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
md = exif_mem_alloc(mem, sizeof(ExifMnoteDataApple));
|
| 270 |
+
if (!md) {
|
| 271 |
+
return NULL;
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
exif_mnote_data_construct(md, mem);
|
| 275 |
+
|
| 276 |
+
md->methods.free = exif_mnote_data_apple_free;
|
| 277 |
+
md->methods.load = exif_mnote_data_apple_load;
|
| 278 |
+
md->methods.set_offset = exif_mnote_data_apple_set_offset;
|
| 279 |
+
md->methods.set_byte_order = exif_mnote_data_apple_set_byte_order;
|
| 280 |
+
md->methods.count = exif_mnote_data_apple_count;
|
| 281 |
+
md->methods.get_id = exif_mnote_data_apple_get_id;
|
| 282 |
+
md->methods.get_name = exif_mnote_data_apple_get_name;
|
| 283 |
+
md->methods.get_title = exif_mnote_data_apple_get_title;
|
| 284 |
+
md->methods.get_description = exif_mnote_data_apple_get_description;
|
| 285 |
+
md->methods.get_value = exif_mnote_data_apple_get_value;
|
| 286 |
+
|
| 287 |
+
return md;
|
| 288 |
+
}
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/apple/exif-mnote-data-apple.h
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* mnote-apple-data.h
|
| 2 |
+
*
|
| 3 |
+
* Copyright (c) 2018 zhanwang-sky <[email protected]>
|
| 4 |
+
*
|
| 5 |
+
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef __MNOTE_APPLE_CONTENT_H__
|
| 22 |
+
#define __MNOTE_APPLE_CONTENT_H__
|
| 23 |
+
|
| 24 |
+
#include <libexif/exif-byte-order.h>
|
| 25 |
+
#include <libexif/exif-data.h>
|
| 26 |
+
#include <libexif/exif-mem.h>
|
| 27 |
+
#include <libexif/exif-mnote-data-priv.h>
|
| 28 |
+
#include <libexif/apple/mnote-apple-entry.h>
|
| 29 |
+
|
| 30 |
+
typedef struct _ExifMnoteDataApple ExifMnoteDataApple;
|
| 31 |
+
|
| 32 |
+
struct _ExifMnoteDataApple {
|
| 33 |
+
ExifMnoteData parent;
|
| 34 |
+
ExifByteOrder order;
|
| 35 |
+
unsigned int offset;
|
| 36 |
+
MnoteAppleEntry *entries;
|
| 37 |
+
unsigned int count;
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
int exif_mnote_data_apple_identify(const ExifData *, const ExifEntry *);
|
| 41 |
+
|
| 42 |
+
ExifMnoteData *exif_mnote_data_apple_new(ExifMem *);
|
| 43 |
+
|
| 44 |
+
#endif /* __MNOTE_APPLE_CONTENT_H__ */
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/apple/mnote-apple-entry.c
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* mnote-apple-entry.c
|
| 2 |
+
*
|
| 3 |
+
* Copyright (c) 2018 zhanwang-sky <[email protected]>
|
| 4 |
+
*
|
| 5 |
+
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#include <config.h>
|
| 22 |
+
#include "mnote-apple-entry.h"
|
| 23 |
+
|
| 24 |
+
#include <stdio.h>
|
| 25 |
+
#include <stdlib.h>
|
| 26 |
+
#include <string.h>
|
| 27 |
+
|
| 28 |
+
#include <libexif/exif-entry.h>
|
| 29 |
+
#include <libexif/exif-format.h>
|
| 30 |
+
#include <libexif/exif-utils.h>
|
| 31 |
+
#include <libexif/i18n.h>
|
| 32 |
+
|
| 33 |
+
char *
|
| 34 |
+
mnote_apple_entry_get_value(MnoteAppleEntry *entry, char *v, unsigned int maxlen) {
|
| 35 |
+
ExifLong vl;
|
| 36 |
+
ExifSLong vsl;
|
| 37 |
+
ExifShort vs;
|
| 38 |
+
ExifSShort vss;
|
| 39 |
+
ExifRational vr;
|
| 40 |
+
ExifSRational vsr;
|
| 41 |
+
size_t size;
|
| 42 |
+
unsigned char *data;
|
| 43 |
+
|
| 44 |
+
if (!entry)
|
| 45 |
+
return NULL;
|
| 46 |
+
|
| 47 |
+
memset(v, 0, maxlen);
|
| 48 |
+
maxlen--;
|
| 49 |
+
|
| 50 |
+
size = entry->size;
|
| 51 |
+
data = entry->data;
|
| 52 |
+
switch (entry->tag) {
|
| 53 |
+
case MNOTE_APPLE_TAG_HDR:
|
| 54 |
+
if (size < 4) return NULL;
|
| 55 |
+
if (entry->format != EXIF_FORMAT_SLONG) return NULL;
|
| 56 |
+
if (entry->components != 1) return NULL;
|
| 57 |
+
|
| 58 |
+
vsl = exif_get_slong(data, entry->order);
|
| 59 |
+
snprintf(v, maxlen, "%d", vsl);
|
| 60 |
+
break;
|
| 61 |
+
case MNOTE_APPLE_TAG_IMAGE_UNIQUE_ID:
|
| 62 |
+
case MNOTE_APPLE_TAG_BURST_UUID:
|
| 63 |
+
case MNOTE_APPLE_TAG_MEDIA_GROUP_UUID:
|
| 64 |
+
if (entry->format != EXIF_FORMAT_ASCII) return NULL;
|
| 65 |
+
strncpy (v, (char *) data, MIN (maxlen-1, size));
|
| 66 |
+
v[MIN (maxlen-1, size)] = 0;
|
| 67 |
+
break;
|
| 68 |
+
default:
|
| 69 |
+
switch (entry->format) {
|
| 70 |
+
case EXIF_FORMAT_ASCII:
|
| 71 |
+
strncpy (v, (char *)data, MIN(maxlen, size));
|
| 72 |
+
break;
|
| 73 |
+
case EXIF_FORMAT_SHORT: {
|
| 74 |
+
size_t i, len = 0;
|
| 75 |
+
|
| 76 |
+
for(i=0; i<entry->components; i++) {
|
| 77 |
+
if (size < 2)
|
| 78 |
+
break;
|
| 79 |
+
if (len > maxlen)
|
| 80 |
+
break;
|
| 81 |
+
vs = exif_get_short (data, entry->order);
|
| 82 |
+
snprintf (v+len, maxlen-len, "%hu ", vs);
|
| 83 |
+
len = strlen(v);
|
| 84 |
+
data += 2;
|
| 85 |
+
size -= 2;
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
break;
|
| 89 |
+
case EXIF_FORMAT_SSHORT: {
|
| 90 |
+
size_t i, len = 0;
|
| 91 |
+
for(i=0; i<entry->components; i++) {
|
| 92 |
+
if (size < 2)
|
| 93 |
+
break;
|
| 94 |
+
if (len > maxlen)
|
| 95 |
+
break;
|
| 96 |
+
vss = exif_get_sshort (data, entry->order);
|
| 97 |
+
snprintf (v+len, maxlen-len, "%hi ", vss);
|
| 98 |
+
len = strlen(v);
|
| 99 |
+
data += 2;
|
| 100 |
+
size -= 2;
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
break;
|
| 104 |
+
case EXIF_FORMAT_LONG: {
|
| 105 |
+
size_t i, len = 0;
|
| 106 |
+
for(i=0; i<entry->components; i++) {
|
| 107 |
+
if (size < 4)
|
| 108 |
+
break;
|
| 109 |
+
if (len > maxlen)
|
| 110 |
+
break;
|
| 111 |
+
vl = exif_get_long (data, entry->order);
|
| 112 |
+
snprintf (v+len, maxlen-len, "%lu ", (long unsigned) vl);
|
| 113 |
+
len = strlen(v);
|
| 114 |
+
data += 4;
|
| 115 |
+
size -= 4;
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
break;
|
| 119 |
+
case EXIF_FORMAT_SLONG: {
|
| 120 |
+
size_t i, len = 0;
|
| 121 |
+
for(i=0; i<entry->components; i++) {
|
| 122 |
+
if (size < 4)
|
| 123 |
+
break;
|
| 124 |
+
if (len > maxlen)
|
| 125 |
+
break;
|
| 126 |
+
vsl = exif_get_slong (data, entry->order);
|
| 127 |
+
snprintf (v+len, maxlen-len, "%li ", (long int) vsl);
|
| 128 |
+
len = strlen(v);
|
| 129 |
+
data += 4;
|
| 130 |
+
size -= 4;
|
| 131 |
+
}
|
| 132 |
+
}
|
| 133 |
+
break;
|
| 134 |
+
case EXIF_FORMAT_RATIONAL:
|
| 135 |
+
vr = exif_get_rational (data, entry->order);
|
| 136 |
+
if (!vr.denominator) break;
|
| 137 |
+
snprintf (v, maxlen, "%2.4f", (double) vr.numerator /
|
| 138 |
+
vr.denominator);
|
| 139 |
+
break;
|
| 140 |
+
case EXIF_FORMAT_SRATIONAL:
|
| 141 |
+
vsr = exif_get_srational (data, entry->order);
|
| 142 |
+
if (!vsr.denominator) break;
|
| 143 |
+
snprintf (v, maxlen, "%2.4f", (double) vsr.numerator /
|
| 144 |
+
vsr.denominator);
|
| 145 |
+
break;
|
| 146 |
+
case EXIF_FORMAT_UNDEFINED:
|
| 147 |
+
default:
|
| 148 |
+
snprintf (v, maxlen, _("%i bytes unknown data"), entry->size);
|
| 149 |
+
break;
|
| 150 |
+
}
|
| 151 |
+
break;
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
return v;
|
| 155 |
+
}
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/apple/mnote-apple-entry.h
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* mnote-apple-entry.h
|
| 2 |
+
*
|
| 3 |
+
* Copyright (c) 2018 zhanwang-sky <[email protected]>
|
| 4 |
+
*
|
| 5 |
+
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef __MNOTE_APPLE_ENTRY_H__
|
| 22 |
+
#define __MNOTE_APPLE_ENTRY_H__
|
| 23 |
+
|
| 24 |
+
#include <libexif/exif-byte-order.h>
|
| 25 |
+
#include <libexif/exif-format.h>
|
| 26 |
+
#include <libexif/apple/mnote-apple-tag.h>
|
| 27 |
+
|
| 28 |
+
typedef struct _MnoteAppleEntry MnoteAppleEntry;
|
| 29 |
+
|
| 30 |
+
struct _MnoteAppleEntry {
|
| 31 |
+
MnoteAppleTag tag;
|
| 32 |
+
ExifFormat format;
|
| 33 |
+
unsigned long components;
|
| 34 |
+
unsigned char *data;
|
| 35 |
+
unsigned int size;
|
| 36 |
+
ExifByteOrder order;
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
char *mnote_apple_entry_get_value(MnoteAppleEntry *, char *, unsigned int);
|
| 40 |
+
|
| 41 |
+
#endif /* __MNOTE_APPLE_ENTRY_H__ */
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/apple/mnote-apple-tag.c
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* mnote-apple-tag.c:
|
| 2 |
+
*
|
| 3 |
+
* Copyright (c) 2018 zhanwang-sky <[email protected]>
|
| 4 |
+
*
|
| 5 |
+
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#include <config.h>
|
| 22 |
+
#include "mnote-apple-tag.h"
|
| 23 |
+
|
| 24 |
+
#include <libexif/i18n.h>
|
| 25 |
+
#include <libexif/exif-utils.h>
|
| 26 |
+
|
| 27 |
+
#include <stdlib.h>
|
| 28 |
+
|
| 29 |
+
static const struct {
|
| 30 |
+
MnoteAppleTag tag;
|
| 31 |
+
const char *name;
|
| 32 |
+
const char *title;
|
| 33 |
+
const char *description;
|
| 34 |
+
} table[] = {
|
| 35 |
+
#ifndef NO_VERBOSE_TAG_STRINGS
|
| 36 |
+
{MNOTE_APPLE_TAG_HDR, "HDR", N_("HDR Mode"), ""},
|
| 37 |
+
{MNOTE_APPLE_TAG_RUNTIME, "RUNTIME", N_("Runtime"), ""},
|
| 38 |
+
{MNOTE_APPLE_TAG_ACCELERATION_VECTOR, "ACCELERATION_VECTOR", N_("Acceleration Vector"), ""},
|
| 39 |
+
{MNOTE_APPLE_TAG_HDR, "HDR", N_("HDR"), ""},
|
| 40 |
+
{MNOTE_APPLE_TAG_BURST_UUID, "BURST_UUID", N_("Burst UUID"), ""},
|
| 41 |
+
{MNOTE_APPLE_TAG_MEDIA_GROUP_UUID, "MEDIA_GROUP_UUID", N_("Media Group UUID"), ""},
|
| 42 |
+
{MNOTE_APPLE_TAG_IMAGE_UNIQUE_ID, "IMAGE_UNIQUE_ID", N_("Image Unique ID"), ""},
|
| 43 |
+
#endif
|
| 44 |
+
{0, NULL, NULL, NULL}
|
| 45 |
+
};
|
| 46 |
+
|
| 47 |
+
const char *
|
| 48 |
+
mnote_apple_tag_get_name(MnoteAppleTag t) {
|
| 49 |
+
unsigned int i;
|
| 50 |
+
|
| 51 |
+
for (i = 0; i < sizeof (table) / sizeof (table[0]); i++) {
|
| 52 |
+
if (table[i].tag == t) {
|
| 53 |
+
return table[i].name;
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
return NULL;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
const char *
|
| 61 |
+
mnote_apple_tag_get_title(MnoteAppleTag t) {
|
| 62 |
+
unsigned int i;
|
| 63 |
+
|
| 64 |
+
(void) bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
|
| 65 |
+
for (i = 0; i < sizeof (table) / sizeof (table[0]); i++) {
|
| 66 |
+
if (table[i].tag == t) {
|
| 67 |
+
return _(table[i].title);
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
return NULL;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
const char *
|
| 75 |
+
mnote_apple_tag_get_description(MnoteAppleTag t) {
|
| 76 |
+
unsigned int i;
|
| 77 |
+
|
| 78 |
+
for (i = 0; i < sizeof (table) / sizeof (table[0]); i++) {
|
| 79 |
+
if (table[i].tag == t) {
|
| 80 |
+
if (!table[i].description || !*table[i].description) {
|
| 81 |
+
return "";
|
| 82 |
+
}
|
| 83 |
+
(void) bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
|
| 84 |
+
return _(table[i].description);
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
return NULL;
|
| 89 |
+
}
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/apple/mnote-apple-tag.h
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* mnote-apple-tag.h
|
| 2 |
+
*
|
| 3 |
+
* Copyright (c) 2018 zhanwang-sky <[email protected]>
|
| 4 |
+
*
|
| 5 |
+
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef __MNOTE_APPLE_TAG_H__
|
| 22 |
+
#define __MNOTE_APPLE_TAG_H__
|
| 23 |
+
|
| 24 |
+
#ifdef __cplusplus
|
| 25 |
+
extern "C" {
|
| 26 |
+
#endif /* __cplusplus */
|
| 27 |
+
|
| 28 |
+
enum _MnoteAppleTag {
|
| 29 |
+
MNOTE_APPLE_TAG_RUNTIME = 0x3,
|
| 30 |
+
MNOTE_APPLE_TAG_ACCELERATION_VECTOR = 0x9,
|
| 31 |
+
MNOTE_APPLE_TAG_HDR = 0xA,
|
| 32 |
+
MNOTE_APPLE_TAG_BURST_UUID = 0xB,
|
| 33 |
+
MNOTE_APPLE_TAG_MEDIA_GROUP_UUID = 0x11,
|
| 34 |
+
MNOTE_APPLE_TAG_IMAGE_UNIQUE_ID = 0x15,
|
| 35 |
+
};
|
| 36 |
+
typedef enum _MnoteAppleTag MnoteAppleTag;
|
| 37 |
+
|
| 38 |
+
const char *mnote_apple_tag_get_name(MnoteAppleTag);
|
| 39 |
+
const char *mnote_apple_tag_get_title(MnoteAppleTag);
|
| 40 |
+
const char *mnote_apple_tag_get_description(MnoteAppleTag);
|
| 41 |
+
|
| 42 |
+
#ifdef __cplusplus
|
| 43 |
+
}
|
| 44 |
+
#endif /* __cplusplus */
|
| 45 |
+
|
| 46 |
+
#endif /* __MNOTE_APPLE_TAG_H__ */
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/canon/.gitignore
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Makefile
|
| 2 |
+
Makefile.in
|
| 3 |
+
.deps
|
| 4 |
+
.libs
|
| 5 |
+
*.la
|
| 6 |
+
*.lo
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/canon/Makefile-files
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- Makefile -*-
|
| 2 |
+
noinst_LTLIBRARIES += libmnote-canon.la
|
| 3 |
+
libmnote_canon_la_SOURCES = \
|
| 4 |
+
canon/exif-mnote-data-canon.c canon/exif-mnote-data-canon.h \
|
| 5 |
+
canon/mnote-canon-entry.c canon/mnote-canon-entry.h \
|
| 6 |
+
canon/mnote-canon-tag.c canon/mnote-canon-tag.h
|
| 7 |
+
libmnote_canon_la_LIBADD = $(LTLIBINTL)
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/canon/exif-mnote-data-canon.c
ADDED
|
@@ -0,0 +1,433 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* exif-mnote-data-canon.c
|
| 2 |
+
*
|
| 3 |
+
* Copyright (c) 2002, 2003 Lutz Mueller <[email protected]>
|
| 4 |
+
* Copyright (c) 2003 Matthieu Castet <[email protected]>
|
| 5 |
+
*
|
| 6 |
+
* This library is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* This library is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with this library; if not, write to the
|
| 18 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 19 |
+
* Boston, MA 02110-1301 USA.
|
| 20 |
+
*/
|
| 21 |
+
|
| 22 |
+
#include <config.h>
|
| 23 |
+
#include "exif-mnote-data-canon.h"
|
| 24 |
+
|
| 25 |
+
#include <stdlib.h>
|
| 26 |
+
#include <stdio.h>
|
| 27 |
+
#include <string.h>
|
| 28 |
+
|
| 29 |
+
#include <libexif/exif-byte-order.h>
|
| 30 |
+
#include <libexif/exif-utils.h>
|
| 31 |
+
#include <libexif/exif-data.h>
|
| 32 |
+
|
| 33 |
+
#define CHECKOVERFLOW(offset,datasize,structsize) (( offset >= datasize) || (structsize > datasize) || (offset > datasize - structsize ))
|
| 34 |
+
|
| 35 |
+
/* Total size limit to prevent abuse by DoS */
|
| 36 |
+
#define FAILSAFE_SIZE_MAX 1000000L
|
| 37 |
+
|
| 38 |
+
static void
|
| 39 |
+
exif_mnote_data_canon_clear (ExifMnoteDataCanon *n)
|
| 40 |
+
{
|
| 41 |
+
ExifMnoteData *d = (ExifMnoteData *) n;
|
| 42 |
+
unsigned int i;
|
| 43 |
+
|
| 44 |
+
if (!n) return;
|
| 45 |
+
|
| 46 |
+
if (n->entries) {
|
| 47 |
+
for (i = 0; i < n->count; i++)
|
| 48 |
+
if (n->entries[i].data) {
|
| 49 |
+
exif_mem_free (d->mem, n->entries[i].data);
|
| 50 |
+
n->entries[i].data = NULL;
|
| 51 |
+
}
|
| 52 |
+
exif_mem_free (d->mem, n->entries);
|
| 53 |
+
n->entries = NULL;
|
| 54 |
+
n->count = 0;
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
static void
|
| 59 |
+
exif_mnote_data_canon_free (ExifMnoteData *n)
|
| 60 |
+
{
|
| 61 |
+
if (!n) return;
|
| 62 |
+
|
| 63 |
+
exif_mnote_data_canon_clear ((ExifMnoteDataCanon *) n);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
static void
|
| 67 |
+
exif_mnote_data_canon_get_tags (ExifMnoteDataCanon *dc, unsigned int n,
|
| 68 |
+
unsigned int *m, unsigned int *s)
|
| 69 |
+
{
|
| 70 |
+
unsigned int from = 0, to;
|
| 71 |
+
|
| 72 |
+
if (!dc || !m) return;
|
| 73 |
+
for (*m = 0; *m < dc->count; (*m)++) {
|
| 74 |
+
to = from + mnote_canon_entry_count_values (&dc->entries[*m]);
|
| 75 |
+
if (to > n) {
|
| 76 |
+
if (s) *s = n - from;
|
| 77 |
+
break;
|
| 78 |
+
}
|
| 79 |
+
from = to;
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
static char *
|
| 84 |
+
exif_mnote_data_canon_get_value (ExifMnoteData *note, unsigned int n, char *val, unsigned int maxlen)
|
| 85 |
+
{
|
| 86 |
+
ExifMnoteDataCanon *dc = (ExifMnoteDataCanon *) note;
|
| 87 |
+
unsigned int m, s;
|
| 88 |
+
|
| 89 |
+
if (!dc) return NULL;
|
| 90 |
+
exif_mnote_data_canon_get_tags (dc, n, &m, &s);
|
| 91 |
+
if (m >= dc->count) return NULL;
|
| 92 |
+
return mnote_canon_entry_get_value (&dc->entries[m], s, val, maxlen);
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
static void
|
| 96 |
+
exif_mnote_data_canon_set_byte_order (ExifMnoteData *d, ExifByteOrder o)
|
| 97 |
+
{
|
| 98 |
+
ExifByteOrder o_orig;
|
| 99 |
+
ExifMnoteDataCanon *n = (ExifMnoteDataCanon *) d;
|
| 100 |
+
unsigned int i;
|
| 101 |
+
|
| 102 |
+
if (!n) return;
|
| 103 |
+
|
| 104 |
+
o_orig = n->order;
|
| 105 |
+
n->order = o;
|
| 106 |
+
for (i = 0; i < n->count; i++) {
|
| 107 |
+
if (n->entries[i].components && (n->entries[i].size/n->entries[i].components < exif_format_get_size (n->entries[i].format)))
|
| 108 |
+
continue;
|
| 109 |
+
n->entries[i].order = o;
|
| 110 |
+
exif_array_set_byte_order (n->entries[i].format, n->entries[i].data,
|
| 111 |
+
n->entries[i].components, o_orig, o);
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
static void
|
| 116 |
+
exif_mnote_data_canon_set_offset (ExifMnoteData *n, unsigned int o)
|
| 117 |
+
{
|
| 118 |
+
if (n) ((ExifMnoteDataCanon *) n)->offset = o;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
static void
|
| 122 |
+
exif_mnote_data_canon_save (ExifMnoteData *ne,
|
| 123 |
+
unsigned char **buf, unsigned int *buf_size)
|
| 124 |
+
{
|
| 125 |
+
ExifMnoteDataCanon *n = (ExifMnoteDataCanon *) ne;
|
| 126 |
+
size_t i, o, s, doff;
|
| 127 |
+
unsigned char *t;
|
| 128 |
+
size_t ts;
|
| 129 |
+
|
| 130 |
+
if (!n || !buf || !buf_size) return;
|
| 131 |
+
|
| 132 |
+
/*
|
| 133 |
+
* Allocate enough memory for all entries and the number
|
| 134 |
+
* of entries.
|
| 135 |
+
*/
|
| 136 |
+
*buf_size = 2 + n->count * 12 + 4;
|
| 137 |
+
*buf = exif_mem_alloc (ne->mem, sizeof (char) * *buf_size);
|
| 138 |
+
if (!*buf) {
|
| 139 |
+
EXIF_LOG_NO_MEMORY(ne->log, "ExifMnoteCanon", *buf_size);
|
| 140 |
+
return;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
/* Save the number of entries */
|
| 144 |
+
exif_set_short (*buf, n->order, (ExifShort) n->count);
|
| 145 |
+
|
| 146 |
+
/* Save each entry */
|
| 147 |
+
for (i = 0; i < n->count; i++) {
|
| 148 |
+
o = 2 + i * 12;
|
| 149 |
+
exif_set_short (*buf + o + 0, n->order, (ExifShort) n->entries[i].tag);
|
| 150 |
+
exif_set_short (*buf + o + 2, n->order, (ExifShort) n->entries[i].format);
|
| 151 |
+
exif_set_long (*buf + o + 4, n->order,
|
| 152 |
+
n->entries[i].components);
|
| 153 |
+
o += 8;
|
| 154 |
+
s = exif_format_get_size (n->entries[i].format) *
|
| 155 |
+
n->entries[i].components;
|
| 156 |
+
if (s > 65536) {
|
| 157 |
+
/* Corrupt data: EXIF data size is limited to the
|
| 158 |
+
* maximum size of a JPEG segment (64 kb).
|
| 159 |
+
*/
|
| 160 |
+
continue;
|
| 161 |
+
}
|
| 162 |
+
if (s > 4) {
|
| 163 |
+
ts = *buf_size + s;
|
| 164 |
+
|
| 165 |
+
/* Ensure even offsets. Set padding bytes to 0. */
|
| 166 |
+
if (s & 1) ts += 1;
|
| 167 |
+
t = exif_mem_realloc (ne->mem, *buf,
|
| 168 |
+
sizeof (char) * ts);
|
| 169 |
+
if (!t) {
|
| 170 |
+
EXIF_LOG_NO_MEMORY(ne->log, "ExifMnoteCanon", ts);
|
| 171 |
+
return;
|
| 172 |
+
}
|
| 173 |
+
*buf = t;
|
| 174 |
+
*buf_size = ts;
|
| 175 |
+
doff = *buf_size - s;
|
| 176 |
+
if (s & 1) { doff--; *(*buf + *buf_size - 1) = '\0'; }
|
| 177 |
+
exif_set_long (*buf + o, n->order, n->offset + doff);
|
| 178 |
+
} else
|
| 179 |
+
doff = o;
|
| 180 |
+
|
| 181 |
+
/*
|
| 182 |
+
* Write the data. Fill unneeded bytes with 0. Do not
|
| 183 |
+
* crash if data is NULL.
|
| 184 |
+
*/
|
| 185 |
+
if (!n->entries[i].data) memset (*buf + doff, 0, s);
|
| 186 |
+
else memcpy (*buf + doff, n->entries[i].data, s);
|
| 187 |
+
if (s < 4) memset (*buf + doff + s, 0, (4 - s));
|
| 188 |
+
}
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
/* XXX
|
| 192 |
+
* FIXME: exif_mnote_data_canon_load() may fail and there is no
|
| 193 |
+
* semantics to express that.
|
| 194 |
+
* See bug #1054323 for details, especially the comment by liblit
|
| 195 |
+
* after it has supposedly been fixed:
|
| 196 |
+
*
|
| 197 |
+
* https://sourceforge.net/tracker/?func=detail&aid=1054323&group_id=12272&atid=112272
|
| 198 |
+
* Unfortunately, the "return" statements aren't commented at
|
| 199 |
+
* all, so it isn't trivial to find out what is a normal
|
| 200 |
+
* return, and what is a reaction to an error condition.
|
| 201 |
+
*/
|
| 202 |
+
|
| 203 |
+
static void
|
| 204 |
+
exif_mnote_data_canon_load (ExifMnoteData *ne,
|
| 205 |
+
const unsigned char *buf, unsigned int buf_size)
|
| 206 |
+
{
|
| 207 |
+
ExifMnoteDataCanon *n = (ExifMnoteDataCanon *) ne;
|
| 208 |
+
ExifShort c;
|
| 209 |
+
size_t i, tcount, o, datao;
|
| 210 |
+
long failsafe_size = 0;
|
| 211 |
+
|
| 212 |
+
if (!n || !buf || !buf_size) {
|
| 213 |
+
exif_log (ne->log, EXIF_LOG_CODE_CORRUPT_DATA,
|
| 214 |
+
"ExifMnoteCanon", "Short MakerNote");
|
| 215 |
+
return;
|
| 216 |
+
}
|
| 217 |
+
datao = 6 + n->offset;
|
| 218 |
+
if (CHECKOVERFLOW(datao, buf_size, 2)) {
|
| 219 |
+
exif_log (ne->log, EXIF_LOG_CODE_CORRUPT_DATA,
|
| 220 |
+
"ExifMnoteCanon", "Short MakerNote");
|
| 221 |
+
return;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
/* Read the number of tags */
|
| 225 |
+
c = exif_get_short (buf + datao, n->order);
|
| 226 |
+
datao += 2;
|
| 227 |
+
/* Just use an arbitrary max tag limit here to avoid needing to much memory or time. There are 24 named tags currently.
|
| 228 |
+
* The format allows specifying the same range of memory as often as it can, so this multiplies quickly. */
|
| 229 |
+
if (c > 100) {
|
| 230 |
+
exif_log (ne->log, EXIF_LOG_CODE_CORRUPT_DATA, "ExifMnoteCanon", "Too much tags (%d) in Canon MakerNote", c);
|
| 231 |
+
return;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
/* Remove any old entries */
|
| 235 |
+
exif_mnote_data_canon_clear (n);
|
| 236 |
+
|
| 237 |
+
/* Reserve enough space for all the possible MakerNote tags */
|
| 238 |
+
n->entries = exif_mem_alloc (ne->mem, sizeof (MnoteCanonEntry) * c);
|
| 239 |
+
if (!n->entries) {
|
| 240 |
+
EXIF_LOG_NO_MEMORY(ne->log, "ExifMnoteCanon", sizeof (MnoteCanonEntry) * c);
|
| 241 |
+
return;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
/* Parse the entries */
|
| 245 |
+
tcount = 0;
|
| 246 |
+
for (i = c, o = datao; i; --i, o += 12) {
|
| 247 |
+
size_t s;
|
| 248 |
+
|
| 249 |
+
memset(&n->entries[tcount], 0, sizeof(MnoteCanonEntry));
|
| 250 |
+
if (CHECKOVERFLOW(o,buf_size,12)) {
|
| 251 |
+
exif_log (ne->log, EXIF_LOG_CODE_CORRUPT_DATA,
|
| 252 |
+
"ExifMnoteCanon", "Short MakerNote");
|
| 253 |
+
break;
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
n->entries[tcount].tag = exif_get_short (buf + o, n->order);
|
| 257 |
+
n->entries[tcount].format = exif_get_short (buf + o + 2, n->order);
|
| 258 |
+
n->entries[tcount].components = exif_get_long (buf + o + 4, n->order);
|
| 259 |
+
n->entries[tcount].order = n->order;
|
| 260 |
+
|
| 261 |
+
exif_log (ne->log, EXIF_LOG_CODE_DEBUG, "ExifMnoteCanon",
|
| 262 |
+
"Loading entry 0x%x ('%s')...", n->entries[tcount].tag,
|
| 263 |
+
mnote_canon_tag_get_name (n->entries[tcount].tag));
|
| 264 |
+
|
| 265 |
+
/* Check if we overflow the multiplication. Use buf_size as the max size for integer overflow detection,
|
| 266 |
+
* we will check the buffer sizes closer later. */
|
| 267 |
+
if ( exif_format_get_size (n->entries[tcount].format) &&
|
| 268 |
+
buf_size / exif_format_get_size (n->entries[tcount].format) < n->entries[tcount].components
|
| 269 |
+
) {
|
| 270 |
+
exif_log (ne->log, EXIF_LOG_CODE_CORRUPT_DATA,
|
| 271 |
+
"ExifMnoteCanon", "Tag size overflow detected (%u * %lu)", exif_format_get_size (n->entries[tcount].format), n->entries[tcount].components);
|
| 272 |
+
continue;
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
/*
|
| 276 |
+
* Size? If bigger than 4 bytes, the actual data is not
|
| 277 |
+
* in the entry but somewhere else (offset).
|
| 278 |
+
*/
|
| 279 |
+
s = exif_format_get_size (n->entries[tcount].format) *
|
| 280 |
+
n->entries[tcount].components;
|
| 281 |
+
n->entries[tcount].size = s;
|
| 282 |
+
if (!s) {
|
| 283 |
+
exif_log (ne->log, EXIF_LOG_CODE_CORRUPT_DATA,
|
| 284 |
+
"ExifMnoteCanon",
|
| 285 |
+
"Invalid zero-length tag size");
|
| 286 |
+
continue;
|
| 287 |
+
|
| 288 |
+
} else {
|
| 289 |
+
size_t dataofs = o + 8;
|
| 290 |
+
if (s > 4) dataofs = exif_get_long (buf + dataofs, n->order) + 6;
|
| 291 |
+
|
| 292 |
+
if (CHECKOVERFLOW(dataofs, buf_size, s)) {
|
| 293 |
+
exif_log (ne->log, EXIF_LOG_CODE_DEBUG,
|
| 294 |
+
"ExifMnoteCanon",
|
| 295 |
+
"Tag data past end of buffer (%u > %u)",
|
| 296 |
+
(unsigned)(dataofs + s), buf_size);
|
| 297 |
+
continue;
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
n->entries[tcount].data = exif_mem_alloc (ne->mem, s);
|
| 301 |
+
if (!n->entries[tcount].data) {
|
| 302 |
+
EXIF_LOG_NO_MEMORY(ne->log, "ExifMnoteCanon", s);
|
| 303 |
+
continue;
|
| 304 |
+
}
|
| 305 |
+
memcpy (n->entries[tcount].data, buf + dataofs, s);
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
/* Track the size of decoded tag data. A malicious file could
|
| 309 |
+
* be crafted to cause extremely large values here without
|
| 310 |
+
* tripping any buffer range checks. This is especially bad
|
| 311 |
+
* with the libexif representation of Canon MakerNotes because
|
| 312 |
+
* some arrays are turned into individual tags that the
|
| 313 |
+
* application must loop around. */
|
| 314 |
+
failsafe_size += mnote_canon_entry_count_values(&n->entries[tcount]);
|
| 315 |
+
|
| 316 |
+
if (failsafe_size > FAILSAFE_SIZE_MAX) {
|
| 317 |
+
/* Abort if the total size of the data in the tags extraordinarily large, */
|
| 318 |
+
exif_mem_free (ne->mem, n->entries[tcount].data);
|
| 319 |
+
exif_log (ne->log, EXIF_LOG_CODE_CORRUPT_DATA,
|
| 320 |
+
"ExifMnoteCanon", "Failsafe tag size overflow (%lu > %ld)",
|
| 321 |
+
failsafe_size, FAILSAFE_SIZE_MAX);
|
| 322 |
+
break;
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
/* Tag was successfully parsed */
|
| 326 |
+
++tcount;
|
| 327 |
+
}
|
| 328 |
+
/* Store the count of successfully parsed tags */
|
| 329 |
+
n->count = tcount;
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
static unsigned int
|
| 333 |
+
exif_mnote_data_canon_count (ExifMnoteData *n)
|
| 334 |
+
{
|
| 335 |
+
ExifMnoteDataCanon *dc = (ExifMnoteDataCanon *) n;
|
| 336 |
+
unsigned int i, c;
|
| 337 |
+
|
| 338 |
+
for (i = c = 0; dc && (i < dc->count); i++)
|
| 339 |
+
c += mnote_canon_entry_count_values (&dc->entries[i]);
|
| 340 |
+
return c;
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
static unsigned int
|
| 344 |
+
exif_mnote_data_canon_get_id (ExifMnoteData *d, unsigned int i)
|
| 345 |
+
{
|
| 346 |
+
ExifMnoteDataCanon *dc = (ExifMnoteDataCanon *) d;
|
| 347 |
+
unsigned int m;
|
| 348 |
+
|
| 349 |
+
if (!dc) return 0;
|
| 350 |
+
exif_mnote_data_canon_get_tags (dc, i, &m, NULL);
|
| 351 |
+
if (m >= dc->count) return 0;
|
| 352 |
+
return dc->entries[m].tag;
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
static const char *
|
| 356 |
+
exif_mnote_data_canon_get_name (ExifMnoteData *note, unsigned int i)
|
| 357 |
+
{
|
| 358 |
+
ExifMnoteDataCanon *dc = (ExifMnoteDataCanon *) note;
|
| 359 |
+
unsigned int m, s;
|
| 360 |
+
|
| 361 |
+
if (!dc) return NULL;
|
| 362 |
+
exif_mnote_data_canon_get_tags (dc, i, &m, &s);
|
| 363 |
+
if (m >= dc->count) return NULL;
|
| 364 |
+
return mnote_canon_tag_get_name_sub (dc->entries[m].tag, s, dc->options);
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
static const char *
|
| 368 |
+
exif_mnote_data_canon_get_title (ExifMnoteData *note, unsigned int i)
|
| 369 |
+
{
|
| 370 |
+
ExifMnoteDataCanon *dc = (ExifMnoteDataCanon *) note;
|
| 371 |
+
unsigned int m, s;
|
| 372 |
+
|
| 373 |
+
if (!dc) return NULL;
|
| 374 |
+
exif_mnote_data_canon_get_tags (dc, i, &m, &s);
|
| 375 |
+
if (m >= dc->count) return NULL;
|
| 376 |
+
return mnote_canon_tag_get_title_sub (dc->entries[m].tag, s, dc->options);
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
static const char *
|
| 380 |
+
exif_mnote_data_canon_get_description (ExifMnoteData *note, unsigned int i)
|
| 381 |
+
{
|
| 382 |
+
ExifMnoteDataCanon *dc = (ExifMnoteDataCanon *) note;
|
| 383 |
+
unsigned int m;
|
| 384 |
+
|
| 385 |
+
if (!dc) return NULL;
|
| 386 |
+
exif_mnote_data_canon_get_tags (dc, i, &m, NULL);
|
| 387 |
+
if (m >= dc->count) return NULL;
|
| 388 |
+
return mnote_canon_tag_get_description (dc->entries[m].tag);
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
int
|
| 392 |
+
exif_mnote_data_canon_identify (const ExifData *ed, const ExifEntry *e)
|
| 393 |
+
{
|
| 394 |
+
char value[8];
|
| 395 |
+
|
| 396 |
+
(void) e; /* unused */
|
| 397 |
+
ExifEntry *em = exif_data_get_entry (ed, EXIF_TAG_MAKE);
|
| 398 |
+
if (!em)
|
| 399 |
+
return 0;
|
| 400 |
+
return !strcmp (exif_entry_get_value (em, value, sizeof (value)), "Canon");
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
ExifMnoteData *
|
| 404 |
+
exif_mnote_data_canon_new (ExifMem *mem, ExifDataOption o)
|
| 405 |
+
{
|
| 406 |
+
ExifMnoteData *d;
|
| 407 |
+
ExifMnoteDataCanon *dc;
|
| 408 |
+
|
| 409 |
+
if (!mem) return NULL;
|
| 410 |
+
|
| 411 |
+
d = exif_mem_alloc (mem, sizeof (ExifMnoteDataCanon));
|
| 412 |
+
if (!d)
|
| 413 |
+
return NULL;
|
| 414 |
+
|
| 415 |
+
exif_mnote_data_construct (d, mem);
|
| 416 |
+
|
| 417 |
+
/* Set up function pointers */
|
| 418 |
+
d->methods.free = exif_mnote_data_canon_free;
|
| 419 |
+
d->methods.set_byte_order = exif_mnote_data_canon_set_byte_order;
|
| 420 |
+
d->methods.set_offset = exif_mnote_data_canon_set_offset;
|
| 421 |
+
d->methods.load = exif_mnote_data_canon_load;
|
| 422 |
+
d->methods.save = exif_mnote_data_canon_save;
|
| 423 |
+
d->methods.count = exif_mnote_data_canon_count;
|
| 424 |
+
d->methods.get_id = exif_mnote_data_canon_get_id;
|
| 425 |
+
d->methods.get_name = exif_mnote_data_canon_get_name;
|
| 426 |
+
d->methods.get_title = exif_mnote_data_canon_get_title;
|
| 427 |
+
d->methods.get_description = exif_mnote_data_canon_get_description;
|
| 428 |
+
d->methods.get_value = exif_mnote_data_canon_get_value;
|
| 429 |
+
|
| 430 |
+
dc = (ExifMnoteDataCanon*)d;
|
| 431 |
+
dc->options = o;
|
| 432 |
+
return d;
|
| 433 |
+
}
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/canon/exif-mnote-data-canon.h
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* exif-mnote-data-canon.h
|
| 2 |
+
*
|
| 3 |
+
* Copyright (c) 2002, 2003 Lutz Mueller <[email protected]>
|
| 4 |
+
*
|
| 5 |
+
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef __EXIF_MNOTE_DATA_CANON_H__
|
| 22 |
+
#define __EXIF_MNOTE_DATA_CANON_H__
|
| 23 |
+
|
| 24 |
+
#include <libexif/exif-byte-order.h>
|
| 25 |
+
#include <libexif/exif-mnote-data.h>
|
| 26 |
+
#include <libexif/exif-mnote-data-priv.h>
|
| 27 |
+
#include <libexif/exif-mem.h>
|
| 28 |
+
#include <libexif/exif-data.h>
|
| 29 |
+
|
| 30 |
+
typedef struct _ExifMnoteDataCanon ExifMnoteDataCanon;
|
| 31 |
+
|
| 32 |
+
#include <libexif/canon/mnote-canon-entry.h>
|
| 33 |
+
|
| 34 |
+
struct _ExifMnoteDataCanon {
|
| 35 |
+
ExifMnoteData parent;
|
| 36 |
+
|
| 37 |
+
MnoteCanonEntry *entries;
|
| 38 |
+
unsigned int count;
|
| 39 |
+
|
| 40 |
+
ExifByteOrder order;
|
| 41 |
+
unsigned int offset;
|
| 42 |
+
|
| 43 |
+
ExifDataOption options;
|
| 44 |
+
};
|
| 45 |
+
|
| 46 |
+
/*! Detect if MakerNote is recognized as one handled by the Canon module.
|
| 47 |
+
*
|
| 48 |
+
* \param[in] ed image #ExifData to identify as as a Canon type
|
| 49 |
+
* \param[in] e #ExifEntry for EXIF_TAG_MAKER_NOTE, from within ed but
|
| 50 |
+
* duplicated here for convenience
|
| 51 |
+
* \return 0 if not recognized, nonzero if recognized. The specific nonzero
|
| 52 |
+
* value returned may identify a subtype unique within this module.
|
| 53 |
+
*/
|
| 54 |
+
int exif_mnote_data_canon_identify (const ExifData *ed, const ExifEntry *e);
|
| 55 |
+
|
| 56 |
+
ExifMnoteData *exif_mnote_data_canon_new (ExifMem *mem, ExifDataOption o);
|
| 57 |
+
|
| 58 |
+
#endif /* __EXIF_MNOTE_DATA_CANON_H__ */
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/canon/mnote-canon-entry.c
ADDED
|
@@ -0,0 +1,822 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* mnote-canon-entry.c
|
| 2 |
+
*
|
| 3 |
+
* Copyright (c) 2002 Lutz Mueller <[email protected]>
|
| 4 |
+
* Copyright (c) 2003 Matthieu Castet <[email protected]>
|
| 5 |
+
*
|
| 6 |
+
* This library is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* This library is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with this library; if not, write to the
|
| 18 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 19 |
+
* Boston, MA 02110-1301 USA.
|
| 20 |
+
*/
|
| 21 |
+
|
| 22 |
+
#include "config.h"
|
| 23 |
+
#include "mnote-canon-entry.h"
|
| 24 |
+
|
| 25 |
+
#include <stdio.h>
|
| 26 |
+
#include <stdlib.h>
|
| 27 |
+
#include <string.h>
|
| 28 |
+
#include <math.h>
|
| 29 |
+
|
| 30 |
+
#include <libexif/exif-format.h>
|
| 31 |
+
#include <libexif/exif-utils.h>
|
| 32 |
+
#include <libexif/i18n.h>
|
| 33 |
+
|
| 34 |
+
#define CF(format,target,v,maxlen) \
|
| 35 |
+
{ \
|
| 36 |
+
if (format != target) { \
|
| 37 |
+
snprintf (v, maxlen, \
|
| 38 |
+
_("Invalid format '%s', " \
|
| 39 |
+
"expected '%s'."), \
|
| 40 |
+
exif_format_get_name (format), \
|
| 41 |
+
exif_format_get_name (target)); \
|
| 42 |
+
break; \
|
| 43 |
+
} \
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
#define CC(number,target,v,maxlen) \
|
| 47 |
+
{ \
|
| 48 |
+
if (number != target) { \
|
| 49 |
+
snprintf (v, maxlen, \
|
| 50 |
+
_("Invalid number of components (%i, " \
|
| 51 |
+
"expected %i)."), (int) number, (int) target); \
|
| 52 |
+
break; \
|
| 53 |
+
} \
|
| 54 |
+
}
|
| 55 |
+
#define CC2(number,t1,t2,v,maxlen) \
|
| 56 |
+
{ \
|
| 57 |
+
if ((number != t1) && (number != t2)) { \
|
| 58 |
+
snprintf (v, maxlen, \
|
| 59 |
+
_("Invalid number of components (%i, " \
|
| 60 |
+
"expected %i or %i)."), (int) number, \
|
| 61 |
+
(int) t1, (int) t2); \
|
| 62 |
+
break; \
|
| 63 |
+
} \
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
#define UNDEFINED 0xFF
|
| 67 |
+
|
| 68 |
+
static const struct canon_entry_table_t {
|
| 69 |
+
unsigned int subtag;
|
| 70 |
+
ExifShort value;
|
| 71 |
+
const char *name;
|
| 72 |
+
} entries_settings_1 [] = {
|
| 73 |
+
#ifndef NO_VERBOSE_TAG_DATA
|
| 74 |
+
{ 0, 1, N_("Macro")},
|
| 75 |
+
{ 0, 2, N_("Normal")},
|
| 76 |
+
{ 2, 1, N_("Economy")},
|
| 77 |
+
{ 2, 2, N_("Normal")},
|
| 78 |
+
{ 2, 3, N_("Fine")},
|
| 79 |
+
{ 2, 4, N_("RAW")},
|
| 80 |
+
{ 2, 5, N_("Superfine")},
|
| 81 |
+
{ 3, 0, N_("Off")},
|
| 82 |
+
{ 3, 1, N_("Auto")},
|
| 83 |
+
{ 3, 2, N_("On")},
|
| 84 |
+
{ 3, 3, N_("Red-eye reduction")},
|
| 85 |
+
{ 3, 4, N_("Slow synchro")},
|
| 86 |
+
{ 3, 5, N_("Auto, red-eye reduction")},
|
| 87 |
+
{ 3, 6, N_("On, red-eye reduction")},
|
| 88 |
+
{ 3, 16, N_("External flash")},
|
| 89 |
+
{ 4, 0, N_("Single")},
|
| 90 |
+
{ 4, 1, N_("Continuous")},
|
| 91 |
+
{ 4, 2, N_("Movie")},
|
| 92 |
+
{ 4, 3, N_("Continuous, speed priority")},
|
| 93 |
+
{ 4, 4, N_("Continuous, low")},
|
| 94 |
+
{ 4, 5, N_("Continuous, high")},
|
| 95 |
+
{ 6, 0, N_("One-shot AF")},
|
| 96 |
+
{ 6, 1, N_("AI servo AF")},
|
| 97 |
+
{ 6, 2, N_("AI focus AF")},
|
| 98 |
+
{ 6, 3, N_("Manual focus")},
|
| 99 |
+
{ 6, 4, N_("Single")},
|
| 100 |
+
{ 6, 5, N_("Continuous")},
|
| 101 |
+
{ 6, 6, N_("Manual focus")},
|
| 102 |
+
{ 6, 16, N_("Pan focus")},
|
| 103 |
+
{ 8, 1, N_("JPEG")},
|
| 104 |
+
{ 8, 2, N_("CRW+THM")},
|
| 105 |
+
{ 8, 3, N_("AVI+THM")},
|
| 106 |
+
{ 8, 4, N_("TIF")},
|
| 107 |
+
{ 8, 5, N_("TIF+JPEG")},
|
| 108 |
+
{ 8, 6, N_("CR2")},
|
| 109 |
+
{ 8, 7, N_("CR2+JPEG")},
|
| 110 |
+
{ 9, 0, N_("Large")},
|
| 111 |
+
{ 9, 1, N_("Medium")},
|
| 112 |
+
{ 9, 2, N_("Small")},
|
| 113 |
+
{ 9, 5, N_("Medium 1")},
|
| 114 |
+
{ 9, 6, N_("Medium 2")},
|
| 115 |
+
{ 9, 7, N_("Medium 3")},
|
| 116 |
+
{ 9, 8, N_("Postcard")},
|
| 117 |
+
{ 9, 9, N_("Widescreen")},
|
| 118 |
+
{10, 0, N_("Full auto")},
|
| 119 |
+
{10, 1, N_("Manual")},
|
| 120 |
+
{10, 2, N_("Landscape")},
|
| 121 |
+
{10, 3, N_("Fast shutter")},
|
| 122 |
+
{10, 4, N_("Slow shutter")},
|
| 123 |
+
{10, 5, N_("Night")},
|
| 124 |
+
{10, 6, N_("Grayscale")},
|
| 125 |
+
{10, 7, N_("Sepia")},
|
| 126 |
+
{10, 8, N_("Portrait")},
|
| 127 |
+
{10, 9, N_("Sports")},
|
| 128 |
+
{10, 10, N_("Macro")},
|
| 129 |
+
{10, 11, N_("Black & white")},
|
| 130 |
+
{10, 12, N_("Pan focus")},
|
| 131 |
+
{10, 13, N_("Vivid")},
|
| 132 |
+
{10, 14, N_("Neutral")},
|
| 133 |
+
{10, 15, N_("Flash off")},
|
| 134 |
+
{10, 16, N_("Long shutter")},
|
| 135 |
+
{10, 17, N_("Super macro")},
|
| 136 |
+
{10, 18, N_("Foliage")},
|
| 137 |
+
{10, 19, N_("Indoor")},
|
| 138 |
+
{10, 20, N_("Fireworks")},
|
| 139 |
+
{10, 21, N_("Beach")},
|
| 140 |
+
{10, 22, N_("Underwater")},
|
| 141 |
+
{10, 23, N_("Snow")},
|
| 142 |
+
{10, 24, N_("Kids & pets")},
|
| 143 |
+
{10, 25, N_("Night snapshot")},
|
| 144 |
+
{10, 26, N_("Digital macro")},
|
| 145 |
+
{10, 27, N_("My colors")},
|
| 146 |
+
{10, 28, N_("Still image")},
|
| 147 |
+
{10, 30, N_("Color accent")},
|
| 148 |
+
{10, 31, N_("Color swap")},
|
| 149 |
+
{10, 32, N_("Aquarium")},
|
| 150 |
+
{10, 33, N_("ISO 3200")},
|
| 151 |
+
{11, 0, N_("None")},
|
| 152 |
+
{11, 1, N_("2x")},
|
| 153 |
+
{11, 2, N_("4x")},
|
| 154 |
+
{11, 3, N_("Other")},
|
| 155 |
+
{12, 0x0000, N_("Normal")},
|
| 156 |
+
{12, 0x0001, N_("High")},
|
| 157 |
+
{12, 0xffff, N_("Low")},
|
| 158 |
+
{13, 0x0000, N_("Normal")},
|
| 159 |
+
{13, 0x0001, N_("High")},
|
| 160 |
+
{13, 0xffff, N_("Low")},
|
| 161 |
+
{14, 0x0000, N_("Normal")},
|
| 162 |
+
{14, 0x0001, N_("High")},
|
| 163 |
+
{14, 0xffff, N_("Low")},
|
| 164 |
+
{15, 14, N_("Auto high")},
|
| 165 |
+
{15, 15, N_("Auto")},
|
| 166 |
+
{15, 16, N_("50")},
|
| 167 |
+
{15, 17, N_("100")},
|
| 168 |
+
{15, 18, N_("200")},
|
| 169 |
+
{15, 19, N_("400")},
|
| 170 |
+
{15, 20, N_("800")},
|
| 171 |
+
{16, 0, N_("Default")},
|
| 172 |
+
{16, 1, N_("Spot")},
|
| 173 |
+
{16, 2, N_("Average")},
|
| 174 |
+
{16, 3, N_("Evaluative")},
|
| 175 |
+
{16, 4, N_("Partial")},
|
| 176 |
+
{16, 5, N_("Center-weighted average")},
|
| 177 |
+
{17, 0, N_("Manual")},
|
| 178 |
+
{17, 1, N_("Auto")},
|
| 179 |
+
{17, 2, N_("Not known")},
|
| 180 |
+
{17, 3, N_("Macro")},
|
| 181 |
+
{17, 4, N_("Very close")},
|
| 182 |
+
{17, 5, N_("Close")},
|
| 183 |
+
{17, 6, N_("Middle range")},
|
| 184 |
+
{17, 7, N_("Far range")},
|
| 185 |
+
{17, 8, N_("Pan focus")},
|
| 186 |
+
{17, 9, N_("Super macro")},
|
| 187 |
+
{17, 10, N_("Infinity")},
|
| 188 |
+
{18, 0x2005, N_("Manual AF point selection")},
|
| 189 |
+
{18, 0x3000, N_("None (MF)")},
|
| 190 |
+
{18, 0x3001, N_("Auto-selected")},
|
| 191 |
+
{18, 0x3002, N_("Right")},
|
| 192 |
+
{18, 0x3003, N_("Center")},
|
| 193 |
+
{18, 0x3004, N_("Left")},
|
| 194 |
+
{18, 0x4001, N_("Auto AF point selection")},
|
| 195 |
+
{19, 0, N_("Easy shooting")},
|
| 196 |
+
{19, 1, N_("Program")},
|
| 197 |
+
{19, 2, N_("Tv-priority")},
|
| 198 |
+
{19, 3, N_("Av-priority")},
|
| 199 |
+
{19, 4, N_("Manual")},
|
| 200 |
+
{19, 5, N_("A-DEP")},
|
| 201 |
+
{19, 6, N_("M-DEP")},
|
| 202 |
+
{21, 1, N_("Canon EF 50mm f/1.8")},
|
| 203 |
+
{21, 2, N_("Canon EF 28mm f/2.8")},
|
| 204 |
+
{21, 4, N_("Sigma UC Zoom 35-135mm f/4-5.6")},
|
| 205 |
+
{21, 6, N_("Tokina AF193-2 19-35mm f/3.5-4.5")},
|
| 206 |
+
{21, 7, N_("Canon EF 100-300mm F5.6L")},
|
| 207 |
+
{21, 10, N_("Sigma 50mm f/2.8 EX or 28mm f/1.8")},
|
| 208 |
+
{21, 11, N_("Canon EF 35mm f/2")},
|
| 209 |
+
{21, 13, N_("Canon EF 15mm f/2.8")},
|
| 210 |
+
{21, 21, N_("Canon EF 80-200mm f/2.8L")},
|
| 211 |
+
{21, 22, N_("Tokina AT-X280AF PRO 28-80mm F2.8 Aspherical")},
|
| 212 |
+
{21, 26, N_("Cosina 100mm f/3.5 Macro AF")},
|
| 213 |
+
{21, 28, N_("Tamron AF Aspherical 28-200mm f/3.8-5.6")},
|
| 214 |
+
{21, 29, N_("Canon EF 50mm f/1.8 MkII")},
|
| 215 |
+
{21, 31, N_("Tamron SP AF 300mm f/2.8 LD IF")},
|
| 216 |
+
{21, 32, N_("Canon EF 24mm f/2.8 or Sigma 15mm f/2.8 EX Fisheye")},
|
| 217 |
+
{21, 37, N_("Canon EF 35-80mm f/4-5.6")},
|
| 218 |
+
{21, 39, N_("Canon EF 75-300mm f/4-5.6")},
|
| 219 |
+
{21, 40, N_("Canon EF 28-80mm f/3.5-5.6")},
|
| 220 |
+
{21, 43, N_("Canon EF 28-105mm f/4-5.6")},
|
| 221 |
+
{21, 45, N_("Canon EF-S 18-55mm f/3.5-5.6")},
|
| 222 |
+
{21, 52, N_("Canon EF-S 18-55mm f/3.5-5.6 IS II")},
|
| 223 |
+
{21, 124, N_("Canon MP-E 65mm f/2.8 1-5x Macro Photo")},
|
| 224 |
+
{21, 125, N_("Canon TS-E 24mm f/3.5L")},
|
| 225 |
+
{21, 126, N_("Canon TS-E 45mm f/2.8")},
|
| 226 |
+
{21, 127, N_("Canon TS-E 90mm f/2.8")},
|
| 227 |
+
{21, 130, N_("Canon EF 50mm f/1.0L")},
|
| 228 |
+
{21, 131, N_("Sigma 17-35mm f2.8-4 EX Aspherical HSM")},
|
| 229 |
+
{21, 134, N_("Canon EF 600mm f/4L IS")},
|
| 230 |
+
{21, 135, N_("Canon EF 200mm f/1.8L")},
|
| 231 |
+
{21, 136, N_("Canon EF 300mm f/2.8L")},
|
| 232 |
+
{21, 137, N_("Canon EF 85mm f/1.2L")},
|
| 233 |
+
{21, 139, N_("Canon EF 400mm f/2.8L")},
|
| 234 |
+
{21, 141, N_("Canon EF 500mm f/4.5L")},
|
| 235 |
+
{21, 142, N_("Canon EF 300mm f/2.8L IS")},
|
| 236 |
+
{21, 143, N_("Canon EF 500mm f/4L IS")},
|
| 237 |
+
{21, 149, N_("Canon EF 100mm f/2")},
|
| 238 |
+
{21, 150, N_("Sigma 20mm EX f/1.8")},
|
| 239 |
+
{21, 151, N_("Canon EF 200mm f/2.8L")},
|
| 240 |
+
{21, 152, N_("Sigma 10-20mm F4-5.6 or 12-24mm f/4.5-5.6 or 14mm f/2.8")},
|
| 241 |
+
{21, 153, N_("Canon EF 35-350mm f/3.5-5.6L")},
|
| 242 |
+
{21, 155, N_("Canon EF 85mm f/1.8 USM")},
|
| 243 |
+
{21, 156, N_("Canon EF 28-105mm f/3.5-4.5 USM")},
|
| 244 |
+
{21, 160, N_("Canon EF 20-35mm f/3.5-4.5 USM")},
|
| 245 |
+
{21, 161, N_("Canon EF 28-70mm f/2.8L or Sigma 24-70mm EX f/2.8")},
|
| 246 |
+
{21, 165, N_("Canon EF 70-200mm f/2.8 L")},
|
| 247 |
+
{21, 166, N_("Canon EF 70-200mm f/2.8 L + x1.4")},
|
| 248 |
+
{21, 167, N_("Canon EF 70-200mm f/2.8 L + x2")},
|
| 249 |
+
{21, 168, N_("Canon EF 28mm f/1.8 USM")},
|
| 250 |
+
{21, 169, N_("Sigma 15-30mm f/3.5-4.5 EX DG Aspherical")},
|
| 251 |
+
{21, 170, N_("Canon EF 200mm f/2.8L II")},
|
| 252 |
+
{21, 173, N_("Canon EF 180mm Macro f/3.5L or Sigma 180mm EX HSM Macro f/3.5")},
|
| 253 |
+
{21, 174, N_("Canon EF 135mm f/2L")},
|
| 254 |
+
{21, 176, N_("Canon EF 24-85mm f/3.5-4.5 USM")},
|
| 255 |
+
{21, 177, N_("Canon EF 300mm f/4L IS")},
|
| 256 |
+
{21, 178, N_("Canon EF 28-135mm f/3.5-5.6 IS")},
|
| 257 |
+
{21, 180, N_("Canon EF 35mm f/1.4L")},
|
| 258 |
+
{21, 181, N_("Canon EF 100-400mm f/4.5-5.6L IS + x1.4")},
|
| 259 |
+
{21, 182, N_("Canon EF 100-400mm f/4.5-5.6L IS + x2")},
|
| 260 |
+
{21, 183, N_("Canon EF 100-400mm f/4.5-5.6L IS")},
|
| 261 |
+
{21, 184, N_("Canon EF 400mm f/2.8L + x2")},
|
| 262 |
+
{21, 186, N_("Canon EF 70-200mm f/4L")},
|
| 263 |
+
{21, 190, N_("Canon EF 100mm f/2.8 Macro")},
|
| 264 |
+
{21, 191, N_("Canon EF 400mm f/4 DO IS")},
|
| 265 |
+
{21, 197, N_("Canon EF 75-300mm f/4-5.6 IS")},
|
| 266 |
+
{21, 198, N_("Canon EF 50mm f/1.4")},
|
| 267 |
+
{21, 202, N_("Canon EF 28-80 f/3.5-5.6 USM IV")},
|
| 268 |
+
{21, 211, N_("Canon EF 28-200mm f/3.5-5.6")},
|
| 269 |
+
{21, 213, N_("Canon EF 90-300mm f/4.5-5.6")},
|
| 270 |
+
{21, 214, N_("Canon EF-S 18-55mm f/3.5-4.5 USM")},
|
| 271 |
+
{21, 224, N_("Canon EF 70-200mm f/2.8L IS USM")},
|
| 272 |
+
{21, 225, N_("Canon EF 70-200mm f/2.8L IS USM + x1.4")},
|
| 273 |
+
{21, 226, N_("Canon EF 70-200mm f/2.8L IS USM + x2")},
|
| 274 |
+
{21, 229, N_("Canon EF 16-35mm f/2.8L")},
|
| 275 |
+
{21, 230, N_("Canon EF 24-70mm f/2.8L")},
|
| 276 |
+
{21, 231, N_("Canon EF 17-40mm f/4L")},
|
| 277 |
+
{21, 232, N_("Canon EF 70-300mm f/4.5-5.6 DO IS USM")},
|
| 278 |
+
{21, 234, N_("Canon EF-S 17-85mm f4-5.6 IS USM")},
|
| 279 |
+
{21, 235, N_("Canon EF-S10-22mm F3.5-4.5 USM")},
|
| 280 |
+
{21, 236, N_("Canon EF-S60mm F2.8 Macro USM")},
|
| 281 |
+
{21, 237, N_("Canon EF 24-105mm f/4L IS")},
|
| 282 |
+
{21, 238, N_("Canon EF 70-300mm F4-5.6 IS USM")},
|
| 283 |
+
{21, 241, N_("Canon EF 50mm F1.2L USM")},
|
| 284 |
+
{21, 242, N_("Canon EF 70-200mm f/4L IS USM")},
|
| 285 |
+
{21, 251, N_("Canon EF 70-200mm f/2.8L IS II USM")},
|
| 286 |
+
{28, 0, N_("Manual")},
|
| 287 |
+
{28, 1, N_("TTL")},
|
| 288 |
+
{28, 2, N_("A-TTL")},
|
| 289 |
+
{28, 3, N_("E-TTL")},
|
| 290 |
+
{28, 4, N_("FP sync enabled")},
|
| 291 |
+
{28, 7, N_("2nd-curtain sync used")},
|
| 292 |
+
{28, 11, N_("FP sync used")},
|
| 293 |
+
{28, 13, N_("Internal")},
|
| 294 |
+
{28, 14, N_("External")},
|
| 295 |
+
{31, 0, N_("Single")},
|
| 296 |
+
{31, 1, N_("Continuous")},
|
| 297 |
+
{32, 0, N_("Normal AE")},
|
| 298 |
+
{32, 1, N_("Exposure compensation")},
|
| 299 |
+
{32, 2, N_("AE lock")},
|
| 300 |
+
{32, 3, N_("AE lock + exposure compensation")},
|
| 301 |
+
{32, 4, N_("No AE")},
|
| 302 |
+
{33, 0, N_("Off")},
|
| 303 |
+
{33, 1, N_("On")},
|
| 304 |
+
{33, 2, N_("On, shot only")},
|
| 305 |
+
{39, 0, N_("Off")},
|
| 306 |
+
{39, 1, N_("Vivid")},
|
| 307 |
+
{39, 2, N_("Neutral")},
|
| 308 |
+
{39, 3, N_("Smooth")},
|
| 309 |
+
{39, 4, N_("Sepia")},
|
| 310 |
+
{39, 5, N_("Black & white")},
|
| 311 |
+
{39, 6, N_("Custom")},
|
| 312 |
+
{39, 100, N_("My color data")},
|
| 313 |
+
{40, 0, N_("Off")},
|
| 314 |
+
{40, 0x0500, N_("Full")},
|
| 315 |
+
{40, 0x0502, N_("2/3")},
|
| 316 |
+
{40, 0x0504, N_("1/3")},
|
| 317 |
+
#endif
|
| 318 |
+
{ 0, 0, NULL}
|
| 319 |
+
},
|
| 320 |
+
entries_focal_length [] = {
|
| 321 |
+
#ifndef NO_VERBOSE_TAG_DATA
|
| 322 |
+
{0, 1, N_("Fixed")},
|
| 323 |
+
{0, 2, N_("Zoom")},
|
| 324 |
+
#endif
|
| 325 |
+
{0, 0, NULL}
|
| 326 |
+
},
|
| 327 |
+
entries_settings_2 [] = {
|
| 328 |
+
#ifndef NO_VERBOSE_TAG_DATA
|
| 329 |
+
{ 6, 0, N_("Auto")},
|
| 330 |
+
{ 6, 1, N_("Sunny")},
|
| 331 |
+
{ 6, 2, N_("Cloudy")},
|
| 332 |
+
{ 6, 3, N_("Tungsten")},
|
| 333 |
+
{ 6, 4, N_("Fluorescent")},
|
| 334 |
+
{ 6, 5, N_("Flash")},
|
| 335 |
+
{ 6, 6, N_("Custom")},
|
| 336 |
+
{ 6, 7, N_("Black & white")},
|
| 337 |
+
{ 6, 8, N_("Shade")},
|
| 338 |
+
{ 6, 9, N_("Manual temperature (Kelvin)")},
|
| 339 |
+
{ 6, 10, N_("PC set 1")},
|
| 340 |
+
{ 6, 11, N_("PC set 2")},
|
| 341 |
+
{ 6, 12, N_("PC set 3")},
|
| 342 |
+
{ 6, 14, N_("Daylight fluorescent")},
|
| 343 |
+
{ 6, 15, N_("Custom 1")},
|
| 344 |
+
{ 6, 16, N_("Custom 2")},
|
| 345 |
+
{ 6, 17, N_("Underwater")},
|
| 346 |
+
{ 7, 0, N_("Off")},
|
| 347 |
+
{ 7, 1, N_("Night scene")},
|
| 348 |
+
{ 7, 2, N_("On")},
|
| 349 |
+
{ 7, 3, N_("None")},
|
| 350 |
+
{ 13, 0x3000, N_("None (MF)")},
|
| 351 |
+
{ 13, 0x3001, N_("Right")},
|
| 352 |
+
{ 13, 0x3002, N_("Center")},
|
| 353 |
+
{ 13, 0x3003, N_("Center-right")},
|
| 354 |
+
{ 13, 0x3004, N_("Left")},
|
| 355 |
+
{ 13, 0x3005, N_("Left-right")},
|
| 356 |
+
{ 13, 0x3006, N_("Left-center")},
|
| 357 |
+
{ 13, 0x3007, N_("All")},
|
| 358 |
+
{ 15, 0, N_("Off")},
|
| 359 |
+
{ 15, 1, N_("On (shot 1)")},
|
| 360 |
+
{ 15, 2, N_("On (shot 2)")},
|
| 361 |
+
{ 15, 3, N_("On (shot 3)")},
|
| 362 |
+
{ 15, 0xffff, N_("On")},
|
| 363 |
+
{ 25, 248, N_("EOS high-end")},
|
| 364 |
+
{ 25, 250, N_("Compact")},
|
| 365 |
+
{ 25, 252, N_("EOS mid-range")},
|
| 366 |
+
{ 26, 0, N_("None")},
|
| 367 |
+
{ 26, 1, N_("Rotate 90 CW")},
|
| 368 |
+
{ 26, 2, N_("Rotate 180")},
|
| 369 |
+
{ 26, 3, N_("Rotate 270 CW")},
|
| 370 |
+
{ 26, 0xffff, N_("Rotated by software")},
|
| 371 |
+
{ 27, 0, N_("Off")},
|
| 372 |
+
{ 27, 1, N_("On")},
|
| 373 |
+
{ 32, 0, N_("Off")},
|
| 374 |
+
{ 32, 0x0014, N_("1/3")},
|
| 375 |
+
{ 32, 0x008c, N_("2/3")},
|
| 376 |
+
{ 32, 0x07d0, N_("Full")},
|
| 377 |
+
#endif
|
| 378 |
+
{0, 0, NULL}
|
| 379 |
+
},
|
| 380 |
+
entries_panorama [] = {
|
| 381 |
+
#ifndef NO_VERBOSE_TAG_DATA
|
| 382 |
+
{0, 0, N_("Left to right")},
|
| 383 |
+
{0, 1, N_("Right to left")},
|
| 384 |
+
{0, 2, N_("Bottom to top")},
|
| 385 |
+
{0, 3, N_("Top to bottom")},
|
| 386 |
+
{0, 4, N_("2x2 matrix (clockwise)")},
|
| 387 |
+
#endif
|
| 388 |
+
{0, 0, NULL}
|
| 389 |
+
},
|
| 390 |
+
color_information [] = {
|
| 391 |
+
#ifndef NO_VERBOSE_TAG_DATA
|
| 392 |
+
{0, 0, N_("Standard")},
|
| 393 |
+
{0, 1, N_("Manual")},
|
| 394 |
+
{0, 2, N_("Custom")},
|
| 395 |
+
{2, 0, N_("N/A")},
|
| 396 |
+
{2, 1, N_("Lowest")},
|
| 397 |
+
{2, 2, N_("Low")},
|
| 398 |
+
{2, 3, N_("Standard")},
|
| 399 |
+
{2, 4, N_("High")},
|
| 400 |
+
{2, 5, N_("Highest")},
|
| 401 |
+
{7, 0, N_("Auto")},
|
| 402 |
+
{7, 1, N_("Daylight")},
|
| 403 |
+
{7, 2, N_("Cloudy")},
|
| 404 |
+
{7, 3, N_("Tungsten")},
|
| 405 |
+
{7, 4, N_("Fluorescent")},
|
| 406 |
+
{7, 5, N_("Flash")},
|
| 407 |
+
{7, 6, N_("Custom")},
|
| 408 |
+
{7, 7, N_("Black & white")},
|
| 409 |
+
{7, 8, N_("Shade")},
|
| 410 |
+
{7, 9, N_("Manual temperature (Kelvin)")},
|
| 411 |
+
{7, 10, N_("PC set 1")},
|
| 412 |
+
{7, 11, N_("PC set 2")},
|
| 413 |
+
{7, 12, N_("PC set 3")},
|
| 414 |
+
{7, 14, N_("Daylight fluorescent")},
|
| 415 |
+
{7, 15, N_("Custom 1")},
|
| 416 |
+
{7, 16, N_("Custom 2")},
|
| 417 |
+
{7, 17, N_("Underwater")},
|
| 418 |
+
{9, 0x00, N_("None")},
|
| 419 |
+
{9, 0x01, N_("Standard")},
|
| 420 |
+
{9, 0x02, N_("Set 1")},
|
| 421 |
+
{9, 0x03, N_("Set 2")},
|
| 422 |
+
{9, 0x04, N_("Set 3")},
|
| 423 |
+
{9, 0x21, N_("User def. 1")},
|
| 424 |
+
{9, 0x22, N_("User def. 2")},
|
| 425 |
+
{9, 0x23, N_("User def. 3")},
|
| 426 |
+
{9, 0x41, N_("External 1")},
|
| 427 |
+
{9, 0x42, N_("External 2")},
|
| 428 |
+
{9, 0x43, N_("External 3")},
|
| 429 |
+
{9, 0x81, N_("Standard")},
|
| 430 |
+
{9, 0x82, N_("Portrait")},
|
| 431 |
+
{9, 0x83, N_("Landscape")},
|
| 432 |
+
{9, 0x84, N_("Neutral")},
|
| 433 |
+
{9, 0x85, N_("Faithful")},
|
| 434 |
+
{9, 0x86, N_("Monochrome")},
|
| 435 |
+
#endif
|
| 436 |
+
{0, 0, NULL}
|
| 437 |
+
};
|
| 438 |
+
|
| 439 |
+
static void
|
| 440 |
+
canon_search_table_value (const struct canon_entry_table_t table[],
|
| 441 |
+
unsigned int t, ExifShort vs, char *val, unsigned int maxlen)
|
| 442 |
+
{
|
| 443 |
+
unsigned int j;
|
| 444 |
+
|
| 445 |
+
/* Search the table for the first matching subtag and value. */
|
| 446 |
+
for (j = 0; table[j].name && ((table[j].subtag < t) ||
|
| 447 |
+
((table[j].subtag == t) && table[j].value <= vs)); j++) {
|
| 448 |
+
if ((table[j].subtag == t) && (table[j].value == vs)) {
|
| 449 |
+
break;
|
| 450 |
+
}
|
| 451 |
+
}
|
| 452 |
+
if ((table[j].subtag == t) && (table[j].value == vs) && table[j].name) {
|
| 453 |
+
/* Matching subtag and value found. */
|
| 454 |
+
strncpy (val, _(table[j].name), maxlen);
|
| 455 |
+
} else {
|
| 456 |
+
/* No matching subtag and/or value found. */
|
| 457 |
+
snprintf (val, maxlen, "0x%04x", vs);
|
| 458 |
+
}
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
static void
|
| 462 |
+
canon_search_table_bitfield (const struct canon_entry_table_t table[],
|
| 463 |
+
unsigned int t, ExifShort vs, char *val, unsigned int maxlen)
|
| 464 |
+
{
|
| 465 |
+
unsigned int j;
|
| 466 |
+
|
| 467 |
+
/* Search the table for the first matching subtag. */
|
| 468 |
+
for (j = 0; table[j].name && (table[j].subtag <= t); j++) {
|
| 469 |
+
if (table[j].subtag == t) {
|
| 470 |
+
break;
|
| 471 |
+
}
|
| 472 |
+
}
|
| 473 |
+
if ((table[j].subtag == t) && table[j].name) {
|
| 474 |
+
unsigned int i, bit, lastbit = 0;
|
| 475 |
+
|
| 476 |
+
/*
|
| 477 |
+
* Search the table for the last matching bit, because
|
| 478 |
+
* that one needs no additional comma appended.
|
| 479 |
+
*/
|
| 480 |
+
for (i = j; table[i].name && (table[i].subtag == t); i++) {
|
| 481 |
+
bit = table[i].value;
|
| 482 |
+
if ((vs >> bit) & 1) {
|
| 483 |
+
lastbit = bit;
|
| 484 |
+
}
|
| 485 |
+
}
|
| 486 |
+
/* Search the table for all matching bits. */
|
| 487 |
+
for (i = j; table[i].name && (table[i].subtag == t); i++) {
|
| 488 |
+
bit = table[i].value;
|
| 489 |
+
if ((vs >> bit) & 1) {
|
| 490 |
+
strncat(val, _(table[i].name), maxlen - strlen (val));
|
| 491 |
+
if (bit != lastbit)
|
| 492 |
+
strncat (val, _(", "), maxlen - strlen (val));
|
| 493 |
+
}
|
| 494 |
+
}
|
| 495 |
+
} else {
|
| 496 |
+
/* No matching subtag found. */
|
| 497 |
+
snprintf (val, maxlen, "0x%04x", vs);
|
| 498 |
+
}
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
unsigned int
|
| 502 |
+
mnote_canon_entry_count_values (const MnoteCanonEntry *entry)
|
| 503 |
+
{
|
| 504 |
+
unsigned int val;
|
| 505 |
+
|
| 506 |
+
if (!entry) return 0;
|
| 507 |
+
|
| 508 |
+
switch (entry->tag) {
|
| 509 |
+
case MNOTE_CANON_TAG_FOCAL_LENGTH:
|
| 510 |
+
case MNOTE_CANON_TAG_PANORAMA:
|
| 511 |
+
return entry->components;
|
| 512 |
+
case MNOTE_CANON_TAG_SETTINGS_1:
|
| 513 |
+
case MNOTE_CANON_TAG_SETTINGS_2:
|
| 514 |
+
case MNOTE_CANON_TAG_CUSTOM_FUNCS:
|
| 515 |
+
case MNOTE_CANON_TAG_COLOR_INFORMATION:
|
| 516 |
+
if (entry->format != EXIF_FORMAT_SHORT) return 0;
|
| 517 |
+
|
| 518 |
+
val = exif_get_short (entry->data, entry->order);
|
| 519 |
+
/* val is buffer size, i.e. # of values plus 1 */
|
| 520 |
+
return MIN (entry->size - 2, val) / 2;
|
| 521 |
+
default:
|
| 522 |
+
return 1;
|
| 523 |
+
}
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
/*
|
| 527 |
+
* For reference, see Exif 2.1 specification (Appendix C),
|
| 528 |
+
* or http://en.wikipedia.org/wiki/APEX_system
|
| 529 |
+
*/
|
| 530 |
+
static double
|
| 531 |
+
apex_value_to_aperture (double x)
|
| 532 |
+
{
|
| 533 |
+
return pow (2, x / 2.);
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
static double
|
| 537 |
+
apex_value_to_shutter_speed(double x)
|
| 538 |
+
{
|
| 539 |
+
return 1.0 / pow (2, x);
|
| 540 |
+
}
|
| 541 |
+
|
| 542 |
+
static double
|
| 543 |
+
apex_value_to_iso_speed (double x)
|
| 544 |
+
{
|
| 545 |
+
return 3.125 * pow (2, x);
|
| 546 |
+
}
|
| 547 |
+
|
| 548 |
+
char *
|
| 549 |
+
mnote_canon_entry_get_value (const MnoteCanonEntry *entry, unsigned int t, char *val, unsigned int maxlen)
|
| 550 |
+
{
|
| 551 |
+
char buf[128];
|
| 552 |
+
ExifLong vl;
|
| 553 |
+
ExifSLong vsl;
|
| 554 |
+
ExifShort vs, n;
|
| 555 |
+
ExifSShort vss;
|
| 556 |
+
unsigned char *data;
|
| 557 |
+
size_t size;
|
| 558 |
+
double d;
|
| 559 |
+
|
| 560 |
+
if (!entry)
|
| 561 |
+
return NULL;
|
| 562 |
+
|
| 563 |
+
data = entry->data;
|
| 564 |
+
size = entry->size;
|
| 565 |
+
|
| 566 |
+
memset (val, 0, maxlen);
|
| 567 |
+
maxlen--;
|
| 568 |
+
|
| 569 |
+
switch (entry->tag) {
|
| 570 |
+
case MNOTE_CANON_TAG_SETTINGS_1:
|
| 571 |
+
CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
|
| 572 |
+
|
| 573 |
+
if (size < 2) return NULL;
|
| 574 |
+
n = exif_get_short (data, entry->order) / 2;
|
| 575 |
+
if (t >= n) return NULL;
|
| 576 |
+
|
| 577 |
+
CC (entry->components, n, val, maxlen);
|
| 578 |
+
|
| 579 |
+
if (size < 2 + t*2 + 2) return NULL;
|
| 580 |
+
vs = exif_get_short (data + 2 + t * 2, entry->order);
|
| 581 |
+
switch (t) {
|
| 582 |
+
case 1:
|
| 583 |
+
if (!vs) {
|
| 584 |
+
strncpy(val, _("Off"), maxlen);
|
| 585 |
+
break;
|
| 586 |
+
}
|
| 587 |
+
snprintf (val, maxlen, _("%i (ms)"), vs * 100);
|
| 588 |
+
break;
|
| 589 |
+
case 15:
|
| 590 |
+
if (((vs & 0xC000) == 0x4000) && (vs != 0x7FFF)) {
|
| 591 |
+
/* Canon S3 IS - directly specified value */
|
| 592 |
+
snprintf (val, maxlen, "%i", vs & ~0x4000);
|
| 593 |
+
} else {
|
| 594 |
+
/* Standard Canon - index into lookup table */
|
| 595 |
+
canon_search_table_value (entries_settings_1, t, vs, val, maxlen);
|
| 596 |
+
}
|
| 597 |
+
break;
|
| 598 |
+
case 22:
|
| 599 |
+
case 23:
|
| 600 |
+
case 24:
|
| 601 |
+
snprintf (val, maxlen, "%u", vs);
|
| 602 |
+
break;
|
| 603 |
+
case 25:
|
| 604 |
+
case 26:
|
| 605 |
+
snprintf (val, maxlen, "%.2f", apex_value_to_aperture (vs / 32.0));
|
| 606 |
+
break;
|
| 607 |
+
case 28:
|
| 608 |
+
canon_search_table_bitfield(entries_settings_1, t, vs, val, maxlen);
|
| 609 |
+
break;
|
| 610 |
+
case 34:
|
| 611 |
+
snprintf (val, maxlen, "%.2f", vs / 10.0);
|
| 612 |
+
break;
|
| 613 |
+
case 35:
|
| 614 |
+
case 36:
|
| 615 |
+
snprintf (val, maxlen, "%u", vs);
|
| 616 |
+
break;
|
| 617 |
+
default:
|
| 618 |
+
canon_search_table_value (entries_settings_1, t, vs, val, maxlen);
|
| 619 |
+
}
|
| 620 |
+
break;
|
| 621 |
+
|
| 622 |
+
case MNOTE_CANON_TAG_FOCAL_LENGTH:
|
| 623 |
+
CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
|
| 624 |
+
if (size < t*2 + 2) return NULL;
|
| 625 |
+
vs = exif_get_short (data + t * 2, entry->order);
|
| 626 |
+
switch (t) {
|
| 627 |
+
case 1:
|
| 628 |
+
snprintf (val, maxlen, "%u", vs);
|
| 629 |
+
break;
|
| 630 |
+
case 2:
|
| 631 |
+
case 3:
|
| 632 |
+
snprintf (val, maxlen, _("%.2f mm"), vs * 25.4 / 1000);
|
| 633 |
+
break;
|
| 634 |
+
default:
|
| 635 |
+
canon_search_table_value (entries_focal_length, t, vs, val, maxlen);
|
| 636 |
+
}
|
| 637 |
+
break;
|
| 638 |
+
|
| 639 |
+
case MNOTE_CANON_TAG_SETTINGS_2:
|
| 640 |
+
CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
|
| 641 |
+
if (size < 2) return NULL;
|
| 642 |
+
n = exif_get_short (data, entry->order) / 2;
|
| 643 |
+
if (t >= n) return NULL;
|
| 644 |
+
CC (entry->components, n, val, maxlen);
|
| 645 |
+
if (size < 2 + t*2 + 2) return NULL;
|
| 646 |
+
vss = exif_get_sshort (data + 2 + t * 2, entry->order);
|
| 647 |
+
switch (t) {
|
| 648 |
+
case 0:
|
| 649 |
+
snprintf (val, maxlen, "%.3f", pow (2, vss / 32.0));
|
| 650 |
+
break;
|
| 651 |
+
case 1:
|
| 652 |
+
snprintf (val, maxlen, "%.0f", apex_value_to_iso_speed (vss / 32.0));
|
| 653 |
+
break;
|
| 654 |
+
case 2:
|
| 655 |
+
case 5:
|
| 656 |
+
case 14:
|
| 657 |
+
case 16:
|
| 658 |
+
snprintf (val, maxlen, _("%.2f EV"), vss / 32.0);
|
| 659 |
+
break;
|
| 660 |
+
case 3:
|
| 661 |
+
case 20:
|
| 662 |
+
snprintf (val, maxlen, "%.2f", apex_value_to_aperture (vss / 32.0));
|
| 663 |
+
break;
|
| 664 |
+
case 4:
|
| 665 |
+
case 21:
|
| 666 |
+
d = apex_value_to_shutter_speed (vss / 32.0);
|
| 667 |
+
if (d < 1)
|
| 668 |
+
snprintf (val, maxlen, _("1/%.0f"), 1.0 / d);
|
| 669 |
+
else
|
| 670 |
+
snprintf (val, maxlen, "%.0f", d);
|
| 671 |
+
break;
|
| 672 |
+
case 8:
|
| 673 |
+
snprintf (val, maxlen, "%u", vss);
|
| 674 |
+
break;
|
| 675 |
+
case 12:
|
| 676 |
+
snprintf (val, maxlen, "%.2f", vss / 32.0);
|
| 677 |
+
break;
|
| 678 |
+
case 18:
|
| 679 |
+
case 19:
|
| 680 |
+
snprintf (val, maxlen, _("%u mm"), vss);
|
| 681 |
+
break;
|
| 682 |
+
case 28:
|
| 683 |
+
if (vss <= 0) {
|
| 684 |
+
strncpy(val, _("Off"), maxlen);
|
| 685 |
+
break;
|
| 686 |
+
}
|
| 687 |
+
snprintf (val, maxlen, _("%i (ms)"), vss * 100);
|
| 688 |
+
break;
|
| 689 |
+
default:
|
| 690 |
+
canon_search_table_value (entries_settings_2, t, vss, val, maxlen);
|
| 691 |
+
}
|
| 692 |
+
break;
|
| 693 |
+
|
| 694 |
+
case MNOTE_CANON_TAG_PANORAMA:
|
| 695 |
+
CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
|
| 696 |
+
if (size < t*2 + 2) return NULL;
|
| 697 |
+
vs = exif_get_short (data + t * 2, entry->order);
|
| 698 |
+
canon_search_table_value (entries_panorama, t, vs, val, maxlen);
|
| 699 |
+
break;
|
| 700 |
+
|
| 701 |
+
case MNOTE_CANON_TAG_OWNER:
|
| 702 |
+
CC (entry->components, 32, val, maxlen);
|
| 703 |
+
/* Fall through; ImageType can have many sizes */
|
| 704 |
+
case MNOTE_CANON_TAG_IMAGE_TYPE:
|
| 705 |
+
CF (entry->format, EXIF_FORMAT_ASCII, val, maxlen);
|
| 706 |
+
strncpy (val, (char *)data, MIN (entry->size, maxlen));
|
| 707 |
+
break;
|
| 708 |
+
|
| 709 |
+
case MNOTE_CANON_TAG_FIRMWARE:
|
| 710 |
+
CF (entry->format, EXIF_FORMAT_ASCII, val, maxlen);
|
| 711 |
+
/* CC2 (entry->components, 24, 32, val, maxlen); Can also be 22 */
|
| 712 |
+
strncpy (val, (char *)data, MIN (entry->size, maxlen));
|
| 713 |
+
break;
|
| 714 |
+
|
| 715 |
+
case MNOTE_CANON_TAG_IMAGE_NUMBER:
|
| 716 |
+
CF (entry->format, EXIF_FORMAT_LONG, val, maxlen);
|
| 717 |
+
CC (entry->components, 1, val, maxlen);
|
| 718 |
+
if (size < 4) return NULL;
|
| 719 |
+
vl = exif_get_long (data, entry->order);
|
| 720 |
+
snprintf (val, maxlen, "%03lu-%04lu",
|
| 721 |
+
(unsigned long) vl/10000,
|
| 722 |
+
(unsigned long) vl%10000);
|
| 723 |
+
break;
|
| 724 |
+
|
| 725 |
+
case MNOTE_CANON_TAG_SERIAL_NUMBER:
|
| 726 |
+
CF (entry->format, EXIF_FORMAT_LONG, val, maxlen);
|
| 727 |
+
CC (entry->components, 1, val, maxlen);
|
| 728 |
+
if (size < 4) return NULL;
|
| 729 |
+
vl = exif_get_long (data, entry->order);
|
| 730 |
+
snprintf (val, maxlen, "%04X-%05d", (int)vl>>16,(int)vl&0xffff);
|
| 731 |
+
break;
|
| 732 |
+
|
| 733 |
+
case MNOTE_CANON_TAG_CUSTOM_FUNCS:
|
| 734 |
+
CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
|
| 735 |
+
if (size < 2) return NULL;
|
| 736 |
+
n = exif_get_short (data, entry->order) / 2;
|
| 737 |
+
if (t >= n) return NULL;
|
| 738 |
+
CC (entry->components, n, val, maxlen);
|
| 739 |
+
if (size < 2 + t*2 + 2) return NULL;
|
| 740 |
+
vs = exif_get_short (data + 2 + t * 2, entry->order);
|
| 741 |
+
snprintf (buf, sizeof (buf), "%u", vs);
|
| 742 |
+
strncat (val, buf, maxlen - strlen (val));
|
| 743 |
+
break;
|
| 744 |
+
|
| 745 |
+
case MNOTE_CANON_TAG_COLOR_INFORMATION:
|
| 746 |
+
CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
|
| 747 |
+
if (size < 2) return NULL;
|
| 748 |
+
n = exif_get_short (data, entry->order) / 2;
|
| 749 |
+
if (t >= n) return NULL;
|
| 750 |
+
CC (entry->components, n, val, maxlen);
|
| 751 |
+
if (size < 2 + t*2 + 2) return NULL;
|
| 752 |
+
vs = exif_get_short (data + 2 + t * 2, entry->order);
|
| 753 |
+
canon_search_table_value (color_information, t, vs, val, maxlen);
|
| 754 |
+
break;
|
| 755 |
+
|
| 756 |
+
default:
|
| 757 |
+
switch (entry->format) {
|
| 758 |
+
case EXIF_FORMAT_SHORT:
|
| 759 |
+
{
|
| 760 |
+
size_t i, len = strlen(val);
|
| 761 |
+
for(i=0; i<entry->components; i++) {
|
| 762 |
+
if (size < 2)
|
| 763 |
+
break;
|
| 764 |
+
vs = exif_get_short (data, entry->order);
|
| 765 |
+
snprintf (val+len, maxlen-len, "%hu ", vs);
|
| 766 |
+
len = strlen(val);
|
| 767 |
+
data += 2;
|
| 768 |
+
size -= 2;
|
| 769 |
+
}
|
| 770 |
+
}
|
| 771 |
+
break;
|
| 772 |
+
case EXIF_FORMAT_SSHORT:
|
| 773 |
+
{
|
| 774 |
+
size_t i, len = strlen(val);
|
| 775 |
+
for(i=0; i<entry->components; i++) {
|
| 776 |
+
if (size < 2)
|
| 777 |
+
break;
|
| 778 |
+
vss = exif_get_sshort (data, entry->order);
|
| 779 |
+
snprintf (val+len, maxlen-len, "%hi ", vss);
|
| 780 |
+
data += 2;
|
| 781 |
+
size -= 2;
|
| 782 |
+
}
|
| 783 |
+
}
|
| 784 |
+
break;
|
| 785 |
+
case EXIF_FORMAT_LONG:
|
| 786 |
+
{
|
| 787 |
+
size_t i, len = strlen(val);
|
| 788 |
+
for(i=0; i<entry->components; i++) {
|
| 789 |
+
if (size < 4)
|
| 790 |
+
break;
|
| 791 |
+
vl = exif_get_long (data, entry->order);
|
| 792 |
+
snprintf (val+len, maxlen-len, "%lu ", (long unsigned) vl);
|
| 793 |
+
data += 4;
|
| 794 |
+
size -= 4;
|
| 795 |
+
}
|
| 796 |
+
}
|
| 797 |
+
break;
|
| 798 |
+
case EXIF_FORMAT_SLONG:
|
| 799 |
+
{
|
| 800 |
+
size_t i, len = strlen(val);
|
| 801 |
+
for(i=0; i<entry->components; i++) {
|
| 802 |
+
if (size < 4)
|
| 803 |
+
break;
|
| 804 |
+
vsl = exif_get_slong (data, entry->order);
|
| 805 |
+
snprintf (val+len, maxlen-len, "%li ", (long int) vsl);
|
| 806 |
+
data += 4;
|
| 807 |
+
size -= 4;
|
| 808 |
+
}
|
| 809 |
+
}
|
| 810 |
+
break;
|
| 811 |
+
case EXIF_FORMAT_ASCII:
|
| 812 |
+
strncpy (val, (char *)data, MIN (entry->size, maxlen));
|
| 813 |
+
break;
|
| 814 |
+
default:
|
| 815 |
+
snprintf (val, maxlen, _("%i bytes unknown data"),
|
| 816 |
+
entry->size);
|
| 817 |
+
break;
|
| 818 |
+
}
|
| 819 |
+
break;
|
| 820 |
+
}
|
| 821 |
+
return val;
|
| 822 |
+
}
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/canon/mnote-canon-entry.h
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* mnote-canon-entry.h
|
| 2 |
+
*
|
| 3 |
+
* Copyright (c) 2002 Lutz Mueller <[email protected]>
|
| 4 |
+
*
|
| 5 |
+
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef __MNOTE_CANON_ENTRY_H__
|
| 22 |
+
#define __MNOTE_CANON_ENTRY_H__
|
| 23 |
+
|
| 24 |
+
#include <libexif/exif-format.h>
|
| 25 |
+
#include <libexif/exif-byte-order.h>
|
| 26 |
+
#include <libexif/canon/mnote-canon-tag.h>
|
| 27 |
+
|
| 28 |
+
typedef struct _MnoteCanonEntry MnoteCanonEntry;
|
| 29 |
+
|
| 30 |
+
struct _MnoteCanonEntry {
|
| 31 |
+
MnoteCanonTag tag;
|
| 32 |
+
ExifFormat format;
|
| 33 |
+
unsigned long components;
|
| 34 |
+
|
| 35 |
+
unsigned char *data;
|
| 36 |
+
unsigned int size;
|
| 37 |
+
|
| 38 |
+
ExifByteOrder order;
|
| 39 |
+
};
|
| 40 |
+
|
| 41 |
+
unsigned int mnote_canon_entry_count_values (const MnoteCanonEntry *);
|
| 42 |
+
char *mnote_canon_entry_get_value (const MnoteCanonEntry *, unsigned int t, char *val, unsigned int maxlen);
|
| 43 |
+
|
| 44 |
+
#endif /* __MNOTE_CANON_ENTRY_H__ */
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/canon/mnote-canon-tag.c
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* mnote-canon-tag.c
|
| 2 |
+
*
|
| 3 |
+
* Copyright (c) 2002 Lutz Mueller <[email protected]>
|
| 4 |
+
*
|
| 5 |
+
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#include <config.h>
|
| 22 |
+
#include "mnote-canon-tag.h"
|
| 23 |
+
|
| 24 |
+
#include <stdlib.h>
|
| 25 |
+
|
| 26 |
+
#include <libexif/i18n.h>
|
| 27 |
+
|
| 28 |
+
static const struct {
|
| 29 |
+
MnoteCanonTag tag;
|
| 30 |
+
const char *name;
|
| 31 |
+
const char *title;
|
| 32 |
+
const char *description;
|
| 33 |
+
} table[] = {
|
| 34 |
+
#ifndef NO_VERBOSE_TAG_STRINGS
|
| 35 |
+
{MNOTE_CANON_TAG_SETTINGS_1, "Settings1", N_("Settings (First Part)"), ""},
|
| 36 |
+
{MNOTE_CANON_TAG_FOCAL_LENGTH, "FocalLength", N_("Focal Length"), ""},
|
| 37 |
+
{MNOTE_CANON_TAG_SETTINGS_2, "Settings2", N_("Settings (Second Part)"), ""},
|
| 38 |
+
{MNOTE_CANON_TAG_PANORAMA, "Panorama", N_("Panorama"), ""},
|
| 39 |
+
{MNOTE_CANON_TAG_IMAGE_TYPE, "ImageType", N_("Image Type"), ""},
|
| 40 |
+
{MNOTE_CANON_TAG_FIRMWARE, "FirmwareVersion", N_("Firmware Version"), ""},
|
| 41 |
+
{MNOTE_CANON_TAG_IMAGE_NUMBER, "ImageNumber", N_("Image Number"), ""},
|
| 42 |
+
{MNOTE_CANON_TAG_OWNER, "OwnerName", N_("Owner Name"), ""},
|
| 43 |
+
{MNOTE_CANON_TAG_COLOR_INFORMATION, "ColorInformation", N_("Color Information"), ""},
|
| 44 |
+
{MNOTE_CANON_TAG_SERIAL_NUMBER, "SerialNumber", N_("Serial Number"), ""},
|
| 45 |
+
{MNOTE_CANON_TAG_CUSTOM_FUNCS, "CustomFunctions", N_("Custom Functions"), ""},
|
| 46 |
+
#endif
|
| 47 |
+
{0, NULL, NULL, NULL}
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
static const struct {
|
| 51 |
+
MnoteCanonTag tag;
|
| 52 |
+
unsigned int subtag;
|
| 53 |
+
const char *name;
|
| 54 |
+
} table_sub[] = {
|
| 55 |
+
#ifndef NO_VERBOSE_TAG_STRINGS
|
| 56 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 0, N_("Macro Mode")},
|
| 57 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 1, N_("Self-timer")},
|
| 58 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 2, N_("Quality")},
|
| 59 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 3, N_("Flash Mode")},
|
| 60 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 4, N_("Drive Mode")},
|
| 61 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 6, N_("Focus Mode")},
|
| 62 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 8, N_("Record Mode")},
|
| 63 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 9, N_("Image Size")},
|
| 64 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 10, N_("Easy Shooting Mode")},
|
| 65 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 11, N_("Digital Zoom")},
|
| 66 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 12, N_("Contrast")},
|
| 67 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 13, N_("Saturation")},
|
| 68 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 14, N_("Sharpness")},
|
| 69 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 15, N_("ISO")},
|
| 70 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 16, N_("Metering Mode")},
|
| 71 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 17, N_("Focus Range")},
|
| 72 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 18, N_("AF Point")},
|
| 73 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 19, N_("Exposure Mode")},
|
| 74 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 21, N_("Lens Type")},
|
| 75 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 22, N_("Long Focal Length of Lens")},
|
| 76 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 23, N_("Short Focal Length of Lens")},
|
| 77 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 24, N_("Focal Units per mm")},
|
| 78 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 25, N_("Maximal Aperture")},
|
| 79 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 26, N_("Minimal Aperture")},
|
| 80 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 27, N_("Flash Activity")},
|
| 81 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 28, N_("Flash Details")},
|
| 82 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 31, N_("Focus Mode")},
|
| 83 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 32, N_("AE Setting")},
|
| 84 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 33, N_("Image Stabilization")},
|
| 85 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 34, N_("Display Aperture")},
|
| 86 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 35, N_("Zoom Source Width")},
|
| 87 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 36, N_("Zoom Target Width")},
|
| 88 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 39, N_("Photo Effect")},
|
| 89 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 40, N_("Manual Flash Output")},
|
| 90 |
+
{MNOTE_CANON_TAG_SETTINGS_1, 41, N_("Color Tone")},
|
| 91 |
+
{MNOTE_CANON_TAG_FOCAL_LENGTH, 0, N_("Focal Type")},
|
| 92 |
+
{MNOTE_CANON_TAG_FOCAL_LENGTH, 1, N_("Focal Length")},
|
| 93 |
+
{MNOTE_CANON_TAG_FOCAL_LENGTH, 2, N_("Focal Plane X Size")},
|
| 94 |
+
{MNOTE_CANON_TAG_FOCAL_LENGTH, 3, N_("Focal Plane Y Size")},
|
| 95 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 0, N_("Auto ISO")},
|
| 96 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 1, N_("Shot ISO")},
|
| 97 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 2, N_("Measured EV")},
|
| 98 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 3, N_("Target Aperture")},
|
| 99 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 4, N_("Target Exposure Time")},
|
| 100 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 5, N_("Exposure Compensation")},
|
| 101 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 6, N_("White Balance")},
|
| 102 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 7, N_("Slow Shutter")},
|
| 103 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 8, N_("Sequence Number")},
|
| 104 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 12, N_("Flash Guide Number")},
|
| 105 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 13, N_("AF Point")},
|
| 106 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 14, N_("Flash Exposure Compensation")},
|
| 107 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 15, N_("AE Bracketing")},
|
| 108 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 16, N_("AE Bracket Value")},
|
| 109 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 18, N_("Focus Distance Upper")},
|
| 110 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 19, N_("Focus Distance Lower")},
|
| 111 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 20, N_("F-Number")},
|
| 112 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 21, N_("Exposure Time")},
|
| 113 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 23, N_("Bulb Duration")},
|
| 114 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 25, N_("Camera Type")},
|
| 115 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 26, N_("Auto Rotate")},
|
| 116 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 27, N_("ND Filter")},
|
| 117 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 28, N_("Self-timer")},
|
| 118 |
+
{MNOTE_CANON_TAG_SETTINGS_2, 32, N_("Manual Flash Output")},
|
| 119 |
+
{MNOTE_CANON_TAG_PANORAMA, 2, N_("Panorama Frame")},
|
| 120 |
+
{MNOTE_CANON_TAG_PANORAMA, 5, N_("Panorama Direction")},
|
| 121 |
+
{MNOTE_CANON_TAG_COLOR_INFORMATION, 0, N_("Tone Curve")},
|
| 122 |
+
{MNOTE_CANON_TAG_COLOR_INFORMATION, 2, N_("Sharpness Frequency")},
|
| 123 |
+
{MNOTE_CANON_TAG_COLOR_INFORMATION, 7, N_("White Balance")},
|
| 124 |
+
{MNOTE_CANON_TAG_COLOR_INFORMATION, 9, N_("Picture Style")},
|
| 125 |
+
#endif
|
| 126 |
+
{0, 0, NULL}
|
| 127 |
+
};
|
| 128 |
+
|
| 129 |
+
const char *
|
| 130 |
+
mnote_canon_tag_get_name (MnoteCanonTag t)
|
| 131 |
+
{
|
| 132 |
+
unsigned int i;
|
| 133 |
+
|
| 134 |
+
for (i = 0; i < sizeof (table) / sizeof (table[0]); i++)
|
| 135 |
+
if (table[i].tag == t) return table[i].name; /* do not translate */
|
| 136 |
+
return NULL;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
const char *
|
| 140 |
+
mnote_canon_tag_get_name_sub (MnoteCanonTag t, unsigned int s, ExifDataOption o)
|
| 141 |
+
{
|
| 142 |
+
unsigned int i;
|
| 143 |
+
int tag_found = 0;
|
| 144 |
+
|
| 145 |
+
for (i = 0; i < sizeof (table_sub) / sizeof (table_sub[0]); i++) {
|
| 146 |
+
if (table_sub[i].tag == t) {
|
| 147 |
+
if (table_sub[i].subtag == s)
|
| 148 |
+
return table_sub[i].name;
|
| 149 |
+
tag_found = 1;
|
| 150 |
+
}
|
| 151 |
+
}
|
| 152 |
+
if (!tag_found || !(o & EXIF_DATA_OPTION_IGNORE_UNKNOWN_TAGS))
|
| 153 |
+
return mnote_canon_tag_get_name (t);
|
| 154 |
+
else
|
| 155 |
+
return NULL;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
const char *
|
| 159 |
+
mnote_canon_tag_get_title (MnoteCanonTag t)
|
| 160 |
+
{
|
| 161 |
+
unsigned int i;
|
| 162 |
+
|
| 163 |
+
(void) bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
| 164 |
+
for (i = 0; i < sizeof (table) / sizeof (table[0]); i++)
|
| 165 |
+
if (table[i].tag == t) return (_(table[i].title));
|
| 166 |
+
return NULL;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
const char *
|
| 170 |
+
mnote_canon_tag_get_title_sub (MnoteCanonTag t, unsigned int s, ExifDataOption o)
|
| 171 |
+
{
|
| 172 |
+
unsigned int i;
|
| 173 |
+
int tag_found = 0;
|
| 174 |
+
|
| 175 |
+
for (i = 0; i < sizeof (table_sub) / sizeof (table_sub[0]); i++) {
|
| 176 |
+
if (table_sub[i].tag == t) {
|
| 177 |
+
if (table_sub[i].subtag == s)
|
| 178 |
+
return _(table_sub[i].name);
|
| 179 |
+
tag_found = 1;
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
if (!tag_found || !(o & EXIF_DATA_OPTION_IGNORE_UNKNOWN_TAGS))
|
| 183 |
+
return mnote_canon_tag_get_title (t);
|
| 184 |
+
else
|
| 185 |
+
return NULL;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
const char *
|
| 189 |
+
mnote_canon_tag_get_description (MnoteCanonTag t)
|
| 190 |
+
{
|
| 191 |
+
unsigned int i;
|
| 192 |
+
|
| 193 |
+
for (i = 0; i < sizeof (table) / sizeof (table[0]); i++)
|
| 194 |
+
if (table[i].tag == t) {
|
| 195 |
+
if (!table[i].description || !*table[i].description)
|
| 196 |
+
return "";
|
| 197 |
+
(void) bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
| 198 |
+
return _(table[i].description);
|
| 199 |
+
}
|
| 200 |
+
return NULL;
|
| 201 |
+
}
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/canon/mnote-canon-tag.h
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* mnote-canon-tag.h
|
| 2 |
+
*
|
| 3 |
+
* Copyright (c) 2002 Lutz Mueller <[email protected]>
|
| 4 |
+
*
|
| 5 |
+
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef __MNOTE_CANON_TAG_H__
|
| 22 |
+
#define __MNOTE_CANON_TAG_H__
|
| 23 |
+
|
| 24 |
+
#include <libexif/exif-data.h>
|
| 25 |
+
|
| 26 |
+
#ifdef __cplusplus
|
| 27 |
+
extern "C" {
|
| 28 |
+
#endif /* __cplusplus */
|
| 29 |
+
|
| 30 |
+
enum _MnoteCanonTag {
|
| 31 |
+
MNOTE_CANON_TAG_UNKNOWN_0 = 0x0,
|
| 32 |
+
MNOTE_CANON_TAG_SETTINGS_1 = 0x1,
|
| 33 |
+
MNOTE_CANON_TAG_FOCAL_LENGTH = 0x2,
|
| 34 |
+
MNOTE_CANON_TAG_UNKNOWN_3 = 0x3,
|
| 35 |
+
MNOTE_CANON_TAG_SETTINGS_2 = 0x4,
|
| 36 |
+
MNOTE_CANON_TAG_PANORAMA = 0x5,
|
| 37 |
+
MNOTE_CANON_TAG_IMAGE_TYPE = 0x6,
|
| 38 |
+
MNOTE_CANON_TAG_FIRMWARE = 0x7,
|
| 39 |
+
MNOTE_CANON_TAG_IMAGE_NUMBER = 0x8,
|
| 40 |
+
MNOTE_CANON_TAG_OWNER = 0x9,
|
| 41 |
+
MNOTE_CANON_TAG_UNKNOWN_10 = 0xa,
|
| 42 |
+
MNOTE_CANON_TAG_SERIAL_NUMBER = 0xc,
|
| 43 |
+
MNOTE_CANON_TAG_UNKNOWN_13 = 0xd,
|
| 44 |
+
MNOTE_CANON_TAG_CUSTOM_FUNCS = 0xf,
|
| 45 |
+
MNOTE_CANON_TAG_COLOR_INFORMATION = 0xa0
|
| 46 |
+
};
|
| 47 |
+
typedef enum _MnoteCanonTag MnoteCanonTag;
|
| 48 |
+
|
| 49 |
+
const char *mnote_canon_tag_get_name (MnoteCanonTag);
|
| 50 |
+
const char *mnote_canon_tag_get_name_sub (MnoteCanonTag, unsigned int, ExifDataOption);
|
| 51 |
+
const char *mnote_canon_tag_get_title (MnoteCanonTag);
|
| 52 |
+
const char *mnote_canon_tag_get_title_sub (MnoteCanonTag, unsigned int, ExifDataOption);
|
| 53 |
+
const char *mnote_canon_tag_get_description (MnoteCanonTag);
|
| 54 |
+
|
| 55 |
+
#ifdef __cplusplus
|
| 56 |
+
}
|
| 57 |
+
#endif /* __cplusplus */
|
| 58 |
+
|
| 59 |
+
#endif /* __MNOTE_CANON_TAG_H__ */
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-byte-order.c
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* exif-byte-order.c
|
| 2 |
+
*
|
| 3 |
+
* Copyright (c) 2002 Lutz Mueller <[email protected]>
|
| 4 |
+
*
|
| 5 |
+
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#include <config.h>
|
| 22 |
+
|
| 23 |
+
#include <libexif/exif-byte-order.h>
|
| 24 |
+
#include <libexif/i18n.h>
|
| 25 |
+
|
| 26 |
+
#include <stdlib.h>
|
| 27 |
+
|
| 28 |
+
const char *
|
| 29 |
+
exif_byte_order_get_name (ExifByteOrder order)
|
| 30 |
+
{
|
| 31 |
+
switch (order) {
|
| 32 |
+
case EXIF_BYTE_ORDER_MOTOROLA:
|
| 33 |
+
return (_("Motorola"));
|
| 34 |
+
case EXIF_BYTE_ORDER_INTEL:
|
| 35 |
+
return (_("Intel"));
|
| 36 |
+
default:
|
| 37 |
+
return NULL;
|
| 38 |
+
}
|
| 39 |
+
}
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-byte-order.h
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*! \file exif-byte-order.h
|
| 2 |
+
* \brief Defines the ExifByteOrder enum and the associated functions.
|
| 3 |
+
*/
|
| 4 |
+
/*
|
| 5 |
+
* Copyright (c) 2002 Lutz Mueller <[email protected]>
|
| 6 |
+
*
|
| 7 |
+
* This library is free software; you can redistribute it and/or
|
| 8 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 9 |
+
* License as published by the Free Software Foundation; either
|
| 10 |
+
* version 2 of the License, or (at your option) any later version.
|
| 11 |
+
*
|
| 12 |
+
* This library is distributed in the hope that it will be useful,
|
| 13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 15 |
+
* Lesser General Public License for more details.
|
| 16 |
+
*
|
| 17 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 18 |
+
* License along with this library; if not, write to the
|
| 19 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 20 |
+
* Boston, MA 02110-1301 USA.
|
| 21 |
+
*/
|
| 22 |
+
|
| 23 |
+
#ifndef __EXIF_BYTE_ORDER_H__
|
| 24 |
+
#define __EXIF_BYTE_ORDER_H__
|
| 25 |
+
|
| 26 |
+
#ifdef __cplusplus
|
| 27 |
+
extern "C" {
|
| 28 |
+
#endif /* __cplusplus */
|
| 29 |
+
|
| 30 |
+
/*! Which byte order to use */
|
| 31 |
+
typedef enum {
|
| 32 |
+
/*! Big-endian byte order */
|
| 33 |
+
EXIF_BYTE_ORDER_MOTOROLA,
|
| 34 |
+
/*! Little-endian byte order */
|
| 35 |
+
EXIF_BYTE_ORDER_INTEL
|
| 36 |
+
} ExifByteOrder;
|
| 37 |
+
|
| 38 |
+
/*! Return a short, localized, textual name for the given byte order.
|
| 39 |
+
* \param[in] order byte order
|
| 40 |
+
* \return localized textual name of the byte order, or NULL if unknown
|
| 41 |
+
*/
|
| 42 |
+
const char *exif_byte_order_get_name (ExifByteOrder order);
|
| 43 |
+
|
| 44 |
+
#ifdef __cplusplus
|
| 45 |
+
}
|
| 46 |
+
#endif /* __cplusplus */
|
| 47 |
+
|
| 48 |
+
#endif /* __EXIF_BYTE_ORDER_H__ */
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-content.c
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#include <config.h>
|
| 22 |
+
|
| 23 |
+
#include <libexif/exif-content.h>
|
| 24 |
+
#include <libexif/exif-system.h>
|
| 25 |
+
|
| 26 |
+
#include <stdlib.h>
|
| 27 |
+
#include <stdio.h>
|
| 28 |
+
#include <string.h>
|
| 29 |
+
|
| 30 |
+
/* unused constant
|
| 31 |
+
* static const unsigned char ExifHeader[] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00};
|
| 32 |
+
*/
|
| 33 |
+
|
| 34 |
+
struct _ExifContentPrivate
|
| 35 |
+
{
|
| 36 |
+
unsigned int ref_count;
|
| 37 |
+
|
| 38 |
+
ExifMem *mem;
|
| 39 |
+
ExifLog *log;
|
| 40 |
+
};
|
| 41 |
+
|
| 42 |
+
ExifContent *
|
| 43 |
+
exif_content_new (void)
|
| 44 |
+
{
|
| 45 |
+
ExifMem *mem = exif_mem_new_default ();
|
| 46 |
+
ExifContent *content = exif_content_new_mem (mem);
|
| 47 |
+
|
| 48 |
+
exif_mem_unref (mem);
|
| 49 |
+
|
| 50 |
+
return content;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
ExifContent *
|
| 54 |
+
exif_content_new_mem (ExifMem *mem)
|
| 55 |
+
{
|
| 56 |
+
ExifContent *content;
|
| 57 |
+
|
| 58 |
+
if (!mem) return NULL;
|
| 59 |
+
|
| 60 |
+
content = exif_mem_alloc (mem, (ExifLong) sizeof (ExifContent));
|
| 61 |
+
if (!content)
|
| 62 |
+
return NULL;
|
| 63 |
+
content->priv = exif_mem_alloc (mem,
|
| 64 |
+
(ExifLong) sizeof (ExifContentPrivate));
|
| 65 |
+
if (!content->priv) {
|
| 66 |
+
exif_mem_free (mem, content);
|
| 67 |
+
return NULL;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
content->priv->ref_count = 1;
|
| 71 |
+
|
| 72 |
+
content->priv->mem = mem;
|
| 73 |
+
exif_mem_ref (mem);
|
| 74 |
+
|
| 75 |
+
return content;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
void
|
| 79 |
+
exif_content_ref (ExifContent *content)
|
| 80 |
+
{
|
| 81 |
+
if (!content)
|
| 82 |
+
return;
|
| 83 |
+
|
| 84 |
+
content->priv->ref_count++;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
void
|
| 88 |
+
exif_content_unref (ExifContent *content)
|
| 89 |
+
{
|
| 90 |
+
if (!content)
|
| 91 |
+
return;
|
| 92 |
+
|
| 93 |
+
content->priv->ref_count--;
|
| 94 |
+
if (!content->priv->ref_count)
|
| 95 |
+
exif_content_free (content);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
void
|
| 99 |
+
exif_content_free (ExifContent *content)
|
| 100 |
+
{
|
| 101 |
+
ExifMem *mem = (content && content->priv) ? content->priv->mem : NULL;
|
| 102 |
+
unsigned int i;
|
| 103 |
+
|
| 104 |
+
if (!content) return;
|
| 105 |
+
|
| 106 |
+
for (i = 0; i < content->count; i++)
|
| 107 |
+
exif_entry_unref (content->entries[i]);
|
| 108 |
+
exif_mem_free (mem, content->entries);
|
| 109 |
+
|
| 110 |
+
if (content->priv) {
|
| 111 |
+
exif_log_unref (content->priv->log);
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
exif_mem_free (mem, content->priv);
|
| 115 |
+
exif_mem_free (mem, content);
|
| 116 |
+
exif_mem_unref (mem);
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
void
|
| 120 |
+
exif_content_dump (ExifContent *content, unsigned int indent)
|
| 121 |
+
{
|
| 122 |
+
char buf[1024];
|
| 123 |
+
unsigned int i, l;
|
| 124 |
+
|
| 125 |
+
if (!content)
|
| 126 |
+
return;
|
| 127 |
+
|
| 128 |
+
l = MIN(sizeof(buf)-1, 2*indent);
|
| 129 |
+
memset(buf, ' ', l);
|
| 130 |
+
buf[l] = '\0';
|
| 131 |
+
|
| 132 |
+
printf ("%sDumping exif content (%u entries)...\n", buf,
|
| 133 |
+
content->count);
|
| 134 |
+
for (i = 0; i < content->count; i++)
|
| 135 |
+
exif_entry_dump (content->entries[i], indent + 1);
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
void
|
| 139 |
+
exif_content_add_entry (ExifContent *c, ExifEntry *entry)
|
| 140 |
+
{
|
| 141 |
+
ExifEntry **entries;
|
| 142 |
+
if (!c || !c->priv || !entry || entry->parent) return;
|
| 143 |
+
|
| 144 |
+
/* One tag can only be added once to an IFD. */
|
| 145 |
+
if (exif_content_get_entry (c, entry->tag)) {
|
| 146 |
+
exif_log (c->priv->log, EXIF_LOG_CODE_DEBUG, "ExifContent",
|
| 147 |
+
"An attempt has been made to add "
|
| 148 |
+
"the tag '%s' twice to an IFD. This is against "
|
| 149 |
+
"specification.", exif_tag_get_name (entry->tag));
|
| 150 |
+
return;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
entries = exif_mem_realloc (c->priv->mem,
|
| 154 |
+
c->entries, sizeof (ExifEntry*) * (c->count + 1));
|
| 155 |
+
if (!entries) return;
|
| 156 |
+
entry->parent = c;
|
| 157 |
+
entries[c->count++] = entry;
|
| 158 |
+
c->entries = entries;
|
| 159 |
+
exif_entry_ref (entry);
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
void
|
| 163 |
+
exif_content_remove_entry (ExifContent *c, ExifEntry *e)
|
| 164 |
+
{
|
| 165 |
+
unsigned int i;
|
| 166 |
+
ExifEntry **t, *temp;
|
| 167 |
+
|
| 168 |
+
if (!c || !c->priv || !e || (e->parent != c)) return;
|
| 169 |
+
|
| 170 |
+
/* Search the entry */
|
| 171 |
+
for (i = 0; i < c->count; i++)
|
| 172 |
+
if (c->entries[i] == e)
|
| 173 |
+
break;
|
| 174 |
+
|
| 175 |
+
if (i == c->count)
|
| 176 |
+
return;
|
| 177 |
+
|
| 178 |
+
/* Remove the entry */
|
| 179 |
+
temp = c->entries[c->count-1];
|
| 180 |
+
if (c->count > 1) {
|
| 181 |
+
t = exif_mem_realloc (c->priv->mem, c->entries,
|
| 182 |
+
sizeof(ExifEntry*) * (c->count - 1));
|
| 183 |
+
if (!t) {
|
| 184 |
+
return;
|
| 185 |
+
}
|
| 186 |
+
c->entries = t;
|
| 187 |
+
c->count--;
|
| 188 |
+
if (i != c->count) { /* we deallocated the last slot already */
|
| 189 |
+
memmove (&t[i], &t[i + 1], sizeof (ExifEntry*) * (c->count - i - 1));
|
| 190 |
+
t[c->count-1] = temp;
|
| 191 |
+
}
|
| 192 |
+
} else {
|
| 193 |
+
exif_mem_free (c->priv->mem, c->entries);
|
| 194 |
+
c->entries = NULL;
|
| 195 |
+
c->count = 0;
|
| 196 |
+
}
|
| 197 |
+
e->parent = NULL;
|
| 198 |
+
exif_entry_unref (e);
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
ExifEntry *
|
| 202 |
+
exif_content_get_entry (ExifContent *content, ExifTag tag)
|
| 203 |
+
{
|
| 204 |
+
unsigned int i;
|
| 205 |
+
|
| 206 |
+
if (!content)
|
| 207 |
+
return (NULL);
|
| 208 |
+
|
| 209 |
+
for (i = 0; i < content->count; i++)
|
| 210 |
+
if (content->entries[i]->tag == tag)
|
| 211 |
+
return (content->entries[i]);
|
| 212 |
+
return (NULL);
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
void
|
| 216 |
+
exif_content_foreach_entry (ExifContent *content,
|
| 217 |
+
ExifContentForeachEntryFunc func, void *data)
|
| 218 |
+
{
|
| 219 |
+
unsigned int i;
|
| 220 |
+
|
| 221 |
+
if (!content || !func)
|
| 222 |
+
return;
|
| 223 |
+
|
| 224 |
+
for (i = 0; i < content->count; i++)
|
| 225 |
+
func (content->entries[i], data);
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
void
|
| 229 |
+
exif_content_log (ExifContent *content, ExifLog *log)
|
| 230 |
+
{
|
| 231 |
+
if (!content || !content->priv || !log || content->priv->log == log)
|
| 232 |
+
return;
|
| 233 |
+
|
| 234 |
+
if (content->priv->log) exif_log_unref (content->priv->log);
|
| 235 |
+
content->priv->log = log;
|
| 236 |
+
exif_log_ref (log);
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
ExifIfd
|
| 240 |
+
exif_content_get_ifd (ExifContent *c)
|
| 241 |
+
{
|
| 242 |
+
if (!c || !c->parent) return EXIF_IFD_COUNT;
|
| 243 |
+
|
| 244 |
+
return
|
| 245 |
+
((c)->parent->ifd[EXIF_IFD_EXIF] == (c)) ? EXIF_IFD_EXIF :
|
| 246 |
+
((c)->parent->ifd[EXIF_IFD_0] == (c)) ? EXIF_IFD_0 :
|
| 247 |
+
((c)->parent->ifd[EXIF_IFD_1] == (c)) ? EXIF_IFD_1 :
|
| 248 |
+
((c)->parent->ifd[EXIF_IFD_GPS] == (c)) ? EXIF_IFD_GPS :
|
| 249 |
+
((c)->parent->ifd[EXIF_IFD_INTEROPERABILITY] == (c)) ? EXIF_IFD_INTEROPERABILITY :
|
| 250 |
+
EXIF_IFD_COUNT;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
static void
|
| 254 |
+
fix_func (ExifEntry *e, void *UNUSED(data))
|
| 255 |
+
{
|
| 256 |
+
exif_entry_fix (e);
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
/*!
|
| 260 |
+
* Check if this entry is unknown and if so, delete it.
|
| 261 |
+
* \note Be careful calling this function in a loop. Deleting an entry from
|
| 262 |
+
* an ExifContent changes the index of subsequent entries, as well as the
|
| 263 |
+
* total size of the entries array.
|
| 264 |
+
*/
|
| 265 |
+
static void
|
| 266 |
+
remove_not_recorded (ExifEntry *e, void *UNUSED(data))
|
| 267 |
+
{
|
| 268 |
+
ExifIfd ifd = exif_entry_get_ifd(e) ;
|
| 269 |
+
ExifContent *c = e->parent;
|
| 270 |
+
ExifDataType dt = exif_data_get_data_type (c->parent);
|
| 271 |
+
ExifTag t = e->tag;
|
| 272 |
+
|
| 273 |
+
if (exif_tag_get_support_level_in_ifd (t, ifd, dt) ==
|
| 274 |
+
EXIF_SUPPORT_LEVEL_NOT_RECORDED) {
|
| 275 |
+
exif_log (c->priv->log, EXIF_LOG_CODE_DEBUG, "exif-content",
|
| 276 |
+
"Tag 0x%04x is not recorded in IFD '%s' and has therefore been "
|
| 277 |
+
"removed.", t, exif_ifd_get_name (ifd));
|
| 278 |
+
exif_content_remove_entry (c, e);
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
void
|
| 284 |
+
exif_content_fix (ExifContent *c)
|
| 285 |
+
{
|
| 286 |
+
ExifIfd ifd = exif_content_get_ifd (c);
|
| 287 |
+
ExifDataType dt;
|
| 288 |
+
ExifEntry *e;
|
| 289 |
+
unsigned int i, num;
|
| 290 |
+
|
| 291 |
+
if (!c)
|
| 292 |
+
return;
|
| 293 |
+
|
| 294 |
+
dt = exif_data_get_data_type (c->parent);
|
| 295 |
+
|
| 296 |
+
/*
|
| 297 |
+
* First of all, fix all existing entries.
|
| 298 |
+
*/
|
| 299 |
+
exif_content_foreach_entry (c, fix_func, NULL);
|
| 300 |
+
|
| 301 |
+
/*
|
| 302 |
+
* Go through each tag and if it's not recorded, remove it. If one
|
| 303 |
+
* is removed, exif_content_foreach_entry() will skip the next entry,
|
| 304 |
+
* so if this happens do the loop again from the beginning to ensure
|
| 305 |
+
* they're all checked. This could be avoided if we stop relying on
|
| 306 |
+
* exif_content_foreach_entry but loop intelligently here.
|
| 307 |
+
*/
|
| 308 |
+
do {
|
| 309 |
+
num = c->count;
|
| 310 |
+
exif_content_foreach_entry (c, remove_not_recorded, NULL);
|
| 311 |
+
} while (num != c->count);
|
| 312 |
+
|
| 313 |
+
/*
|
| 314 |
+
* Then check for non-existing mandatory tags and create them if needed
|
| 315 |
+
*/
|
| 316 |
+
num = exif_tag_table_count();
|
| 317 |
+
for (i = 0; i < num; ++i) {
|
| 318 |
+
const ExifTag t = exif_tag_table_get_tag (i);
|
| 319 |
+
if (exif_tag_get_support_level_in_ifd (t, ifd, dt) ==
|
| 320 |
+
EXIF_SUPPORT_LEVEL_MANDATORY) {
|
| 321 |
+
if (exif_content_get_entry (c, t))
|
| 322 |
+
/* This tag already exists */
|
| 323 |
+
continue;
|
| 324 |
+
exif_log (c->priv->log, EXIF_LOG_CODE_DEBUG, "exif-content",
|
| 325 |
+
"Tag '%s' is mandatory in IFD '%s' and has therefore been added.",
|
| 326 |
+
exif_tag_get_name_in_ifd (t, ifd), exif_ifd_get_name (ifd));
|
| 327 |
+
e = exif_entry_new ();
|
| 328 |
+
exif_content_add_entry (c, e);
|
| 329 |
+
exif_entry_initialize (e, t);
|
| 330 |
+
exif_entry_unref (e);
|
| 331 |
+
}
|
| 332 |
+
}
|
| 333 |
+
}
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-content.h
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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* This library is free software; you can redistribute it and/or
|
| 8 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 9 |
+
* License as published by the Free Software Foundation; either
|
| 10 |
+
* version 2 of the License, or (at your option) any later version.
|
| 11 |
+
*
|
| 12 |
+
* This library is distributed in the hope that it will be useful,
|
| 13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 15 |
+
* Lesser General Public License for more details.
|
| 16 |
+
*
|
| 17 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 18 |
+
* License along with this library; if not, write to the
|
| 19 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 20 |
+
* Boston, MA 02110-1301 USA.
|
| 21 |
+
*/
|
| 22 |
+
|
| 23 |
+
#ifndef __EXIF_CONTENT_H__
|
| 24 |
+
#define __EXIF_CONTENT_H__
|
| 25 |
+
|
| 26 |
+
#ifdef __cplusplus
|
| 27 |
+
extern "C" {
|
| 28 |
+
#endif /* __cplusplus */
|
| 29 |
+
|
| 30 |
+
/*! Holds all EXIF tags in a single IFD */
|
| 31 |
+
typedef struct _ExifContent ExifContent;
|
| 32 |
+
typedef struct _ExifContentPrivate ExifContentPrivate;
|
| 33 |
+
|
| 34 |
+
#include <libexif/exif-tag.h>
|
| 35 |
+
#include <libexif/exif-entry.h>
|
| 36 |
+
#include <libexif/exif-data.h>
|
| 37 |
+
#include <libexif/exif-log.h>
|
| 38 |
+
#include <libexif/exif-mem.h>
|
| 39 |
+
|
| 40 |
+
struct _ExifContent
|
| 41 |
+
{
|
| 42 |
+
ExifEntry **entries;
|
| 43 |
+
unsigned int count;
|
| 44 |
+
|
| 45 |
+
/*! Data containing this content */
|
| 46 |
+
ExifData *parent;
|
| 47 |
+
|
| 48 |
+
ExifContentPrivate *priv;
|
| 49 |
+
};
|
| 50 |
+
|
| 51 |
+
/* Lifecycle */
|
| 52 |
+
|
| 53 |
+
/*! Reserve memory for and initialize a new #ExifContent.
|
| 54 |
+
*
|
| 55 |
+
* \return new allocated #ExifContent, or NULL on error
|
| 56 |
+
*
|
| 57 |
+
* \see exif_content_new_mem, exif_content_unref
|
| 58 |
+
*/
|
| 59 |
+
ExifContent *exif_content_new (void);
|
| 60 |
+
|
| 61 |
+
/*! Reserve memory for and initialize new #ExifContent using the specified
|
| 62 |
+
* memory allocator.
|
| 63 |
+
*
|
| 64 |
+
* \return new allocated #ExifContent, or NULL on error
|
| 65 |
+
*
|
| 66 |
+
* \see exif_content_new, exif_content_unref
|
| 67 |
+
*/
|
| 68 |
+
ExifContent *exif_content_new_mem (ExifMem *);
|
| 69 |
+
|
| 70 |
+
/*! Increase reference counter for #ExifContent.
|
| 71 |
+
*
|
| 72 |
+
* \param[in] content #ExifContent
|
| 73 |
+
*
|
| 74 |
+
* \see exif_content_unref
|
| 75 |
+
*/
|
| 76 |
+
void exif_content_ref (ExifContent *content);
|
| 77 |
+
|
| 78 |
+
/*! Decrease reference counter for #ExifContent.
|
| 79 |
+
* When the reference count drops to zero, free the content.
|
| 80 |
+
*
|
| 81 |
+
* \param[in] content #ExifContent
|
| 82 |
+
*/
|
| 83 |
+
void exif_content_unref (ExifContent *content);
|
| 84 |
+
|
| 85 |
+
/*! Actually free the #ExifContent.
|
| 86 |
+
*
|
| 87 |
+
* \deprecated Should not be called directly. Use #exif_content_ref and
|
| 88 |
+
* #exif_content_unref instead.
|
| 89 |
+
*
|
| 90 |
+
* \param[in] content #ExifContent
|
| 91 |
+
*/
|
| 92 |
+
void exif_content_free (ExifContent *content);
|
| 93 |
+
|
| 94 |
+
/*! Add an EXIF tag to an IFD.
|
| 95 |
+
* If this tag already exists in the IFD, this function does nothing.
|
| 96 |
+
* \pre The "tag" member of the entry must be set on entry.
|
| 97 |
+
*
|
| 98 |
+
* \param[out] c IFD
|
| 99 |
+
* \param[in] entry EXIF entry to add
|
| 100 |
+
*/
|
| 101 |
+
void exif_content_add_entry (ExifContent *c, ExifEntry *entry);
|
| 102 |
+
|
| 103 |
+
/*! Remove an EXIF tag from an IFD.
|
| 104 |
+
* If this tag does not exist in the IFD, this function does nothing.
|
| 105 |
+
*
|
| 106 |
+
* \param[out] c IFD
|
| 107 |
+
* \param[in] e EXIF entry to remove
|
| 108 |
+
*/
|
| 109 |
+
void exif_content_remove_entry (ExifContent *c, ExifEntry *e);
|
| 110 |
+
|
| 111 |
+
/*! Return the #ExifEntry in this IFD corresponding to the given tag.
|
| 112 |
+
* This is a pointer into a member of the #ExifContent array and must NOT be
|
| 113 |
+
* freed or unrefed by the caller.
|
| 114 |
+
*
|
| 115 |
+
* \param[in] content EXIF content for an IFD
|
| 116 |
+
* \param[in] tag EXIF tag to return
|
| 117 |
+
* \return #ExifEntry of the tag, or NULL on error
|
| 118 |
+
*/
|
| 119 |
+
ExifEntry *exif_content_get_entry (ExifContent *content, ExifTag tag);
|
| 120 |
+
|
| 121 |
+
/*! Fix the IFD to bring it into specification. Call #exif_entry_fix on
|
| 122 |
+
* each entry in this IFD to fix existing entries, create any new entries
|
| 123 |
+
* that are mandatory in this IFD but do not yet exist, and remove any
|
| 124 |
+
* entries that are not allowed in this IFD.
|
| 125 |
+
*
|
| 126 |
+
* \param[in,out] c EXIF content for an IFD
|
| 127 |
+
*/
|
| 128 |
+
void exif_content_fix (ExifContent *c);
|
| 129 |
+
|
| 130 |
+
typedef void (* ExifContentForeachEntryFunc) (ExifEntry *, void *user_data);
|
| 131 |
+
|
| 132 |
+
/*! Executes function on each EXIF tag in this IFD in turn.
|
| 133 |
+
* The tags will not necessarily be visited in numerical order.
|
| 134 |
+
*
|
| 135 |
+
* \param[in,out] content IFD over which to iterate
|
| 136 |
+
* \param[in] func function to call for each entry
|
| 137 |
+
* \param[in] user_data data to pass into func on each call
|
| 138 |
+
*/
|
| 139 |
+
void exif_content_foreach_entry (ExifContent *content,
|
| 140 |
+
ExifContentForeachEntryFunc func,
|
| 141 |
+
void *user_data);
|
| 142 |
+
|
| 143 |
+
/*! Return the IFD number in which the given #ExifContent is found.
|
| 144 |
+
*
|
| 145 |
+
* \param[in] c an #ExifContent*
|
| 146 |
+
* \return IFD number, or #EXIF_IFD_COUNT on error
|
| 147 |
+
*/
|
| 148 |
+
ExifIfd exif_content_get_ifd (ExifContent *c);
|
| 149 |
+
|
| 150 |
+
/*! Return a textual representation of the EXIF data for a tag.
|
| 151 |
+
*
|
| 152 |
+
* \param[in] c #ExifContent* for an IFD
|
| 153 |
+
* \param[in] t #ExifTag to return
|
| 154 |
+
* \param[out] v char* buffer in which to store value
|
| 155 |
+
* \param[in] m unsigned int length of the buffer v
|
| 156 |
+
* \return the v pointer, or NULL on error
|
| 157 |
+
*/
|
| 158 |
+
#define exif_content_get_value(c,t,v,m) \
|
| 159 |
+
(exif_content_get_entry (c,t) ? \
|
| 160 |
+
exif_entry_get_value (exif_content_get_entry (c,t),v,m) : NULL)
|
| 161 |
+
|
| 162 |
+
/*! Dump contents of the IFD to stdout.
|
| 163 |
+
* This is intended for diagnostic purposes only.
|
| 164 |
+
*
|
| 165 |
+
* \param[in] content IFD data
|
| 166 |
+
* \param[in] indent how many levels deep to indent the data
|
| 167 |
+
*/
|
| 168 |
+
void exif_content_dump (ExifContent *content, unsigned int indent);
|
| 169 |
+
|
| 170 |
+
/*! Set the log message object for this IFD.
|
| 171 |
+
*
|
| 172 |
+
* \param[in] content IFD
|
| 173 |
+
* \param[in] log #ExifLog*
|
| 174 |
+
*/
|
| 175 |
+
void exif_content_log (ExifContent *content, ExifLog *log);
|
| 176 |
+
|
| 177 |
+
#ifdef __cplusplus
|
| 178 |
+
}
|
| 179 |
+
#endif /* __cplusplus */
|
| 180 |
+
|
| 181 |
+
#endif /* __EXIF_CONTENT_H__ */
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-data-type.h
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* exif-data-tag.h
|
| 2 |
+
*
|
| 3 |
+
* Copyright (c) 2005 Lutz Mueller <[email protected]>
|
| 4 |
+
*
|
| 5 |
+
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef __EXIF_DATA_TYPE_H__
|
| 22 |
+
#define __EXIF_DATA_TYPE_H__
|
| 23 |
+
|
| 24 |
+
#ifdef __cplusplus
|
| 25 |
+
extern "C" {
|
| 26 |
+
#endif /* __cplusplus */
|
| 27 |
+
|
| 28 |
+
/*! Represents the type of image data to which the EXIF data applies.
|
| 29 |
+
* The EXIF tags have different constraints depending on the type of
|
| 30 |
+
* image data.
|
| 31 |
+
*/
|
| 32 |
+
typedef enum {
|
| 33 |
+
EXIF_DATA_TYPE_UNCOMPRESSED_CHUNKY = 0,
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* exif-data.c
|
| 2 |
+
*
|
| 3 |
+
* Copyright (c) 2001 Lutz Mueller <[email protected]>
|
| 4 |
+
*
|
| 5 |
+
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#include <config.h>
|
| 22 |
+
|
| 23 |
+
#include <libexif/exif-mnote-data.h>
|
| 24 |
+
#include <libexif/exif-data.h>
|
| 25 |
+
#include <libexif/exif-ifd.h>
|
| 26 |
+
#include <libexif/exif-mnote-data-priv.h>
|
| 27 |
+
#include <libexif/exif-utils.h>
|
| 28 |
+
#include <libexif/exif-loader.h>
|
| 29 |
+
#include <libexif/exif-log.h>
|
| 30 |
+
#include <libexif/i18n.h>
|
| 31 |
+
#include <libexif/exif-system.h>
|
| 32 |
+
|
| 33 |
+
#include <libexif/apple/exif-mnote-data-apple.h>
|
| 34 |
+
#include <libexif/canon/exif-mnote-data-canon.h>
|
| 35 |
+
#include <libexif/fuji/exif-mnote-data-fuji.h>
|
| 36 |
+
#include <libexif/olympus/exif-mnote-data-olympus.h>
|
| 37 |
+
#include <libexif/pentax/exif-mnote-data-pentax.h>
|
| 38 |
+
|
| 39 |
+
#include <math.h>
|
| 40 |
+
#include <stdlib.h>
|
| 41 |
+
#include <stdio.h>
|
| 42 |
+
#include <string.h>
|
| 43 |
+
|
| 44 |
+
#undef JPEG_MARKER_SOI
|
| 45 |
+
#define JPEG_MARKER_SOI 0xd8
|
| 46 |
+
#undef JPEG_MARKER_APP0
|
| 47 |
+
#define JPEG_MARKER_APP0 0xe0
|
| 48 |
+
#undef JPEG_MARKER_APP1
|
| 49 |
+
#define JPEG_MARKER_APP1 0xe1
|
| 50 |
+
|
| 51 |
+
#define CHECKOVERFLOW(offset,datasize,structsize) (( offset >= datasize) || (structsize > datasize) || (offset > datasize - structsize ))
|
| 52 |
+
|
| 53 |
+
static const unsigned char ExifHeader[] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00};
|
| 54 |
+
|
| 55 |
+
struct _ExifDataPrivate
|
| 56 |
+
{
|
| 57 |
+
ExifByteOrder order;
|
| 58 |
+
|
| 59 |
+
ExifMnoteData *md;
|
| 60 |
+
|
| 61 |
+
ExifLog *log;
|
| 62 |
+
ExifMem *mem;
|
| 63 |
+
|
| 64 |
+
unsigned int ref_count;
|
| 65 |
+
|
| 66 |
+
/* Temporarily used while loading data */
|
| 67 |
+
unsigned int offset_mnote;
|
| 68 |
+
|
| 69 |
+
ExifDataOption options;
|
| 70 |
+
ExifDataType data_type;
|
| 71 |
+
};
|
| 72 |
+
|
| 73 |
+
static void *
|
| 74 |
+
exif_data_alloc (ExifData *data, unsigned int i)
|
| 75 |
+
{
|
| 76 |
+
void *d;
|
| 77 |
+
|
| 78 |
+
if (!data || !i)
|
| 79 |
+
return NULL;
|
| 80 |
+
|
| 81 |
+
d = exif_mem_alloc (data->priv->mem, i);
|
| 82 |
+
if (d)
|
| 83 |
+
return d;
|
| 84 |
+
|
| 85 |
+
EXIF_LOG_NO_MEMORY (data->priv->log, "ExifData", i);
|
| 86 |
+
return NULL;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
ExifMnoteData *
|
| 90 |
+
exif_data_get_mnote_data (ExifData *d)
|
| 91 |
+
{
|
| 92 |
+
return (d && d->priv) ? d->priv->md : NULL;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
ExifData *
|
| 96 |
+
exif_data_new (void)
|
| 97 |
+
{
|
| 98 |
+
ExifMem *mem = exif_mem_new_default ();
|
| 99 |
+
ExifData *d = exif_data_new_mem (mem);
|
| 100 |
+
|
| 101 |
+
exif_mem_unref (mem);
|
| 102 |
+
|
| 103 |
+
return d;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
ExifData *
|
| 107 |
+
exif_data_new_mem (ExifMem *mem)
|
| 108 |
+
{
|
| 109 |
+
ExifData *data;
|
| 110 |
+
unsigned int i;
|
| 111 |
+
|
| 112 |
+
if (!mem)
|
| 113 |
+
return NULL;
|
| 114 |
+
|
| 115 |
+
data = exif_mem_alloc (mem, sizeof (ExifData));
|
| 116 |
+
if (!data)
|
| 117 |
+
return (NULL);
|
| 118 |
+
data->priv = exif_mem_alloc (mem, sizeof (ExifDataPrivate));
|
| 119 |
+
if (!data->priv) {
|
| 120 |
+
exif_mem_free (mem, data);
|
| 121 |
+
return (NULL);
|
| 122 |
+
}
|
| 123 |
+
data->priv->ref_count = 1;
|
| 124 |
+
|
| 125 |
+
data->priv->mem = mem;
|
| 126 |
+
exif_mem_ref (mem);
|
| 127 |
+
|
| 128 |
+
for (i = 0; i < EXIF_IFD_COUNT; i++) {
|
| 129 |
+
data->ifd[i] = exif_content_new_mem (data->priv->mem);
|
| 130 |
+
if (!data->ifd[i]) {
|
| 131 |
+
exif_data_free (data);
|
| 132 |
+
return (NULL);
|
| 133 |
+
}
|
| 134 |
+
data->ifd[i]->parent = data;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
/* Default options */
|
| 138 |
+
#ifndef NO_VERBOSE_TAG_STRINGS
|
| 139 |
+
/*
|
| 140 |
+
* When the tag list is compiled away, setting this option prevents
|
| 141 |
+
* any tags from being loaded
|
| 142 |
+
*/
|
| 143 |
+
exif_data_set_option (data, EXIF_DATA_OPTION_IGNORE_UNKNOWN_TAGS);
|
| 144 |
+
#endif
|
| 145 |
+
exif_data_set_option (data, EXIF_DATA_OPTION_FOLLOW_SPECIFICATION);
|
| 146 |
+
|
| 147 |
+
/* Default data type: none */
|
| 148 |
+
exif_data_set_data_type (data, EXIF_DATA_TYPE_COUNT);
|
| 149 |
+
|
| 150 |
+
return (data);
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
ExifData *
|
| 154 |
+
exif_data_new_from_data (const unsigned char *data, unsigned int size)
|
| 155 |
+
{
|
| 156 |
+
ExifData *edata;
|
| 157 |
+
|
| 158 |
+
edata = exif_data_new ();
|
| 159 |
+
exif_data_load_data (edata, data, size);
|
| 160 |
+
return (edata);
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
static int
|
| 164 |
+
exif_data_load_data_entry (ExifData *data, ExifEntry *entry,
|
| 165 |
+
const unsigned char *d,
|
| 166 |
+
unsigned int size, unsigned int offset)
|
| 167 |
+
{
|
| 168 |
+
unsigned int s, doff;
|
| 169 |
+
|
| 170 |
+
entry->tag = exif_get_short (d + offset + 0, data->priv->order);
|
| 171 |
+
entry->format = exif_get_short (d + offset + 2, data->priv->order);
|
| 172 |
+
entry->components = exif_get_long (d + offset + 4, data->priv->order);
|
| 173 |
+
|
| 174 |
+
/* FIXME: should use exif_tag_get_name_in_ifd here but entry->parent
|
| 175 |
+
* has not been set yet
|
| 176 |
+
*/
|
| 177 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 178 |
+
"Loading entry 0x%x ('%s')...", entry->tag,
|
| 179 |
+
exif_tag_get_name (entry->tag));
|
| 180 |
+
|
| 181 |
+
/* {0,1,2,4,8} x { 0x00000000 .. 0xffffffff }
|
| 182 |
+
* -> { 0x000000000 .. 0x7fffffff8 } */
|
| 183 |
+
s = exif_format_get_size(entry->format) * entry->components;
|
| 184 |
+
if ((s < entry->components) || (s == 0)){
|
| 185 |
+
return 0;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
/*
|
| 189 |
+
* Size? If bigger than 4 bytes, the actual data is not
|
| 190 |
+
* in the entry but somewhere else (offset).
|
| 191 |
+
*/
|
| 192 |
+
if (s > 4)
|
| 193 |
+
doff = exif_get_long (d + offset + 8, data->priv->order);
|
| 194 |
+
else
|
| 195 |
+
doff = offset + 8;
|
| 196 |
+
|
| 197 |
+
/* Sanity checks */
|
| 198 |
+
if (doff >= size) {
|
| 199 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 200 |
+
"Tag starts past end of buffer (%u > %u)", doff, size);
|
| 201 |
+
return 0;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
if (s > size - doff) {
|
| 205 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 206 |
+
"Tag data goes past end of buffer (%u > %u)", doff+s, size);
|
| 207 |
+
return 0;
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
entry->data = exif_data_alloc (data, s);
|
| 211 |
+
if (entry->data) {
|
| 212 |
+
entry->size = s;
|
| 213 |
+
memcpy (entry->data, d + doff, s);
|
| 214 |
+
} else {
|
| 215 |
+
EXIF_LOG_NO_MEMORY(data->priv->log, "ExifData", s);
|
| 216 |
+
return 0;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
/* If this is the MakerNote, remember the offset */
|
| 220 |
+
if (entry->tag == EXIF_TAG_MAKER_NOTE) {
|
| 221 |
+
if (!entry->data) {
|
| 222 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 223 |
+
"MakerNote found with empty data");
|
| 224 |
+
} else if (entry->size > 6) {
|
| 225 |
+
exif_log (data->priv->log,
|
| 226 |
+
EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 227 |
+
"MakerNote found (%02x %02x %02x %02x "
|
| 228 |
+
"%02x %02x %02x...).",
|
| 229 |
+
entry->data[0], entry->data[1], entry->data[2],
|
| 230 |
+
entry->data[3], entry->data[4], entry->data[5],
|
| 231 |
+
entry->data[6]);
|
| 232 |
+
}
|
| 233 |
+
data->priv->offset_mnote = doff;
|
| 234 |
+
}
|
| 235 |
+
return 1;
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
static void
|
| 239 |
+
exif_data_save_data_entry (ExifData *data, ExifEntry *e,
|
| 240 |
+
unsigned char **d, unsigned int *ds,
|
| 241 |
+
unsigned int offset)
|
| 242 |
+
{
|
| 243 |
+
unsigned int doff, s;
|
| 244 |
+
unsigned int ts;
|
| 245 |
+
|
| 246 |
+
if (!data || !data->priv)
|
| 247 |
+
return;
|
| 248 |
+
|
| 249 |
+
/*
|
| 250 |
+
* Each entry is 12 bytes long. The memory for the entry has
|
| 251 |
+
* already been allocated.
|
| 252 |
+
*/
|
| 253 |
+
exif_set_short (*d + 6 + offset + 0,
|
| 254 |
+
data->priv->order, (ExifShort) e->tag);
|
| 255 |
+
exif_set_short (*d + 6 + offset + 2,
|
| 256 |
+
data->priv->order, (ExifShort) e->format);
|
| 257 |
+
|
| 258 |
+
if (!(data->priv->options & EXIF_DATA_OPTION_DONT_CHANGE_MAKER_NOTE)) {
|
| 259 |
+
/* If this is the maker note tag, update it. */
|
| 260 |
+
if ((e->tag == EXIF_TAG_MAKER_NOTE) && data->priv->md) {
|
| 261 |
+
/* TODO: this is using the wrong ExifMem to free e->data */
|
| 262 |
+
exif_mem_free (data->priv->mem, e->data);
|
| 263 |
+
e->data = NULL;
|
| 264 |
+
e->size = 0;
|
| 265 |
+
exif_mnote_data_set_offset (data->priv->md, *ds - 6);
|
| 266 |
+
exif_mnote_data_save (data->priv->md, &e->data, &e->size);
|
| 267 |
+
e->components = e->size;
|
| 268 |
+
if (exif_format_get_size (e->format) != 1) {
|
| 269 |
+
/* e->format is taken from input code,
|
| 270 |
+
* but we need to make sure it is a 1 byte
|
| 271 |
+
* entity due to the multiplication below. */
|
| 272 |
+
e->format = EXIF_FORMAT_UNDEFINED;
|
| 273 |
+
}
|
| 274 |
+
}
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
exif_set_long (*d + 6 + offset + 4,
|
| 278 |
+
data->priv->order, e->components);
|
| 279 |
+
|
| 280 |
+
/*
|
| 281 |
+
* Size? If bigger than 4 bytes, the actual data is not in
|
| 282 |
+
* the entry but somewhere else.
|
| 283 |
+
*/
|
| 284 |
+
s = exif_format_get_size (e->format) * e->components;
|
| 285 |
+
if (s > 4) {
|
| 286 |
+
unsigned char *t;
|
| 287 |
+
doff = *ds - 6;
|
| 288 |
+
ts = *ds + s;
|
| 289 |
+
|
| 290 |
+
/*
|
| 291 |
+
* According to the TIFF specification,
|
| 292 |
+
* the offset must be an even number. If we need to introduce
|
| 293 |
+
* a padding byte, we set it to 0.
|
| 294 |
+
*/
|
| 295 |
+
if (s & 1)
|
| 296 |
+
ts++;
|
| 297 |
+
t = exif_mem_realloc (data->priv->mem, *d, ts);
|
| 298 |
+
if (!t) {
|
| 299 |
+
EXIF_LOG_NO_MEMORY (data->priv->log, "ExifData", ts);
|
| 300 |
+
return;
|
| 301 |
+
}
|
| 302 |
+
*d = t;
|
| 303 |
+
*ds = ts;
|
| 304 |
+
exif_set_long (*d + 6 + offset + 8, data->priv->order, doff);
|
| 305 |
+
if (s & 1)
|
| 306 |
+
*(*d + *ds - 1) = '\0';
|
| 307 |
+
|
| 308 |
+
} else
|
| 309 |
+
doff = offset + 8;
|
| 310 |
+
|
| 311 |
+
/* Write the data. Fill unneeded bytes with 0. Do not crash with
|
| 312 |
+
* e->data is NULL */
|
| 313 |
+
if (e->data) {
|
| 314 |
+
unsigned int len = s;
|
| 315 |
+
if (e->size < s) len = e->size;
|
| 316 |
+
memcpy (*d + 6 + doff, e->data, len);
|
| 317 |
+
} else {
|
| 318 |
+
memset (*d + 6 + doff, 0, s);
|
| 319 |
+
}
|
| 320 |
+
if (s < 4)
|
| 321 |
+
memset (*d + 6 + doff + s, 0, (4 - s));
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
static void
|
| 325 |
+
exif_data_load_data_thumbnail (ExifData *data, const unsigned char *d,
|
| 326 |
+
unsigned int ds, ExifLong o, ExifLong s)
|
| 327 |
+
{
|
| 328 |
+
/* Sanity checks */
|
| 329 |
+
if (o >= ds) {
|
| 330 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData", "Bogus thumbnail offset (%u).", o);
|
| 331 |
+
return;
|
| 332 |
+
}
|
| 333 |
+
if (CHECKOVERFLOW(o,ds,s)) {
|
| 334 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData", "Bogus thumbnail size (%u), max would be %u.", s, ds-o);
|
| 335 |
+
return;
|
| 336 |
+
}
|
| 337 |
+
if (data->data)
|
| 338 |
+
exif_mem_free (data->priv->mem, data->data);
|
| 339 |
+
if (!(data->data = exif_data_alloc (data, s))) {
|
| 340 |
+
EXIF_LOG_NO_MEMORY (data->priv->log, "ExifData", s);
|
| 341 |
+
data->size = 0;
|
| 342 |
+
return;
|
| 343 |
+
}
|
| 344 |
+
data->size = s;
|
| 345 |
+
memcpy (data->data, d + o, s);
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
#undef CHECK_REC
|
| 349 |
+
#define CHECK_REC(i) \
|
| 350 |
+
if ((i) == ifd) { \
|
| 351 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, \
|
| 352 |
+
"ExifData", "Recursive entry in IFD " \
|
| 353 |
+
"'%s' detected. Skipping...", \
|
| 354 |
+
exif_ifd_get_name (i)); \
|
| 355 |
+
break; \
|
| 356 |
+
} \
|
| 357 |
+
if (data->ifd[(i)]->count) { \
|
| 358 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, \
|
| 359 |
+
"ExifData", "Attempt to load IFD " \
|
| 360 |
+
"'%s' multiple times detected. " \
|
| 361 |
+
"Skipping...", \
|
| 362 |
+
exif_ifd_get_name (i)); \
|
| 363 |
+
break; \
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
/*! Calculate the recursion cost added by one level of IFD loading.
|
| 367 |
+
*
|
| 368 |
+
* The work performed is related to the cost in the exponential relation
|
| 369 |
+
* work=1.1**cost
|
| 370 |
+
*/
|
| 371 |
+
static unsigned int
|
| 372 |
+
level_cost(unsigned int n)
|
| 373 |
+
{
|
| 374 |
+
static const double log_1_1 = 0.09531017980432493;
|
| 375 |
+
|
| 376 |
+
/* Adding 0.1 protects against the case where n==1 */
|
| 377 |
+
return ceil(log(n + 0.1)/log_1_1);
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
/*! Load data for an IFD.
|
| 381 |
+
*
|
| 382 |
+
* \param[in,out] data #ExifData
|
| 383 |
+
* \param[in] ifd IFD to load
|
| 384 |
+
* \param[in] d pointer to buffer containing raw IFD data
|
| 385 |
+
* \param[in] ds size of raw data in buffer at \c d
|
| 386 |
+
* \param[in] offset offset into buffer at \c d at which IFD starts
|
| 387 |
+
* \param[in] recursion_cost factor indicating how expensive this recursive
|
| 388 |
+
* call could be
|
| 389 |
+
*/
|
| 390 |
+
static void
|
| 391 |
+
exif_data_load_data_content (ExifData *data, ExifIfd ifd,
|
| 392 |
+
const unsigned char *d,
|
| 393 |
+
unsigned int ds, unsigned int offset, unsigned int recursion_cost)
|
| 394 |
+
{
|
| 395 |
+
ExifLong o, thumbnail_offset = 0, thumbnail_length = 0;
|
| 396 |
+
ExifShort n;
|
| 397 |
+
ExifEntry *entry;
|
| 398 |
+
unsigned int i;
|
| 399 |
+
ExifTag tag;
|
| 400 |
+
|
| 401 |
+
if (!data || !data->priv)
|
| 402 |
+
return;
|
| 403 |
+
|
| 404 |
+
/* check for valid ExifIfd enum range */
|
| 405 |
+
if ((((int)ifd) < 0) || ( ((int)ifd) >= EXIF_IFD_COUNT))
|
| 406 |
+
return;
|
| 407 |
+
|
| 408 |
+
if (recursion_cost > 170) {
|
| 409 |
+
/*
|
| 410 |
+
* recursion_cost is a logarithmic-scale indicator of how expensive this
|
| 411 |
+
* recursive call might end up being. It is an indicator of the depth of
|
| 412 |
+
* recursion as well as the potential for worst-case future recursive
|
| 413 |
+
* calls. Since it's difficult to tell ahead of time how often recursion
|
| 414 |
+
* will occur, this assumes the worst by assuming every tag could end up
|
| 415 |
+
* causing recursion.
|
| 416 |
+
* The value of 170 was chosen to limit typical EXIF structures to a
|
| 417 |
+
* recursive depth of about 6, but pathological ones (those with very
|
| 418 |
+
* many tags) to only 2.
|
| 419 |
+
*/
|
| 420 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA, "ExifData",
|
| 421 |
+
"Deep/expensive recursion detected!");
|
| 422 |
+
return;
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
/* Read the number of entries */
|
| 426 |
+
if (CHECKOVERFLOW(offset, ds, 2)) {
|
| 427 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA, "ExifData",
|
| 428 |
+
"Tag data past end of buffer (%u+2 > %u)", offset, ds);
|
| 429 |
+
return;
|
| 430 |
+
}
|
| 431 |
+
n = exif_get_short (d + offset, data->priv->order);
|
| 432 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 433 |
+
"Loading %hu entries...", n);
|
| 434 |
+
offset += 2;
|
| 435 |
+
|
| 436 |
+
/* Check if we have enough data. */
|
| 437 |
+
if (CHECKOVERFLOW(offset, ds, 12*n)) {
|
| 438 |
+
n = (ds - offset) / 12;
|
| 439 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 440 |
+
"Short data; only loading %hu entries...", n);
|
| 441 |
+
}
|
| 442 |
+
|
| 443 |
+
for (i = 0; i < n; i++) {
|
| 444 |
+
|
| 445 |
+
tag = exif_get_short (d + offset + 12 * i, data->priv->order);
|
| 446 |
+
switch (tag) {
|
| 447 |
+
case EXIF_TAG_EXIF_IFD_POINTER:
|
| 448 |
+
case EXIF_TAG_GPS_INFO_IFD_POINTER:
|
| 449 |
+
case EXIF_TAG_INTEROPERABILITY_IFD_POINTER:
|
| 450 |
+
case EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH:
|
| 451 |
+
case EXIF_TAG_JPEG_INTERCHANGE_FORMAT:
|
| 452 |
+
o = exif_get_long (d + offset + 12 * i + 8,
|
| 453 |
+
data->priv->order);
|
| 454 |
+
if (o >= ds) {
|
| 455 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA, "ExifData",
|
| 456 |
+
"Tag data past end of buffer (%u > %u)", offset+2, ds);
|
| 457 |
+
return;
|
| 458 |
+
}
|
| 459 |
+
/* FIXME: IFD_POINTER tags aren't marked as being in a
|
| 460 |
+
* specific IFD, so exif_tag_get_name_in_ifd won't work
|
| 461 |
+
*/
|
| 462 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 463 |
+
"Sub-IFD entry 0x%x ('%s') at %u.", tag,
|
| 464 |
+
exif_tag_get_name(tag), o);
|
| 465 |
+
switch (tag) {
|
| 466 |
+
case EXIF_TAG_EXIF_IFD_POINTER:
|
| 467 |
+
CHECK_REC (EXIF_IFD_EXIF);
|
| 468 |
+
exif_data_load_data_content (data, EXIF_IFD_EXIF, d, ds, o,
|
| 469 |
+
recursion_cost + level_cost(n));
|
| 470 |
+
break;
|
| 471 |
+
case EXIF_TAG_GPS_INFO_IFD_POINTER:
|
| 472 |
+
CHECK_REC (EXIF_IFD_GPS);
|
| 473 |
+
exif_data_load_data_content (data, EXIF_IFD_GPS, d, ds, o,
|
| 474 |
+
recursion_cost + level_cost(n));
|
| 475 |
+
break;
|
| 476 |
+
case EXIF_TAG_INTEROPERABILITY_IFD_POINTER:
|
| 477 |
+
CHECK_REC (EXIF_IFD_INTEROPERABILITY);
|
| 478 |
+
exif_data_load_data_content (data, EXIF_IFD_INTEROPERABILITY, d, ds, o,
|
| 479 |
+
recursion_cost + level_cost(n));
|
| 480 |
+
break;
|
| 481 |
+
case EXIF_TAG_JPEG_INTERCHANGE_FORMAT:
|
| 482 |
+
thumbnail_offset = o;
|
| 483 |
+
if (thumbnail_offset && thumbnail_length)
|
| 484 |
+
exif_data_load_data_thumbnail (data, d,
|
| 485 |
+
ds, thumbnail_offset,
|
| 486 |
+
thumbnail_length);
|
| 487 |
+
break;
|
| 488 |
+
case EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH:
|
| 489 |
+
thumbnail_length = o;
|
| 490 |
+
if (thumbnail_offset && thumbnail_length)
|
| 491 |
+
exif_data_load_data_thumbnail (data, d,
|
| 492 |
+
ds, thumbnail_offset,
|
| 493 |
+
thumbnail_length);
|
| 494 |
+
break;
|
| 495 |
+
default:
|
| 496 |
+
return;
|
| 497 |
+
}
|
| 498 |
+
break;
|
| 499 |
+
default:
|
| 500 |
+
|
| 501 |
+
/*
|
| 502 |
+
* If we don't know the tag, don't fail. It could be that new
|
| 503 |
+
* versions of the standard have defined additional tags. Note that
|
| 504 |
+
* 0 is a valid tag in the GPS IFD.
|
| 505 |
+
*/
|
| 506 |
+
if (!exif_tag_get_name_in_ifd (tag, ifd)) {
|
| 507 |
+
|
| 508 |
+
/*
|
| 509 |
+
* Special case: Tag and format 0. That's against specification
|
| 510 |
+
* (at least up to 2.2). But Photoshop writes it anyways.
|
| 511 |
+
*/
|
| 512 |
+
if (!memcmp (d + offset + 12 * i, "\0\0\0\0", 4)) {
|
| 513 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 514 |
+
"Skipping empty entry at position %u in '%s'.", i,
|
| 515 |
+
exif_ifd_get_name (ifd));
|
| 516 |
+
break;
|
| 517 |
+
}
|
| 518 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 519 |
+
"Unknown tag 0x%04x (entry %u in '%s'). Please report this tag "
|
| 520 |
+
"to <[email protected]>.", tag, i,
|
| 521 |
+
exif_ifd_get_name (ifd));
|
| 522 |
+
if (data->priv->options & EXIF_DATA_OPTION_IGNORE_UNKNOWN_TAGS)
|
| 523 |
+
break;
|
| 524 |
+
}
|
| 525 |
+
entry = exif_entry_new_mem (data->priv->mem);
|
| 526 |
+
if (!entry) {
|
| 527 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_NO_MEMORY, "ExifData",
|
| 528 |
+
"Could not allocate memory");
|
| 529 |
+
return;
|
| 530 |
+
}
|
| 531 |
+
if (exif_data_load_data_entry (data, entry, d, ds,
|
| 532 |
+
offset + 12 * i))
|
| 533 |
+
exif_content_add_entry (data->ifd[ifd], entry);
|
| 534 |
+
exif_entry_unref (entry);
|
| 535 |
+
break;
|
| 536 |
+
}
|
| 537 |
+
}
|
| 538 |
+
}
|
| 539 |
+
|
| 540 |
+
static int
|
| 541 |
+
cmp_func (const unsigned char *p1, const unsigned char *p2, ExifByteOrder o)
|
| 542 |
+
{
|
| 543 |
+
ExifShort tag1 = exif_get_short (p1, o);
|
| 544 |
+
ExifShort tag2 = exif_get_short (p2, o);
|
| 545 |
+
|
| 546 |
+
return (tag1 < tag2) ? -1 : (tag1 > tag2) ? 1 : 0;
|
| 547 |
+
}
|
| 548 |
+
|
| 549 |
+
static int
|
| 550 |
+
cmp_func_intel (const void *elem1, const void *elem2)
|
| 551 |
+
{
|
| 552 |
+
return cmp_func ((const unsigned char *) elem1,
|
| 553 |
+
(const unsigned char *) elem2, EXIF_BYTE_ORDER_INTEL);
|
| 554 |
+
}
|
| 555 |
+
|
| 556 |
+
static int
|
| 557 |
+
cmp_func_motorola (const void *elem1, const void *elem2)
|
| 558 |
+
{
|
| 559 |
+
return cmp_func ((const unsigned char *) elem1,
|
| 560 |
+
(const unsigned char *) elem2, EXIF_BYTE_ORDER_MOTOROLA);
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
static void
|
| 564 |
+
exif_data_save_data_content (ExifData *data, ExifContent *ifd,
|
| 565 |
+
unsigned char **d, unsigned int *ds,
|
| 566 |
+
unsigned int offset)
|
| 567 |
+
{
|
| 568 |
+
unsigned int j, n_ptr = 0, n_thumb = 0;
|
| 569 |
+
ExifIfd i;
|
| 570 |
+
unsigned char *t;
|
| 571 |
+
unsigned int ts;
|
| 572 |
+
|
| 573 |
+
if (!data || !data->priv || !ifd || !d || !ds)
|
| 574 |
+
return;
|
| 575 |
+
|
| 576 |
+
for (i = 0; i < EXIF_IFD_COUNT; i++)
|
| 577 |
+
if (ifd == data->ifd[i])
|
| 578 |
+
break;
|
| 579 |
+
if (i == EXIF_IFD_COUNT)
|
| 580 |
+
return; /* error */
|
| 581 |
+
|
| 582 |
+
/*
|
| 583 |
+
* Check if we need some extra entries for pointers or the thumbnail.
|
| 584 |
+
*/
|
| 585 |
+
switch (i) {
|
| 586 |
+
case EXIF_IFD_0:
|
| 587 |
+
|
| 588 |
+
/*
|
| 589 |
+
* The pointer to IFD_EXIF is in IFD_0. The pointer to
|
| 590 |
+
* IFD_INTEROPERABILITY is in IFD_EXIF.
|
| 591 |
+
*/
|
| 592 |
+
if (data->ifd[EXIF_IFD_EXIF]->count ||
|
| 593 |
+
data->ifd[EXIF_IFD_INTEROPERABILITY]->count)
|
| 594 |
+
n_ptr++;
|
| 595 |
+
|
| 596 |
+
/* The pointer to IFD_GPS is in IFD_0. */
|
| 597 |
+
if (data->ifd[EXIF_IFD_GPS]->count)
|
| 598 |
+
n_ptr++;
|
| 599 |
+
|
| 600 |
+
break;
|
| 601 |
+
case EXIF_IFD_1:
|
| 602 |
+
if (data->size)
|
| 603 |
+
n_thumb = 2;
|
| 604 |
+
break;
|
| 605 |
+
case EXIF_IFD_EXIF:
|
| 606 |
+
if (data->ifd[EXIF_IFD_INTEROPERABILITY]->count)
|
| 607 |
+
n_ptr++;
|
| 608 |
+
default:
|
| 609 |
+
break;
|
| 610 |
+
}
|
| 611 |
+
|
| 612 |
+
/*
|
| 613 |
+
* Allocate enough memory for all entries
|
| 614 |
+
* and the number of entries.
|
| 615 |
+
*/
|
| 616 |
+
ts = *ds + (2 + (ifd->count + n_ptr + n_thumb) * 12 + 4);
|
| 617 |
+
t = exif_mem_realloc (data->priv->mem, *d, ts);
|
| 618 |
+
if (!t) {
|
| 619 |
+
EXIF_LOG_NO_MEMORY (data->priv->log, "ExifData", ts);
|
| 620 |
+
return;
|
| 621 |
+
}
|
| 622 |
+
*d = t;
|
| 623 |
+
*ds = ts;
|
| 624 |
+
|
| 625 |
+
/* Save the number of entries */
|
| 626 |
+
exif_set_short (*d + 6 + offset, data->priv->order,
|
| 627 |
+
(ExifShort) (ifd->count + n_ptr + n_thumb));
|
| 628 |
+
offset += 2;
|
| 629 |
+
|
| 630 |
+
/*
|
| 631 |
+
* Save each entry. Make sure that no memcpys from NULL pointers are
|
| 632 |
+
* performed
|
| 633 |
+
*/
|
| 634 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 635 |
+
"Saving %i entries (IFD '%s', offset: %i)...",
|
| 636 |
+
ifd->count, exif_ifd_get_name (i), offset);
|
| 637 |
+
for (j = 0; j < ifd->count; j++) {
|
| 638 |
+
if (ifd->entries[j]) {
|
| 639 |
+
exif_data_save_data_entry (data, ifd->entries[j], d, ds,
|
| 640 |
+
offset + 12 * j);
|
| 641 |
+
}
|
| 642 |
+
}
|
| 643 |
+
|
| 644 |
+
offset += 12 * ifd->count;
|
| 645 |
+
|
| 646 |
+
/* Now save special entries. */
|
| 647 |
+
switch (i) {
|
| 648 |
+
case EXIF_IFD_0:
|
| 649 |
+
|
| 650 |
+
/*
|
| 651 |
+
* The pointer to IFD_EXIF is in IFD_0.
|
| 652 |
+
* However, the pointer to IFD_INTEROPERABILITY is in IFD_EXIF,
|
| 653 |
+
* therefore, if IFD_INTEROPERABILITY is not empty, we need
|
| 654 |
+
* IFD_EXIF even if latter is empty.
|
| 655 |
+
*/
|
| 656 |
+
if (data->ifd[EXIF_IFD_EXIF]->count ||
|
| 657 |
+
data->ifd[EXIF_IFD_INTEROPERABILITY]->count) {
|
| 658 |
+
exif_set_short (*d + 6 + offset + 0, data->priv->order,
|
| 659 |
+
EXIF_TAG_EXIF_IFD_POINTER);
|
| 660 |
+
exif_set_short (*d + 6 + offset + 2, data->priv->order,
|
| 661 |
+
EXIF_FORMAT_LONG);
|
| 662 |
+
exif_set_long (*d + 6 + offset + 4, data->priv->order,
|
| 663 |
+
1);
|
| 664 |
+
exif_set_long (*d + 6 + offset + 8, data->priv->order,
|
| 665 |
+
*ds - 6);
|
| 666 |
+
exif_data_save_data_content (data,
|
| 667 |
+
data->ifd[EXIF_IFD_EXIF], d, ds, *ds - 6);
|
| 668 |
+
offset += 12;
|
| 669 |
+
}
|
| 670 |
+
|
| 671 |
+
/* The pointer to IFD_GPS is in IFD_0, too. */
|
| 672 |
+
if (data->ifd[EXIF_IFD_GPS]->count) {
|
| 673 |
+
exif_set_short (*d + 6 + offset + 0, data->priv->order,
|
| 674 |
+
EXIF_TAG_GPS_INFO_IFD_POINTER);
|
| 675 |
+
exif_set_short (*d + 6 + offset + 2, data->priv->order,
|
| 676 |
+
EXIF_FORMAT_LONG);
|
| 677 |
+
exif_set_long (*d + 6 + offset + 4, data->priv->order,
|
| 678 |
+
1);
|
| 679 |
+
exif_set_long (*d + 6 + offset + 8, data->priv->order,
|
| 680 |
+
*ds - 6);
|
| 681 |
+
exif_data_save_data_content (data,
|
| 682 |
+
data->ifd[EXIF_IFD_GPS], d, ds, *ds - 6);
|
| 683 |
+
offset += 12;
|
| 684 |
+
}
|
| 685 |
+
|
| 686 |
+
break;
|
| 687 |
+
case EXIF_IFD_EXIF:
|
| 688 |
+
|
| 689 |
+
/*
|
| 690 |
+
* The pointer to IFD_INTEROPERABILITY is in IFD_EXIF.
|
| 691 |
+
* See note above.
|
| 692 |
+
*/
|
| 693 |
+
if (data->ifd[EXIF_IFD_INTEROPERABILITY]->count) {
|
| 694 |
+
exif_set_short (*d + 6 + offset + 0, data->priv->order,
|
| 695 |
+
EXIF_TAG_INTEROPERABILITY_IFD_POINTER);
|
| 696 |
+
exif_set_short (*d + 6 + offset + 2, data->priv->order,
|
| 697 |
+
EXIF_FORMAT_LONG);
|
| 698 |
+
exif_set_long (*d + 6 + offset + 4, data->priv->order,
|
| 699 |
+
1);
|
| 700 |
+
exif_set_long (*d + 6 + offset + 8, data->priv->order,
|
| 701 |
+
*ds - 6);
|
| 702 |
+
exif_data_save_data_content (data,
|
| 703 |
+
data->ifd[EXIF_IFD_INTEROPERABILITY], d, ds,
|
| 704 |
+
*ds - 6);
|
| 705 |
+
offset += 12;
|
| 706 |
+
}
|
| 707 |
+
|
| 708 |
+
break;
|
| 709 |
+
case EXIF_IFD_1:
|
| 710 |
+
|
| 711 |
+
/*
|
| 712 |
+
* Information about the thumbnail (if any) is saved in
|
| 713 |
+
* IFD_1.
|
| 714 |
+
*/
|
| 715 |
+
if (data->size) {
|
| 716 |
+
|
| 717 |
+
/* EXIF_TAG_JPEG_INTERCHANGE_FORMAT */
|
| 718 |
+
exif_set_short (*d + 6 + offset + 0, data->priv->order,
|
| 719 |
+
EXIF_TAG_JPEG_INTERCHANGE_FORMAT);
|
| 720 |
+
exif_set_short (*d + 6 + offset + 2, data->priv->order,
|
| 721 |
+
EXIF_FORMAT_LONG);
|
| 722 |
+
exif_set_long (*d + 6 + offset + 4, data->priv->order,
|
| 723 |
+
1);
|
| 724 |
+
exif_set_long (*d + 6 + offset + 8, data->priv->order,
|
| 725 |
+
*ds - 6);
|
| 726 |
+
ts = *ds + data->size;
|
| 727 |
+
t = exif_mem_realloc (data->priv->mem, *d, ts);
|
| 728 |
+
if (!t) {
|
| 729 |
+
EXIF_LOG_NO_MEMORY (data->priv->log, "ExifData",
|
| 730 |
+
ts);
|
| 731 |
+
return;
|
| 732 |
+
}
|
| 733 |
+
*d = t;
|
| 734 |
+
*ds = ts;
|
| 735 |
+
memcpy (*d + *ds - data->size, data->data, data->size);
|
| 736 |
+
offset += 12;
|
| 737 |
+
|
| 738 |
+
/* EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH */
|
| 739 |
+
exif_set_short (*d + 6 + offset + 0, data->priv->order,
|
| 740 |
+
EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH);
|
| 741 |
+
exif_set_short (*d + 6 + offset + 2, data->priv->order,
|
| 742 |
+
EXIF_FORMAT_LONG);
|
| 743 |
+
exif_set_long (*d + 6 + offset + 4, data->priv->order,
|
| 744 |
+
1);
|
| 745 |
+
exif_set_long (*d + 6 + offset + 8, data->priv->order,
|
| 746 |
+
data->size);
|
| 747 |
+
offset += 12;
|
| 748 |
+
}
|
| 749 |
+
|
| 750 |
+
break;
|
| 751 |
+
default:
|
| 752 |
+
break;
|
| 753 |
+
}
|
| 754 |
+
|
| 755 |
+
/* Sort the directory according to TIFF specification */
|
| 756 |
+
qsort (*d + 6 + offset - (ifd->count + n_ptr + n_thumb) * 12,
|
| 757 |
+
(ifd->count + n_ptr + n_thumb), 12,
|
| 758 |
+
(data->priv->order == EXIF_BYTE_ORDER_INTEL) ? cmp_func_intel : cmp_func_motorola);
|
| 759 |
+
|
| 760 |
+
/* Correctly terminate the directory */
|
| 761 |
+
if (i == EXIF_IFD_0 && (data->ifd[EXIF_IFD_1]->count ||
|
| 762 |
+
data->size)) {
|
| 763 |
+
|
| 764 |
+
/*
|
| 765 |
+
* We are saving IFD 0. Tell where IFD 1 starts and save
|
| 766 |
+
* IFD 1.
|
| 767 |
+
*/
|
| 768 |
+
exif_set_long (*d + 6 + offset, data->priv->order, *ds - 6);
|
| 769 |
+
exif_data_save_data_content (data, data->ifd[EXIF_IFD_1], d, ds,
|
| 770 |
+
*ds - 6);
|
| 771 |
+
} else
|
| 772 |
+
exif_set_long (*d + 6 + offset, data->priv->order, 0);
|
| 773 |
+
}
|
| 774 |
+
|
| 775 |
+
typedef enum {
|
| 776 |
+
EXIF_DATA_TYPE_MAKER_NOTE_NONE = 0,
|
| 777 |
+
EXIF_DATA_TYPE_MAKER_NOTE_CANON = 1,
|
| 778 |
+
EXIF_DATA_TYPE_MAKER_NOTE_OLYMPUS = 2,
|
| 779 |
+
EXIF_DATA_TYPE_MAKER_NOTE_PENTAX = 3,
|
| 780 |
+
EXIF_DATA_TYPE_MAKER_NOTE_NIKON = 4,
|
| 781 |
+
EXIF_DATA_TYPE_MAKER_NOTE_CASIO = 5,
|
| 782 |
+
EXIF_DATA_TYPE_MAKER_NOTE_FUJI = 6
|
| 783 |
+
} ExifDataTypeMakerNote;
|
| 784 |
+
|
| 785 |
+
/*! If MakerNote is recognized, load it.
|
| 786 |
+
*
|
| 787 |
+
* \param[in,out] data #ExifData
|
| 788 |
+
* \param[in] d pointer to raw EXIF data
|
| 789 |
+
* \param[in] ds length of data at d
|
| 790 |
+
*/
|
| 791 |
+
static void
|
| 792 |
+
interpret_maker_note(ExifData *data, const unsigned char *d, unsigned int ds)
|
| 793 |
+
{
|
| 794 |
+
int mnoteid;
|
| 795 |
+
ExifEntry* e = exif_data_get_entry (data, EXIF_TAG_MAKER_NOTE);
|
| 796 |
+
if (!e)
|
| 797 |
+
return;
|
| 798 |
+
|
| 799 |
+
if ((mnoteid = exif_mnote_data_olympus_identify (data, e)) != 0) {
|
| 800 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG,
|
| 801 |
+
"ExifData", "Olympus MakerNote variant type %d", mnoteid);
|
| 802 |
+
data->priv->md = exif_mnote_data_olympus_new (data->priv->mem);
|
| 803 |
+
|
| 804 |
+
} else if ((mnoteid = exif_mnote_data_canon_identify (data, e)) != 0) {
|
| 805 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG,
|
| 806 |
+
"ExifData", "Canon MakerNote variant type %d", mnoteid);
|
| 807 |
+
data->priv->md = exif_mnote_data_canon_new (data->priv->mem, data->priv->options);
|
| 808 |
+
|
| 809 |
+
} else if ((mnoteid = exif_mnote_data_fuji_identify (data, e)) != 0) {
|
| 810 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG,
|
| 811 |
+
"ExifData", "Fuji MakerNote variant type %d", mnoteid);
|
| 812 |
+
data->priv->md = exif_mnote_data_fuji_new (data->priv->mem);
|
| 813 |
+
|
| 814 |
+
/* NOTE: Must do Pentax detection last because some of the
|
| 815 |
+
* heuristics are pretty general. */
|
| 816 |
+
} else if ((mnoteid = exif_mnote_data_pentax_identify (data, e)) != 0) {
|
| 817 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG,
|
| 818 |
+
"ExifData", "Pentax MakerNote variant type %d", mnoteid);
|
| 819 |
+
data->priv->md = exif_mnote_data_pentax_new (data->priv->mem);
|
| 820 |
+
} else if ((mnoteid = exif_mnote_data_apple_identify (data, e)) != 0) {
|
| 821 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG,
|
| 822 |
+
"ExifData", "Apple MakerNote variant type %d", mnoteid);
|
| 823 |
+
data->priv->md = exif_mnote_data_apple_new (data->priv->mem);
|
| 824 |
+
}
|
| 825 |
+
|
| 826 |
+
/*
|
| 827 |
+
* If we are able to interpret the maker note, do so.
|
| 828 |
+
*/
|
| 829 |
+
if (data->priv->md) {
|
| 830 |
+
exif_mnote_data_log (data->priv->md, data->priv->log);
|
| 831 |
+
exif_mnote_data_set_byte_order (data->priv->md,
|
| 832 |
+
data->priv->order);
|
| 833 |
+
exif_mnote_data_set_offset (data->priv->md,
|
| 834 |
+
data->priv->offset_mnote);
|
| 835 |
+
exif_mnote_data_load (data->priv->md, d, ds);
|
| 836 |
+
}
|
| 837 |
+
}
|
| 838 |
+
|
| 839 |
+
#define LOG_TOO_SMALL \
|
| 840 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA, "ExifData", \
|
| 841 |
+
_("Size of data too small to allow for EXIF data."));
|
| 842 |
+
|
| 843 |
+
void
|
| 844 |
+
exif_data_load_data (ExifData *data, const unsigned char *d_orig,
|
| 845 |
+
unsigned int ds)
|
| 846 |
+
{
|
| 847 |
+
unsigned int l;
|
| 848 |
+
ExifLong offset;
|
| 849 |
+
ExifShort n;
|
| 850 |
+
const unsigned char *d = d_orig;
|
| 851 |
+
unsigned int len, fullds;
|
| 852 |
+
|
| 853 |
+
if (!data || !data->priv || !d || !ds)
|
| 854 |
+
return;
|
| 855 |
+
|
| 856 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 857 |
+
"Parsing %i byte(s) EXIF data...\n", ds);
|
| 858 |
+
|
| 859 |
+
/*
|
| 860 |
+
* It can be that the data starts with the EXIF header. If it does
|
| 861 |
+
* not, search the EXIF marker.
|
| 862 |
+
*/
|
| 863 |
+
if (ds < 6) {
|
| 864 |
+
LOG_TOO_SMALL;
|
| 865 |
+
return;
|
| 866 |
+
}
|
| 867 |
+
if (!memcmp (d, ExifHeader, 6)) {
|
| 868 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 869 |
+
"Found EXIF header at start.");
|
| 870 |
+
} else {
|
| 871 |
+
while (ds >= 3) {
|
| 872 |
+
while (ds && (d[0] == 0xff)) {
|
| 873 |
+
d++;
|
| 874 |
+
ds--;
|
| 875 |
+
}
|
| 876 |
+
|
| 877 |
+
/* JPEG_MARKER_SOI */
|
| 878 |
+
if (ds && d[0] == JPEG_MARKER_SOI) {
|
| 879 |
+
d++;
|
| 880 |
+
ds--;
|
| 881 |
+
continue;
|
| 882 |
+
}
|
| 883 |
+
|
| 884 |
+
/* JPEG_MARKER_APP1 */
|
| 885 |
+
if (ds && d[0] == JPEG_MARKER_APP1) {
|
| 886 |
+
/*
|
| 887 |
+
* Verify the exif header
|
| 888 |
+
* (offset 2, length 6).
|
| 889 |
+
*/
|
| 890 |
+
if ((ds >= 10) && !memcmp (d+4, ExifHeader, 6))
|
| 891 |
+
break;
|
| 892 |
+
/* fallthrough */
|
| 893 |
+
}
|
| 894 |
+
/* Skip irrelevant APP markers. The branch for APP1 must come before this,
|
| 895 |
+
otherwise this code block will cause APP1 to be skipped. This code path
|
| 896 |
+
is only relevant for files that are nonconformant to the EXIF
|
| 897 |
+
specification. For conformant files, the APP1 code path above will be
|
| 898 |
+
taken. */
|
| 899 |
+
if (ds >= 3 && d[0] >= 0xe0 && d[0] <= 0xef) { /* JPEG_MARKER_APPn */
|
| 900 |
+
d++;
|
| 901 |
+
ds--;
|
| 902 |
+
l = (((unsigned int)d[0]) << 8) | d[1];
|
| 903 |
+
if (l > ds)
|
| 904 |
+
return;
|
| 905 |
+
d += l;
|
| 906 |
+
ds -= l;
|
| 907 |
+
continue;
|
| 908 |
+
}
|
| 909 |
+
|
| 910 |
+
/* Unknown marker or data. Give up. */
|
| 911 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA,
|
| 912 |
+
"ExifData", _("EXIF marker not found."));
|
| 913 |
+
return;
|
| 914 |
+
}
|
| 915 |
+
if (ds < 3) {
|
| 916 |
+
LOG_TOO_SMALL;
|
| 917 |
+
return;
|
| 918 |
+
}
|
| 919 |
+
d++;
|
| 920 |
+
ds--;
|
| 921 |
+
len = (((unsigned int)d[0]) << 8) | d[1];
|
| 922 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 923 |
+
"We have to deal with %i byte(s) of EXIF data.",
|
| 924 |
+
len);
|
| 925 |
+
d += 2;
|
| 926 |
+
ds = len - 2; /* we do not want the full rest size, but only the size of the tag */
|
| 927 |
+
}
|
| 928 |
+
|
| 929 |
+
/*
|
| 930 |
+
* Verify the exif header
|
| 931 |
+
* (offset 2, length 6).
|
| 932 |
+
*/
|
| 933 |
+
if (ds < 6) {
|
| 934 |
+
LOG_TOO_SMALL;
|
| 935 |
+
return;
|
| 936 |
+
}
|
| 937 |
+
if (memcmp (d, ExifHeader, 6)) {
|
| 938 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA,
|
| 939 |
+
"ExifData", _("EXIF header not found."));
|
| 940 |
+
return;
|
| 941 |
+
}
|
| 942 |
+
|
| 943 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 944 |
+
"Found EXIF header.");
|
| 945 |
+
|
| 946 |
+
/* Sanity check the data length */
|
| 947 |
+
if (ds < 14)
|
| 948 |
+
return;
|
| 949 |
+
|
| 950 |
+
/* The JPEG APP1 section can be no longer than 64 KiB (including a
|
| 951 |
+
16-bit length), so cap the data length to protect against overflow
|
| 952 |
+
in future offset calculations */
|
| 953 |
+
fullds = ds;
|
| 954 |
+
if (ds > 0xfffe)
|
| 955 |
+
ds = 0xfffe;
|
| 956 |
+
|
| 957 |
+
/* Byte order (offset 6, length 2) */
|
| 958 |
+
if (!memcmp (d + 6, "II", 2))
|
| 959 |
+
data->priv->order = EXIF_BYTE_ORDER_INTEL;
|
| 960 |
+
else if (!memcmp (d + 6, "MM", 2))
|
| 961 |
+
data->priv->order = EXIF_BYTE_ORDER_MOTOROLA;
|
| 962 |
+
else {
|
| 963 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA,
|
| 964 |
+
"ExifData", _("Unknown encoding."));
|
| 965 |
+
return;
|
| 966 |
+
}
|
| 967 |
+
|
| 968 |
+
/* Fixed value */
|
| 969 |
+
if (exif_get_short (d + 8, data->priv->order) != 0x002a)
|
| 970 |
+
return;
|
| 971 |
+
|
| 972 |
+
/* IFD 0 offset */
|
| 973 |
+
offset = exif_get_long (d + 10, data->priv->order);
|
| 974 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 975 |
+
"IFD 0 at %i.", (int) offset);
|
| 976 |
+
|
| 977 |
+
/* ds is restricted to 16 bit above, so offset is restricted too, and offset+8 should not overflow. */
|
| 978 |
+
if (offset > ds || offset + 6 + 2 > ds)
|
| 979 |
+
return;
|
| 980 |
+
|
| 981 |
+
/* Parse the actual exif data (usually offset 14 from start) */
|
| 982 |
+
exif_data_load_data_content (data, EXIF_IFD_0, d + 6, ds - 6, offset, 0);
|
| 983 |
+
|
| 984 |
+
/* IFD 1 offset */
|
| 985 |
+
n = exif_get_short (d + 6 + offset, data->priv->order);
|
| 986 |
+
/* offset < 2<<16, n is 16 bit at most, so this op will not overflow */
|
| 987 |
+
if (offset + 6 + 2 + 12 * n + 4 > ds)
|
| 988 |
+
return;
|
| 989 |
+
|
| 990 |
+
offset = exif_get_long (d + 6 + offset + 2 + 12 * n, data->priv->order);
|
| 991 |
+
if (offset) {
|
| 992 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 993 |
+
"IFD 1 at %i.", (int) offset);
|
| 994 |
+
|
| 995 |
+
/* Sanity check. ds is ensured to be above 6 above, offset is 16bit */
|
| 996 |
+
if (offset > ds - 6) {
|
| 997 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA,
|
| 998 |
+
"ExifData", "Bogus offset of IFD1.");
|
| 999 |
+
} else {
|
| 1000 |
+
exif_data_load_data_content (data, EXIF_IFD_1, d + 6, ds - 6, offset, 0);
|
| 1001 |
+
}
|
| 1002 |
+
}
|
| 1003 |
+
|
| 1004 |
+
/*
|
| 1005 |
+
* If we got an EXIF_TAG_MAKER_NOTE, try to interpret it. Some
|
| 1006 |
+
* cameras use pointers in the maker note tag that point to the
|
| 1007 |
+
* space between IFDs. Here is the only place where we have access
|
| 1008 |
+
* to that data.
|
| 1009 |
+
*/
|
| 1010 |
+
interpret_maker_note(data, d, fullds);
|
| 1011 |
+
|
| 1012 |
+
/* Fixup tags if requested */
|
| 1013 |
+
if (data->priv->options & EXIF_DATA_OPTION_FOLLOW_SPECIFICATION)
|
| 1014 |
+
exif_data_fix (data);
|
| 1015 |
+
}
|
| 1016 |
+
|
| 1017 |
+
void
|
| 1018 |
+
exif_data_save_data (ExifData *data, unsigned char **d, unsigned int *ds)
|
| 1019 |
+
{
|
| 1020 |
+
if (ds)
|
| 1021 |
+
*ds = 0; /* This means something went wrong */
|
| 1022 |
+
|
| 1023 |
+
if (!data || !d || !ds)
|
| 1024 |
+
return;
|
| 1025 |
+
|
| 1026 |
+
/* Header */
|
| 1027 |
+
*ds = 14;
|
| 1028 |
+
*d = exif_data_alloc (data, *ds);
|
| 1029 |
+
if (!*d) {
|
| 1030 |
+
*ds = 0;
|
| 1031 |
+
return;
|
| 1032 |
+
}
|
| 1033 |
+
memcpy (*d, ExifHeader, 6);
|
| 1034 |
+
|
| 1035 |
+
/* Order (offset 6) */
|
| 1036 |
+
if (data->priv->order == EXIF_BYTE_ORDER_INTEL) {
|
| 1037 |
+
memcpy (*d + 6, "II", 2);
|
| 1038 |
+
} else {
|
| 1039 |
+
memcpy (*d + 6, "MM", 2);
|
| 1040 |
+
}
|
| 1041 |
+
|
| 1042 |
+
/* Fixed value (2 bytes, offset 8) */
|
| 1043 |
+
exif_set_short (*d + 8, data->priv->order, 0x002a);
|
| 1044 |
+
|
| 1045 |
+
/*
|
| 1046 |
+
* IFD 0 offset (4 bytes, offset 10).
|
| 1047 |
+
* We will start 8 bytes after the
|
| 1048 |
+
* EXIF header (2 bytes for order, another 2 for the test, and
|
| 1049 |
+
* 4 bytes for the IFD 0 offset make 8 bytes together).
|
| 1050 |
+
*/
|
| 1051 |
+
exif_set_long (*d + 10, data->priv->order, 8);
|
| 1052 |
+
|
| 1053 |
+
/* Now save IFD 0. IFD 1 will be saved automatically. */
|
| 1054 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 1055 |
+
"Saving IFDs...");
|
| 1056 |
+
exif_data_save_data_content (data, data->ifd[EXIF_IFD_0], d, ds,
|
| 1057 |
+
*ds - 6);
|
| 1058 |
+
exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
|
| 1059 |
+
"Saved %i byte(s) EXIF data.", *ds);
|
| 1060 |
+
}
|
| 1061 |
+
|
| 1062 |
+
ExifData *
|
| 1063 |
+
exif_data_new_from_file (const char *path)
|
| 1064 |
+
{
|
| 1065 |
+
ExifData *edata;
|
| 1066 |
+
ExifLoader *loader;
|
| 1067 |
+
|
| 1068 |
+
loader = exif_loader_new ();
|
| 1069 |
+
exif_loader_write_file (loader, path);
|
| 1070 |
+
edata = exif_loader_get_data (loader);
|
| 1071 |
+
exif_loader_unref (loader);
|
| 1072 |
+
|
| 1073 |
+
return (edata);
|
| 1074 |
+
}
|
| 1075 |
+
|
| 1076 |
+
void
|
| 1077 |
+
exif_data_ref (ExifData *data)
|
| 1078 |
+
{
|
| 1079 |
+
if (!data)
|
| 1080 |
+
return;
|
| 1081 |
+
|
| 1082 |
+
data->priv->ref_count++;
|
| 1083 |
+
}
|
| 1084 |
+
|
| 1085 |
+
void
|
| 1086 |
+
exif_data_unref (ExifData *data)
|
| 1087 |
+
{
|
| 1088 |
+
if (!data)
|
| 1089 |
+
return;
|
| 1090 |
+
|
| 1091 |
+
data->priv->ref_count--;
|
| 1092 |
+
if (!data->priv->ref_count)
|
| 1093 |
+
exif_data_free (data);
|
| 1094 |
+
}
|
| 1095 |
+
|
| 1096 |
+
void
|
| 1097 |
+
exif_data_free (ExifData *data)
|
| 1098 |
+
{
|
| 1099 |
+
unsigned int i;
|
| 1100 |
+
ExifMem *mem = (data && data->priv) ? data->priv->mem : NULL;
|
| 1101 |
+
|
| 1102 |
+
if (!data)
|
| 1103 |
+
return;
|
| 1104 |
+
|
| 1105 |
+
for (i = 0; i < EXIF_IFD_COUNT; i++) {
|
| 1106 |
+
if (data->ifd[i]) {
|
| 1107 |
+
exif_content_unref (data->ifd[i]);
|
| 1108 |
+
data->ifd[i] = NULL;
|
| 1109 |
+
}
|
| 1110 |
+
}
|
| 1111 |
+
|
| 1112 |
+
if (data->data) {
|
| 1113 |
+
exif_mem_free (mem, data->data);
|
| 1114 |
+
data->data = NULL;
|
| 1115 |
+
}
|
| 1116 |
+
|
| 1117 |
+
if (data->priv) {
|
| 1118 |
+
if (data->priv->log) {
|
| 1119 |
+
exif_log_unref (data->priv->log);
|
| 1120 |
+
data->priv->log = NULL;
|
| 1121 |
+
}
|
| 1122 |
+
if (data->priv->md) {
|
| 1123 |
+
exif_mnote_data_unref (data->priv->md);
|
| 1124 |
+
data->priv->md = NULL;
|
| 1125 |
+
}
|
| 1126 |
+
exif_mem_free (mem, data->priv);
|
| 1127 |
+
exif_mem_free (mem, data);
|
| 1128 |
+
}
|
| 1129 |
+
|
| 1130 |
+
exif_mem_unref (mem);
|
| 1131 |
+
}
|
| 1132 |
+
|
| 1133 |
+
void
|
| 1134 |
+
exif_data_dump (ExifData *data)
|
| 1135 |
+
{
|
| 1136 |
+
unsigned int i;
|
| 1137 |
+
|
| 1138 |
+
if (!data)
|
| 1139 |
+
return;
|
| 1140 |
+
|
| 1141 |
+
for (i = 0; i < EXIF_IFD_COUNT; i++) {
|
| 1142 |
+
if (data->ifd[i] && data->ifd[i]->count) {
|
| 1143 |
+
printf ("Dumping IFD '%s'...\n",
|
| 1144 |
+
exif_ifd_get_name (i));
|
| 1145 |
+
exif_content_dump (data->ifd[i], 0);
|
| 1146 |
+
}
|
| 1147 |
+
}
|
| 1148 |
+
|
| 1149 |
+
if (data->data) {
|
| 1150 |
+
printf ("%i byte(s) thumbnail data available: ", data->size);
|
| 1151 |
+
if (data->size >= 4) {
|
| 1152 |
+
printf ("0x%02x 0x%02x ... 0x%02x 0x%02x\n",
|
| 1153 |
+
data->data[0], data->data[1],
|
| 1154 |
+
data->data[data->size - 2],
|
| 1155 |
+
data->data[data->size - 1]);
|
| 1156 |
+
}
|
| 1157 |
+
}
|
| 1158 |
+
}
|
| 1159 |
+
|
| 1160 |
+
ExifByteOrder
|
| 1161 |
+
exif_data_get_byte_order (ExifData *data)
|
| 1162 |
+
{
|
| 1163 |
+
if (!data)
|
| 1164 |
+
return (0);
|
| 1165 |
+
|
| 1166 |
+
return (data->priv->order);
|
| 1167 |
+
}
|
| 1168 |
+
|
| 1169 |
+
void
|
| 1170 |
+
exif_data_foreach_content (ExifData *data, ExifDataForeachContentFunc func,
|
| 1171 |
+
void *user_data)
|
| 1172 |
+
{
|
| 1173 |
+
unsigned int i;
|
| 1174 |
+
|
| 1175 |
+
if (!data || !func)
|
| 1176 |
+
return;
|
| 1177 |
+
|
| 1178 |
+
for (i = 0; i < EXIF_IFD_COUNT; i++)
|
| 1179 |
+
func (data->ifd[i], user_data);
|
| 1180 |
+
}
|
| 1181 |
+
|
| 1182 |
+
typedef struct _ByteOrderChangeData ByteOrderChangeData;
|
| 1183 |
+
struct _ByteOrderChangeData {
|
| 1184 |
+
ExifByteOrder old, new;
|
| 1185 |
+
};
|
| 1186 |
+
|
| 1187 |
+
static void
|
| 1188 |
+
entry_set_byte_order (ExifEntry *e, void *data)
|
| 1189 |
+
{
|
| 1190 |
+
ByteOrderChangeData *d = data;
|
| 1191 |
+
|
| 1192 |
+
if (!e)
|
| 1193 |
+
return;
|
| 1194 |
+
|
| 1195 |
+
exif_array_set_byte_order (e->format, e->data, e->components, d->old, d->new);
|
| 1196 |
+
}
|
| 1197 |
+
|
| 1198 |
+
static void
|
| 1199 |
+
content_set_byte_order (ExifContent *content, void *data)
|
| 1200 |
+
{
|
| 1201 |
+
exif_content_foreach_entry (content, entry_set_byte_order, data);
|
| 1202 |
+
}
|
| 1203 |
+
|
| 1204 |
+
void
|
| 1205 |
+
exif_data_set_byte_order (ExifData *data, ExifByteOrder order)
|
| 1206 |
+
{
|
| 1207 |
+
ByteOrderChangeData d;
|
| 1208 |
+
|
| 1209 |
+
if (!data || (order == data->priv->order))
|
| 1210 |
+
return;
|
| 1211 |
+
|
| 1212 |
+
d.old = data->priv->order;
|
| 1213 |
+
d.new = order;
|
| 1214 |
+
exif_data_foreach_content (data, content_set_byte_order, &d);
|
| 1215 |
+
data->priv->order = order;
|
| 1216 |
+
if (data->priv->md)
|
| 1217 |
+
exif_mnote_data_set_byte_order (data->priv->md, order);
|
| 1218 |
+
}
|
| 1219 |
+
|
| 1220 |
+
void
|
| 1221 |
+
exif_data_log (ExifData *data, ExifLog *log)
|
| 1222 |
+
{
|
| 1223 |
+
unsigned int i;
|
| 1224 |
+
|
| 1225 |
+
if (!data || !data->priv)
|
| 1226 |
+
return;
|
| 1227 |
+
exif_log_unref (data->priv->log);
|
| 1228 |
+
data->priv->log = log;
|
| 1229 |
+
exif_log_ref (log);
|
| 1230 |
+
|
| 1231 |
+
for (i = 0; i < EXIF_IFD_COUNT; i++)
|
| 1232 |
+
exif_content_log (data->ifd[i], log);
|
| 1233 |
+
}
|
| 1234 |
+
|
| 1235 |
+
/* Used internally within libexif */
|
| 1236 |
+
ExifLog *exif_data_get_log (ExifData *);
|
| 1237 |
+
ExifLog *
|
| 1238 |
+
exif_data_get_log (ExifData *data)
|
| 1239 |
+
{
|
| 1240 |
+
if (!data || !data->priv)
|
| 1241 |
+
return NULL;
|
| 1242 |
+
return data->priv->log;
|
| 1243 |
+
}
|
| 1244 |
+
|
| 1245 |
+
static const struct {
|
| 1246 |
+
ExifDataOption option;
|
| 1247 |
+
const char *name;
|
| 1248 |
+
const char *description;
|
| 1249 |
+
} exif_data_option[] = {
|
| 1250 |
+
{EXIF_DATA_OPTION_IGNORE_UNKNOWN_TAGS, N_("Ignore unknown tags"),
|
| 1251 |
+
N_("Ignore unknown tags when loading EXIF data.")},
|
| 1252 |
+
{EXIF_DATA_OPTION_FOLLOW_SPECIFICATION, N_("Follow specification"),
|
| 1253 |
+
N_("Add, correct and remove entries to get EXIF data that follows "
|
| 1254 |
+
"the specification.")},
|
| 1255 |
+
{EXIF_DATA_OPTION_DONT_CHANGE_MAKER_NOTE, N_("Do not change maker note"),
|
| 1256 |
+
N_("When loading and resaving Exif data, save the maker note unmodified."
|
| 1257 |
+
" Be aware that the maker note can get corrupted.")},
|
| 1258 |
+
{0, NULL, NULL}
|
| 1259 |
+
};
|
| 1260 |
+
|
| 1261 |
+
const char *
|
| 1262 |
+
exif_data_option_get_name (ExifDataOption o)
|
| 1263 |
+
{
|
| 1264 |
+
unsigned int i;
|
| 1265 |
+
|
| 1266 |
+
for (i = 0; exif_data_option[i].name; i++)
|
| 1267 |
+
if (exif_data_option[i].option == o)
|
| 1268 |
+
break;
|
| 1269 |
+
return _(exif_data_option[i].name);
|
| 1270 |
+
}
|
| 1271 |
+
|
| 1272 |
+
const char *
|
| 1273 |
+
exif_data_option_get_description (ExifDataOption o)
|
| 1274 |
+
{
|
| 1275 |
+
unsigned int i;
|
| 1276 |
+
|
| 1277 |
+
for (i = 0; exif_data_option[i].description; i++)
|
| 1278 |
+
if (exif_data_option[i].option == o)
|
| 1279 |
+
break;
|
| 1280 |
+
return _(exif_data_option[i].description);
|
| 1281 |
+
}
|
| 1282 |
+
|
| 1283 |
+
void
|
| 1284 |
+
exif_data_set_option (ExifData *d, ExifDataOption o)
|
| 1285 |
+
{
|
| 1286 |
+
if (!d)
|
| 1287 |
+
return;
|
| 1288 |
+
|
| 1289 |
+
d->priv->options |= o;
|
| 1290 |
+
}
|
| 1291 |
+
|
| 1292 |
+
void
|
| 1293 |
+
exif_data_unset_option (ExifData *d, ExifDataOption o)
|
| 1294 |
+
{
|
| 1295 |
+
if (!d)
|
| 1296 |
+
return;
|
| 1297 |
+
|
| 1298 |
+
d->priv->options &= ~o;
|
| 1299 |
+
}
|
| 1300 |
+
|
| 1301 |
+
static void
|
| 1302 |
+
fix_func (ExifContent *c, void *UNUSED(data))
|
| 1303 |
+
{
|
| 1304 |
+
switch (exif_content_get_ifd (c)) {
|
| 1305 |
+
case EXIF_IFD_1:
|
| 1306 |
+
if (c->parent->data)
|
| 1307 |
+
exif_content_fix (c);
|
| 1308 |
+
else if (c->count) {
|
| 1309 |
+
exif_log (c->parent->priv->log, EXIF_LOG_CODE_DEBUG, "exif-data",
|
| 1310 |
+
"No thumbnail but entries on thumbnail. These entries have been "
|
| 1311 |
+
"removed.");
|
| 1312 |
+
while (c->count) {
|
| 1313 |
+
unsigned int cnt = c->count;
|
| 1314 |
+
exif_content_remove_entry (c, c->entries[c->count - 1]);
|
| 1315 |
+
if (cnt == c->count) {
|
| 1316 |
+
/* safety net */
|
| 1317 |
+
exif_log (c->parent->priv->log, EXIF_LOG_CODE_DEBUG, "exif-data",
|
| 1318 |
+
"failed to remove last entry from entries.");
|
| 1319 |
+
c->count--;
|
| 1320 |
+
}
|
| 1321 |
+
}
|
| 1322 |
+
}
|
| 1323 |
+
break;
|
| 1324 |
+
default:
|
| 1325 |
+
exif_content_fix (c);
|
| 1326 |
+
}
|
| 1327 |
+
}
|
| 1328 |
+
|
| 1329 |
+
void
|
| 1330 |
+
exif_data_fix (ExifData *d)
|
| 1331 |
+
{
|
| 1332 |
+
exif_data_foreach_content (d, fix_func, NULL);
|
| 1333 |
+
}
|
| 1334 |
+
|
| 1335 |
+
void
|
| 1336 |
+
exif_data_set_data_type (ExifData *d, ExifDataType dt)
|
| 1337 |
+
{
|
| 1338 |
+
if (!d || !d->priv)
|
| 1339 |
+
return;
|
| 1340 |
+
|
| 1341 |
+
d->priv->data_type = dt;
|
| 1342 |
+
}
|
| 1343 |
+
|
| 1344 |
+
ExifDataType
|
| 1345 |
+
exif_data_get_data_type (ExifData *d)
|
| 1346 |
+
{
|
| 1347 |
+
return (d && d->priv) ? d->priv->data_type : EXIF_DATA_TYPE_UNKNOWN;
|
| 1348 |
+
}
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-data.h
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*! \file exif-data.h
|
| 2 |
+
* \brief Defines the ExifData type and the associated functions.
|
| 3 |
+
*/
|
| 4 |
+
/*
|
| 5 |
+
* \author Lutz Mueller <[email protected]>
|
| 6 |
+
* \date 2001-2005
|
| 7 |
+
*
|
| 8 |
+
* This library is free software; you can redistribute it and/or
|
| 9 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 10 |
+
* License as published by the Free Software Foundation; either
|
| 11 |
+
* version 2 of the License, or (at your option) any later version.
|
| 12 |
+
*
|
| 13 |
+
* This library is distributed in the hope that it will be useful,
|
| 14 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 15 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 16 |
+
* Lesser General Public License for more details.
|
| 17 |
+
*
|
| 18 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 19 |
+
* License along with this library; if not, write to the
|
| 20 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 21 |
+
* Boston, MA 02110-1301 USA.
|
| 22 |
+
*/
|
| 23 |
+
|
| 24 |
+
#ifndef __EXIF_DATA_H__
|
| 25 |
+
#define __EXIF_DATA_H__
|
| 26 |
+
|
| 27 |
+
#ifdef __cplusplus
|
| 28 |
+
extern "C" {
|
| 29 |
+
#endif /* __cplusplus */
|
| 30 |
+
|
| 31 |
+
#include <libexif/exif-byte-order.h>
|
| 32 |
+
#include <libexif/exif-data-type.h>
|
| 33 |
+
#include <libexif/exif-ifd.h>
|
| 34 |
+
#include <libexif/exif-log.h>
|
| 35 |
+
#include <libexif/exif-tag.h>
|
| 36 |
+
|
| 37 |
+
/*! Represents the entire EXIF data found in an image */
|
| 38 |
+
typedef struct _ExifData ExifData;
|
| 39 |
+
typedef struct _ExifDataPrivate ExifDataPrivate;
|
| 40 |
+
|
| 41 |
+
#include <libexif/exif-content.h>
|
| 42 |
+
#include <libexif/exif-mnote-data.h>
|
| 43 |
+
#include <libexif/exif-mem.h>
|
| 44 |
+
|
| 45 |
+
/*! Represents the entire EXIF data found in an image */
|
| 46 |
+
struct _ExifData
|
| 47 |
+
{
|
| 48 |
+
/*! Data for each IFD */
|
| 49 |
+
ExifContent *ifd[EXIF_IFD_COUNT];
|
| 50 |
+
|
| 51 |
+
/*! Pointer to thumbnail image, or NULL if not available */
|
| 52 |
+
unsigned char *data;
|
| 53 |
+
|
| 54 |
+
/*! Number of bytes in thumbnail image at \c data */
|
| 55 |
+
unsigned int size;
|
| 56 |
+
|
| 57 |
+
ExifDataPrivate *priv;
|
| 58 |
+
};
|
| 59 |
+
|
| 60 |
+
/*! Allocate a new #ExifData. The #ExifData contains an empty
|
| 61 |
+
* #ExifContent for each IFD and the default set of options,
|
| 62 |
+
* which has #EXIF_DATA_OPTION_IGNORE_UNKNOWN_TAGS
|
| 63 |
+
* and #EXIF_DATA_OPTION_FOLLOW_SPECIFICATION set.
|
| 64 |
+
*
|
| 65 |
+
* \return allocated #ExifData, or NULL on error
|
| 66 |
+
*/
|
| 67 |
+
ExifData *exif_data_new (void);
|
| 68 |
+
|
| 69 |
+
/*! Allocate a new #ExifData using the given memory allocator.
|
| 70 |
+
* The #ExifData contains an empty #ExifContent for each IFD and the default
|
| 71 |
+
* set of options, which has #EXIF_DATA_OPTION_IGNORE_UNKNOWN_TAGS and
|
| 72 |
+
* #EXIF_DATA_OPTION_FOLLOW_SPECIFICATION set.
|
| 73 |
+
*
|
| 74 |
+
* \return allocated #ExifData, or NULL on error
|
| 75 |
+
*/
|
| 76 |
+
ExifData *exif_data_new_mem (ExifMem *);
|
| 77 |
+
|
| 78 |
+
/*! Allocate a new #ExifData and load EXIF data from a JPEG file.
|
| 79 |
+
* Uses an #ExifLoader internally to do the loading.
|
| 80 |
+
*
|
| 81 |
+
* \param[in] path filename including path
|
| 82 |
+
* \return allocated #ExifData, or NULL on error
|
| 83 |
+
*/
|
| 84 |
+
ExifData *exif_data_new_from_file (const char *path);
|
| 85 |
+
|
| 86 |
+
/*! Allocate a new #ExifData and load EXIF data from a memory buffer.
|
| 87 |
+
*
|
| 88 |
+
* \param[in] data pointer to raw JPEG or EXIF data
|
| 89 |
+
* \param[in] size number of bytes of data at data
|
| 90 |
+
* \return allocated #ExifData, or NULL on error
|
| 91 |
+
*/
|
| 92 |
+
ExifData *exif_data_new_from_data (const unsigned char *data,
|
| 93 |
+
unsigned int size);
|
| 94 |
+
|
| 95 |
+
/*! Load the #ExifData structure from the raw JPEG or EXIF data in the given
|
| 96 |
+
* memory buffer. If the EXIF data contains a recognized MakerNote, it is
|
| 97 |
+
* loaded and stored as well for later retrieval by #exif_data_get_mnote_data.
|
| 98 |
+
* If the #EXIF_DATA_OPTION_FOLLOW_SPECIFICATION option has been set on this
|
| 99 |
+
* #ExifData, then the tags are automatically fixed after loading (by calling
|
| 100 |
+
* #exif_data_fix).
|
| 101 |
+
*
|
| 102 |
+
* \param[in,out] data EXIF data
|
| 103 |
+
* \param[in] d pointer to raw JPEG or EXIF data
|
| 104 |
+
* \param[in] size number of bytes of data at d
|
| 105 |
+
*/
|
| 106 |
+
void exif_data_load_data (ExifData *data, const unsigned char *d,
|
| 107 |
+
unsigned int size);
|
| 108 |
+
|
| 109 |
+
/*! Store raw EXIF data representing the #ExifData structure into a memory
|
| 110 |
+
* buffer. The buffer is allocated by this function and must subsequently be
|
| 111 |
+
* freed by the caller using the matching free function as used by the #ExifMem
|
| 112 |
+
* in use by this #ExifData.
|
| 113 |
+
*
|
| 114 |
+
* \param[in] data EXIF data
|
| 115 |
+
* \param[out] d pointer to buffer pointer containing raw EXIF data on return
|
| 116 |
+
* \param[out] ds pointer to variable to hold the number of bytes of
|
| 117 |
+
* data at d, or set to 0 on error
|
| 118 |
+
*/
|
| 119 |
+
void exif_data_save_data (ExifData *data, unsigned char **d,
|
| 120 |
+
unsigned int *ds);
|
| 121 |
+
|
| 122 |
+
void exif_data_ref (ExifData *data);
|
| 123 |
+
void exif_data_unref (ExifData *data);
|
| 124 |
+
void exif_data_free (ExifData *data);
|
| 125 |
+
|
| 126 |
+
/*! Return the byte order in use by this EXIF structure.
|
| 127 |
+
*
|
| 128 |
+
* \param[in] data EXIF data
|
| 129 |
+
* \return byte order
|
| 130 |
+
*/
|
| 131 |
+
ExifByteOrder exif_data_get_byte_order (ExifData *data);
|
| 132 |
+
|
| 133 |
+
/*! Set the byte order to use for this EXIF data. If any tags already exist
|
| 134 |
+
* (including MakerNote tags) they are are converted to the specified byte
|
| 135 |
+
* order.
|
| 136 |
+
*
|
| 137 |
+
* \param[in,out] data EXIF data
|
| 138 |
+
* \param[in] order byte order
|
| 139 |
+
*/
|
| 140 |
+
void exif_data_set_byte_order (ExifData *data, ExifByteOrder order);
|
| 141 |
+
|
| 142 |
+
/*! Return the MakerNote data out of the EXIF data. Only certain
|
| 143 |
+
* MakerNote formats that are recognized by libexif are supported.
|
| 144 |
+
* The pointer references a member of the #ExifData structure and must NOT be
|
| 145 |
+
* freed by the caller.
|
| 146 |
+
*
|
| 147 |
+
* \param[in] d EXIF data
|
| 148 |
+
* \return MakerNote data, or NULL if not found or not supported
|
| 149 |
+
*/
|
| 150 |
+
ExifMnoteData *exif_data_get_mnote_data (ExifData *d);
|
| 151 |
+
|
| 152 |
+
/*! Fix the EXIF data to bring it into specification. Call #exif_content_fix
|
| 153 |
+
* on each IFD to fix existing entries, create any new entries that are
|
| 154 |
+
* mandatory but do not yet exist, and remove any entries that are not
|
| 155 |
+
* allowed.
|
| 156 |
+
*
|
| 157 |
+
* \param[in,out] d EXIF data
|
| 158 |
+
*/
|
| 159 |
+
void exif_data_fix (ExifData *d);
|
| 160 |
+
|
| 161 |
+
typedef void (* ExifDataForeachContentFunc) (ExifContent *, void *user_data);
|
| 162 |
+
|
| 163 |
+
/*! Execute a function on each IFD in turn.
|
| 164 |
+
*
|
| 165 |
+
* \param[in] data EXIF data over which to iterate
|
| 166 |
+
* \param[in] func function to call for each entry
|
| 167 |
+
* \param[in] user_data data to pass into func on each call
|
| 168 |
+
*/
|
| 169 |
+
void exif_data_foreach_content (ExifData *data,
|
| 170 |
+
ExifDataForeachContentFunc func,
|
| 171 |
+
void *user_data);
|
| 172 |
+
|
| 173 |
+
/*! Options to configure the behaviour of #ExifData */
|
| 174 |
+
typedef enum {
|
| 175 |
+
/*! Act as though unknown tags are not present */
|
| 176 |
+
EXIF_DATA_OPTION_IGNORE_UNKNOWN_TAGS = 1 << 0,
|
| 177 |
+
|
| 178 |
+
/*! Fix the EXIF tags to follow the spec */
|
| 179 |
+
EXIF_DATA_OPTION_FOLLOW_SPECIFICATION = 1 << 1,
|
| 180 |
+
|
| 181 |
+
/*! Leave the MakerNote alone, which could cause it to be corrupted */
|
| 182 |
+
EXIF_DATA_OPTION_DONT_CHANGE_MAKER_NOTE = 1 << 2
|
| 183 |
+
} ExifDataOption;
|
| 184 |
+
|
| 185 |
+
/*! Return a short textual description of the given #ExifDataOption.
|
| 186 |
+
*
|
| 187 |
+
* \param[in] o option
|
| 188 |
+
* \return localized textual description of the option,
|
| 189 |
+
* or NULL if unknown
|
| 190 |
+
*/
|
| 191 |
+
const char *exif_data_option_get_name (ExifDataOption o);
|
| 192 |
+
|
| 193 |
+
/*! Return a verbose textual description of the given #ExifDataOption.
|
| 194 |
+
*
|
| 195 |
+
* \param[in] o option
|
| 196 |
+
* \return verbose localized textual description of the option,
|
| 197 |
+
* or NULL if unknown
|
| 198 |
+
*/
|
| 199 |
+
const char *exif_data_option_get_description (ExifDataOption o);
|
| 200 |
+
|
| 201 |
+
/*! Set the given option on the given #ExifData.
|
| 202 |
+
*
|
| 203 |
+
* \param[in] d EXIF data
|
| 204 |
+
* \param[in] o option
|
| 205 |
+
*/
|
| 206 |
+
void exif_data_set_option (ExifData *d, ExifDataOption o);
|
| 207 |
+
|
| 208 |
+
/*! Clear the given option on the given #ExifData.
|
| 209 |
+
*
|
| 210 |
+
* \param[in] d EXIF data
|
| 211 |
+
* \param[in] o option
|
| 212 |
+
*/
|
| 213 |
+
void exif_data_unset_option (ExifData *d, ExifDataOption o);
|
| 214 |
+
|
| 215 |
+
/*! Set the data type for the given #ExifData.
|
| 216 |
+
*
|
| 217 |
+
* \param[in] d EXIF data
|
| 218 |
+
* \param[in] dt data type
|
| 219 |
+
*/
|
| 220 |
+
void exif_data_set_data_type (ExifData *d, ExifDataType dt);
|
| 221 |
+
|
| 222 |
+
/*! Return the data type for the given #ExifData.
|
| 223 |
+
*
|
| 224 |
+
* \param[in] d EXIF data
|
| 225 |
+
* \return data type, or #EXIF_DATA_TYPE_UNKNOWN on error
|
| 226 |
+
*/
|
| 227 |
+
ExifDataType exif_data_get_data_type (ExifData *d);
|
| 228 |
+
|
| 229 |
+
/*! Dump all EXIF data to stdout.
|
| 230 |
+
* This is intended for diagnostic purposes only.
|
| 231 |
+
*
|
| 232 |
+
* \param[in] data EXIF data
|
| 233 |
+
*/
|
| 234 |
+
void exif_data_dump (ExifData *data);
|
| 235 |
+
|
| 236 |
+
/*! Set the log message object for all IFDs.
|
| 237 |
+
*
|
| 238 |
+
* \param[in] data EXIF data
|
| 239 |
+
* \param[in] log #ExifLog
|
| 240 |
+
*/
|
| 241 |
+
void exif_data_log (ExifData *data, ExifLog *log);
|
| 242 |
+
|
| 243 |
+
/*! Return an #ExifEntry for the given tag if found in any IFD.
|
| 244 |
+
* Each IFD is searched in turn and the first containing a tag with
|
| 245 |
+
* this number is returned.
|
| 246 |
+
*
|
| 247 |
+
* \param[in] d #ExifData
|
| 248 |
+
* \param[in] t #ExifTag
|
| 249 |
+
* \return #ExifEntry* if found, else NULL if not found
|
| 250 |
+
*/
|
| 251 |
+
#define exif_data_get_entry(d,t) \
|
| 252 |
+
(exif_content_get_entry(d->ifd[EXIF_IFD_0],t) ? \
|
| 253 |
+
exif_content_get_entry(d->ifd[EXIF_IFD_0],t) : \
|
| 254 |
+
exif_content_get_entry(d->ifd[EXIF_IFD_1],t) ? \
|
| 255 |
+
exif_content_get_entry(d->ifd[EXIF_IFD_1],t) : \
|
| 256 |
+
exif_content_get_entry(d->ifd[EXIF_IFD_EXIF],t) ? \
|
| 257 |
+
exif_content_get_entry(d->ifd[EXIF_IFD_EXIF],t) : \
|
| 258 |
+
exif_content_get_entry(d->ifd[EXIF_IFD_GPS],t) ? \
|
| 259 |
+
exif_content_get_entry(d->ifd[EXIF_IFD_GPS],t) : \
|
| 260 |
+
exif_content_get_entry(d->ifd[EXIF_IFD_INTEROPERABILITY],t) ? \
|
| 261 |
+
exif_content_get_entry(d->ifd[EXIF_IFD_INTEROPERABILITY],t) : NULL)
|
| 262 |
+
|
| 263 |
+
#ifdef __cplusplus
|
| 264 |
+
}
|
| 265 |
+
#endif /* __cplusplus */
|
| 266 |
+
|
| 267 |
+
#endif /* __EXIF_DATA_H__ */
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-entry.c
ADDED
|
@@ -0,0 +1,1809 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* exif-entry.c
|
| 2 |
+
*
|
| 3 |
+
* Copyright (c) 2001 Lutz Mueller <[email protected]>
|
| 4 |
+
*
|
| 5 |
+
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#include <config.h>
|
| 22 |
+
|
| 23 |
+
#include <libexif/exif-entry.h>
|
| 24 |
+
#include <libexif/exif-ifd.h>
|
| 25 |
+
#include <libexif/exif-utils.h>
|
| 26 |
+
#include <libexif/i18n.h>
|
| 27 |
+
|
| 28 |
+
#include <libexif/exif-gps-ifd.h>
|
| 29 |
+
|
| 30 |
+
#include <ctype.h>
|
| 31 |
+
#include <stdlib.h>
|
| 32 |
+
#include <stdio.h>
|
| 33 |
+
#include <string.h>
|
| 34 |
+
#include <time.h>
|
| 35 |
+
#include <math.h>
|
| 36 |
+
|
| 37 |
+
#ifndef M_PI
|
| 38 |
+
#define M_PI 3.14159265358979323846
|
| 39 |
+
#endif
|
| 40 |
+
|
| 41 |
+
struct _ExifEntryPrivate
|
| 42 |
+
{
|
| 43 |
+
unsigned int ref_count;
|
| 44 |
+
|
| 45 |
+
ExifMem *mem;
|
| 46 |
+
};
|
| 47 |
+
|
| 48 |
+
/* This function is hidden in exif-data.c */
|
| 49 |
+
ExifLog *exif_data_get_log (ExifData *);
|
| 50 |
+
|
| 51 |
+
#ifndef NO_VERBOSE_TAG_STRINGS
|
| 52 |
+
static void
|
| 53 |
+
exif_entry_log (ExifEntry *e, ExifLogCode code, const char *format, ...)
|
| 54 |
+
{
|
| 55 |
+
va_list args;
|
| 56 |
+
ExifLog *l = NULL;
|
| 57 |
+
|
| 58 |
+
if (e && e->parent && e->parent->parent)
|
| 59 |
+
l = exif_data_get_log (e->parent->parent);
|
| 60 |
+
va_start (args, format);
|
| 61 |
+
exif_logv (l, code, "ExifEntry", format, args);
|
| 62 |
+
va_end (args);
|
| 63 |
+
}
|
| 64 |
+
#else
|
| 65 |
+
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
| 66 |
+
#define exif_entry_log(...) do { } while (0)
|
| 67 |
+
#elif defined(__GNUC__)
|
| 68 |
+
#define exif_entry_log(x...) do { } while (0)
|
| 69 |
+
#else
|
| 70 |
+
#define exif_entry_log (void)
|
| 71 |
+
#endif
|
| 72 |
+
#endif
|
| 73 |
+
|
| 74 |
+
static void *
|
| 75 |
+
exif_entry_alloc (ExifEntry *e, unsigned int i)
|
| 76 |
+
{
|
| 77 |
+
void *d;
|
| 78 |
+
ExifLog *l = NULL;
|
| 79 |
+
|
| 80 |
+
if (!e || !e->priv || !i) return NULL;
|
| 81 |
+
|
| 82 |
+
d = exif_mem_alloc (e->priv->mem, i);
|
| 83 |
+
if (d) return d;
|
| 84 |
+
|
| 85 |
+
if (e->parent && e->parent->parent)
|
| 86 |
+
l = exif_data_get_log (e->parent->parent);
|
| 87 |
+
EXIF_LOG_NO_MEMORY (l, "ExifEntry", i);
|
| 88 |
+
return NULL;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
static void *
|
| 92 |
+
exif_entry_realloc (ExifEntry *e, void *d_orig, unsigned int i)
|
| 93 |
+
{
|
| 94 |
+
void *d;
|
| 95 |
+
ExifLog *l = NULL;
|
| 96 |
+
|
| 97 |
+
if (!e || !e->priv) return NULL;
|
| 98 |
+
|
| 99 |
+
if (!i) { exif_mem_free (e->priv->mem, d_orig); return NULL; }
|
| 100 |
+
|
| 101 |
+
d = exif_mem_realloc (e->priv->mem, d_orig, i);
|
| 102 |
+
if (d) return d;
|
| 103 |
+
|
| 104 |
+
if (e->parent && e->parent->parent)
|
| 105 |
+
l = exif_data_get_log (e->parent->parent);
|
| 106 |
+
EXIF_LOG_NO_MEMORY (l, "ExifEntry", i);
|
| 107 |
+
return NULL;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
ExifEntry *
|
| 111 |
+
exif_entry_new (void)
|
| 112 |
+
{
|
| 113 |
+
ExifMem *mem = exif_mem_new_default ();
|
| 114 |
+
ExifEntry *e = exif_entry_new_mem (mem);
|
| 115 |
+
|
| 116 |
+
exif_mem_unref (mem);
|
| 117 |
+
|
| 118 |
+
return e;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
ExifEntry *
|
| 122 |
+
exif_entry_new_mem (ExifMem *mem)
|
| 123 |
+
{
|
| 124 |
+
ExifEntry *e = NULL;
|
| 125 |
+
|
| 126 |
+
e = exif_mem_alloc (mem, sizeof (ExifEntry));
|
| 127 |
+
if (!e) return NULL;
|
| 128 |
+
e->priv = exif_mem_alloc (mem, sizeof (ExifEntryPrivate));
|
| 129 |
+
if (!e->priv) { exif_mem_free (mem, e); return NULL; }
|
| 130 |
+
e->priv->ref_count = 1;
|
| 131 |
+
|
| 132 |
+
e->priv->mem = mem;
|
| 133 |
+
exif_mem_ref (mem);
|
| 134 |
+
|
| 135 |
+
return e;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
void
|
| 139 |
+
exif_entry_ref (ExifEntry *e)
|
| 140 |
+
{
|
| 141 |
+
if (!e) return;
|
| 142 |
+
|
| 143 |
+
e->priv->ref_count++;
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
void
|
| 147 |
+
exif_entry_unref (ExifEntry *e)
|
| 148 |
+
{
|
| 149 |
+
if (!e) return;
|
| 150 |
+
|
| 151 |
+
e->priv->ref_count--;
|
| 152 |
+
if (!e->priv->ref_count)
|
| 153 |
+
exif_entry_free (e);
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
void
|
| 157 |
+
exif_entry_free (ExifEntry *e)
|
| 158 |
+
{
|
| 159 |
+
if (!e) return;
|
| 160 |
+
|
| 161 |
+
if (e->priv) {
|
| 162 |
+
ExifMem *mem = e->priv->mem;
|
| 163 |
+
if (e->data)
|
| 164 |
+
exif_mem_free (mem, e->data);
|
| 165 |
+
exif_mem_free (mem, e->priv);
|
| 166 |
+
exif_mem_free (mem, e);
|
| 167 |
+
exif_mem_unref (mem);
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
static void
|
| 172 |
+
clear_entry (ExifEntry *e)
|
| 173 |
+
{
|
| 174 |
+
e->components = 0;
|
| 175 |
+
e->size = 0;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
/*! Get a value and convert it to an ExifShort.
|
| 179 |
+
* \bug Not all types are converted that could be converted and no indication
|
| 180 |
+
* is made when that occurs
|
| 181 |
+
*/
|
| 182 |
+
static inline ExifShort
|
| 183 |
+
exif_get_short_convert (const unsigned char *buf, ExifFormat format,
|
| 184 |
+
ExifByteOrder order)
|
| 185 |
+
{
|
| 186 |
+
switch (format) {
|
| 187 |
+
case EXIF_FORMAT_LONG:
|
| 188 |
+
return (ExifShort) exif_get_long (buf, order);
|
| 189 |
+
case EXIF_FORMAT_SLONG:
|
| 190 |
+
return (ExifShort) exif_get_slong (buf, order);
|
| 191 |
+
case EXIF_FORMAT_SHORT:
|
| 192 |
+
return (ExifShort) exif_get_short (buf, order);
|
| 193 |
+
case EXIF_FORMAT_SSHORT:
|
| 194 |
+
return (ExifShort) exif_get_sshort (buf, order);
|
| 195 |
+
case EXIF_FORMAT_BYTE:
|
| 196 |
+
case EXIF_FORMAT_SBYTE:
|
| 197 |
+
return (ExifShort) buf[0];
|
| 198 |
+
default:
|
| 199 |
+
/* Unsupported type */
|
| 200 |
+
return (ExifShort) 0;
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
void
|
| 205 |
+
exif_entry_fix (ExifEntry *e)
|
| 206 |
+
{
|
| 207 |
+
unsigned int i, newsize;
|
| 208 |
+
unsigned char *newdata;
|
| 209 |
+
ExifByteOrder o;
|
| 210 |
+
ExifRational r;
|
| 211 |
+
ExifSRational sr;
|
| 212 |
+
|
| 213 |
+
if (!e || !e->priv) return;
|
| 214 |
+
|
| 215 |
+
switch (e->tag) {
|
| 216 |
+
|
| 217 |
+
/* These tags all need to be of format SHORT. */
|
| 218 |
+
case EXIF_TAG_YCBCR_SUB_SAMPLING:
|
| 219 |
+
case EXIF_TAG_SUBJECT_AREA:
|
| 220 |
+
case EXIF_TAG_COLOR_SPACE:
|
| 221 |
+
case EXIF_TAG_PLANAR_CONFIGURATION:
|
| 222 |
+
case EXIF_TAG_SENSING_METHOD:
|
| 223 |
+
case EXIF_TAG_ORIENTATION:
|
| 224 |
+
case EXIF_TAG_YCBCR_POSITIONING:
|
| 225 |
+
case EXIF_TAG_PHOTOMETRIC_INTERPRETATION:
|
| 226 |
+
case EXIF_TAG_CUSTOM_RENDERED:
|
| 227 |
+
case EXIF_TAG_EXPOSURE_MODE:
|
| 228 |
+
case EXIF_TAG_WHITE_BALANCE:
|
| 229 |
+
case EXIF_TAG_SCENE_CAPTURE_TYPE:
|
| 230 |
+
case EXIF_TAG_GAIN_CONTROL:
|
| 231 |
+
case EXIF_TAG_SATURATION:
|
| 232 |
+
case EXIF_TAG_CONTRAST:
|
| 233 |
+
case EXIF_TAG_SHARPNESS:
|
| 234 |
+
case EXIF_TAG_ISO_SPEED_RATINGS:
|
| 235 |
+
switch (e->format) {
|
| 236 |
+
case EXIF_FORMAT_LONG:
|
| 237 |
+
case EXIF_FORMAT_SLONG:
|
| 238 |
+
case EXIF_FORMAT_BYTE:
|
| 239 |
+
case EXIF_FORMAT_SBYTE:
|
| 240 |
+
case EXIF_FORMAT_SSHORT:
|
| 241 |
+
if (!e->parent || !e->parent->parent) break;
|
| 242 |
+
exif_entry_log (e, EXIF_LOG_CODE_DEBUG,
|
| 243 |
+
_("Tag '%s' was of format '%s' (which is "
|
| 244 |
+
"against specification) and has been "
|
| 245 |
+
"changed to format '%s'."),
|
| 246 |
+
exif_tag_get_name_in_ifd(e->tag,
|
| 247 |
+
exif_entry_get_ifd(e)),
|
| 248 |
+
exif_format_get_name (e->format),
|
| 249 |
+
exif_format_get_name (EXIF_FORMAT_SHORT));
|
| 250 |
+
|
| 251 |
+
o = exif_data_get_byte_order (e->parent->parent);
|
| 252 |
+
newsize = e->components * exif_format_get_size (EXIF_FORMAT_SHORT);
|
| 253 |
+
newdata = exif_entry_alloc (e, newsize);
|
| 254 |
+
if (!newdata) {
|
| 255 |
+
exif_entry_log (e, EXIF_LOG_CODE_NO_MEMORY,
|
| 256 |
+
"Could not allocate %lu byte(s).", (unsigned long)newsize);
|
| 257 |
+
break;
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
for (i = 0; i < e->components; i++)
|
| 261 |
+
exif_set_short (
|
| 262 |
+
newdata + i *
|
| 263 |
+
exif_format_get_size (
|
| 264 |
+
EXIF_FORMAT_SHORT), o,
|
| 265 |
+
exif_get_short_convert (
|
| 266 |
+
e->data + i *
|
| 267 |
+
exif_format_get_size (e->format),
|
| 268 |
+
e->format, o));
|
| 269 |
+
|
| 270 |
+
exif_mem_free (e->priv->mem, e->data);
|
| 271 |
+
e->data = newdata;
|
| 272 |
+
e->size = newsize;
|
| 273 |
+
e->format = EXIF_FORMAT_SHORT;
|
| 274 |
+
break;
|
| 275 |
+
case EXIF_FORMAT_SHORT:
|
| 276 |
+
/* No conversion necessary */
|
| 277 |
+
break;
|
| 278 |
+
default:
|
| 279 |
+
exif_entry_log (e, EXIF_LOG_CODE_CORRUPT_DATA,
|
| 280 |
+
_("Tag '%s' is of format '%s' (which is "
|
| 281 |
+
"against specification) but cannot be changed "
|
| 282 |
+
"to format '%s'."),
|
| 283 |
+
exif_tag_get_name_in_ifd(e->tag,
|
| 284 |
+
exif_entry_get_ifd(e)),
|
| 285 |
+
exif_format_get_name (e->format),
|
| 286 |
+
exif_format_get_name (EXIF_FORMAT_SHORT));
|
| 287 |
+
break;
|
| 288 |
+
}
|
| 289 |
+
break;
|
| 290 |
+
|
| 291 |
+
/* All these tags need to be of format 'Rational'. */
|
| 292 |
+
case EXIF_TAG_FNUMBER:
|
| 293 |
+
case EXIF_TAG_APERTURE_VALUE:
|
| 294 |
+
case EXIF_TAG_EXPOSURE_TIME:
|
| 295 |
+
case EXIF_TAG_FOCAL_LENGTH:
|
| 296 |
+
switch (e->format) {
|
| 297 |
+
case EXIF_FORMAT_SRATIONAL:
|
| 298 |
+
if (!e->parent || !e->parent->parent) break;
|
| 299 |
+
o = exif_data_get_byte_order (e->parent->parent);
|
| 300 |
+
for (i = 0; i < e->components; i++) {
|
| 301 |
+
sr = exif_get_srational (e->data + i *
|
| 302 |
+
exif_format_get_size (
|
| 303 |
+
EXIF_FORMAT_SRATIONAL), o);
|
| 304 |
+
r.numerator = (ExifLong) sr.numerator;
|
| 305 |
+
r.denominator = (ExifLong) sr.denominator;
|
| 306 |
+
exif_set_rational (e->data + i *
|
| 307 |
+
exif_format_get_size (
|
| 308 |
+
EXIF_FORMAT_RATIONAL), o, r);
|
| 309 |
+
}
|
| 310 |
+
e->format = EXIF_FORMAT_RATIONAL;
|
| 311 |
+
exif_entry_log (e, EXIF_LOG_CODE_DEBUG,
|
| 312 |
+
_("Tag '%s' was of format '%s' (which is "
|
| 313 |
+
"against specification) and has been "
|
| 314 |
+
"changed to format '%s'."),
|
| 315 |
+
exif_tag_get_name_in_ifd(e->tag,
|
| 316 |
+
exif_entry_get_ifd(e)),
|
| 317 |
+
exif_format_get_name (EXIF_FORMAT_SRATIONAL),
|
| 318 |
+
exif_format_get_name (EXIF_FORMAT_RATIONAL));
|
| 319 |
+
break;
|
| 320 |
+
default:
|
| 321 |
+
break;
|
| 322 |
+
}
|
| 323 |
+
break;
|
| 324 |
+
|
| 325 |
+
/* All these tags need to be of format 'SRational'. */
|
| 326 |
+
case EXIF_TAG_EXPOSURE_BIAS_VALUE:
|
| 327 |
+
case EXIF_TAG_BRIGHTNESS_VALUE:
|
| 328 |
+
case EXIF_TAG_SHUTTER_SPEED_VALUE:
|
| 329 |
+
switch (e->format) {
|
| 330 |
+
case EXIF_FORMAT_RATIONAL:
|
| 331 |
+
if (!e->parent || !e->parent->parent) break;
|
| 332 |
+
o = exif_data_get_byte_order (e->parent->parent);
|
| 333 |
+
for (i = 0; i < e->components; i++) {
|
| 334 |
+
r = exif_get_rational (e->data + i *
|
| 335 |
+
exif_format_get_size (
|
| 336 |
+
EXIF_FORMAT_RATIONAL), o);
|
| 337 |
+
sr.numerator = (ExifLong) r.numerator;
|
| 338 |
+
sr.denominator = (ExifLong) r.denominator;
|
| 339 |
+
exif_set_srational (e->data + i *
|
| 340 |
+
exif_format_get_size (
|
| 341 |
+
EXIF_FORMAT_SRATIONAL), o, sr);
|
| 342 |
+
}
|
| 343 |
+
e->format = EXIF_FORMAT_SRATIONAL;
|
| 344 |
+
exif_entry_log (e, EXIF_LOG_CODE_DEBUG,
|
| 345 |
+
_("Tag '%s' was of format '%s' (which is "
|
| 346 |
+
"against specification) and has been "
|
| 347 |
+
"changed to format '%s'."),
|
| 348 |
+
exif_tag_get_name_in_ifd(e->tag,
|
| 349 |
+
exif_entry_get_ifd(e)),
|
| 350 |
+
exif_format_get_name (EXIF_FORMAT_RATIONAL),
|
| 351 |
+
exif_format_get_name (EXIF_FORMAT_SRATIONAL));
|
| 352 |
+
break;
|
| 353 |
+
default:
|
| 354 |
+
break;
|
| 355 |
+
}
|
| 356 |
+
break;
|
| 357 |
+
|
| 358 |
+
case EXIF_TAG_USER_COMMENT:
|
| 359 |
+
|
| 360 |
+
/* Format needs to be UNDEFINED. */
|
| 361 |
+
if (e->format != EXIF_FORMAT_UNDEFINED) {
|
| 362 |
+
exif_entry_log (e, EXIF_LOG_CODE_DEBUG,
|
| 363 |
+
_("Tag 'UserComment' had invalid format '%s'. "
|
| 364 |
+
"Format has been set to 'undefined'."),
|
| 365 |
+
exif_format_get_name (e->format));
|
| 366 |
+
e->format = EXIF_FORMAT_UNDEFINED;
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
/* Some packages like Canon ZoomBrowser EX 4.5 store
|
| 370 |
+
only one zero byte followed by 7 bytes of rubbish */
|
| 371 |
+
if ((e->size >= 8) && (e->data[0] == 0)) {
|
| 372 |
+
memcpy(e->data, "\0\0\0\0\0\0\0\0", 8);
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
/* There need to be at least 8 bytes. */
|
| 376 |
+
if (e->size < 8) {
|
| 377 |
+
e->data = exif_entry_realloc (e, e->data, 8 + e->size);
|
| 378 |
+
if (!e->data) {
|
| 379 |
+
clear_entry(e);
|
| 380 |
+
return;
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
/* Assume ASCII */
|
| 384 |
+
memmove (e->data + 8, e->data, e->size);
|
| 385 |
+
memcpy (e->data, "ASCII\0\0\0", 8);
|
| 386 |
+
e->size += 8;
|
| 387 |
+
e->components += 8;
|
| 388 |
+
exif_entry_log (e, EXIF_LOG_CODE_DEBUG,
|
| 389 |
+
_("Tag 'UserComment' has been expanded to at "
|
| 390 |
+
"least 8 bytes in order to follow the "
|
| 391 |
+
"specification."));
|
| 392 |
+
break;
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
/*
|
| 396 |
+
* If the first 8 bytes are empty and real data starts
|
| 397 |
+
* afterwards, let's assume ASCII and claim the 8 first
|
| 398 |
+
* bytes for the format specifyer.
|
| 399 |
+
*/
|
| 400 |
+
for (i = 0; (i < e->size) && !e->data[i]; i++);
|
| 401 |
+
if (!i) for ( ; (i < e->size) && (e->data[i] == ' '); i++);
|
| 402 |
+
if ((i >= 8) && (i < e->size)) {
|
| 403 |
+
exif_entry_log (e, EXIF_LOG_CODE_DEBUG,
|
| 404 |
+
_("Tag 'UserComment' is not empty but does not "
|
| 405 |
+
"start with a format identifier. "
|
| 406 |
+
"This has been fixed."));
|
| 407 |
+
memcpy (e->data, "ASCII\0\0\0", 8);
|
| 408 |
+
break;
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
/*
|
| 412 |
+
* First 8 bytes need to follow the specification. If they don't,
|
| 413 |
+
* assume ASCII.
|
| 414 |
+
*/
|
| 415 |
+
if (memcmp (e->data, "ASCII\0\0\0" , 8) &&
|
| 416 |
+
memcmp (e->data, "UNICODE\0" , 8) &&
|
| 417 |
+
memcmp (e->data, "JIS\0\0\0\0\0" , 8) &&
|
| 418 |
+
memcmp (e->data, "\0\0\0\0\0\0\0\0", 8)) {
|
| 419 |
+
e->data = exif_entry_realloc (e, e->data, 8 + e->size);
|
| 420 |
+
if (!e->data) {
|
| 421 |
+
clear_entry(e);
|
| 422 |
+
break;
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
/* Assume ASCII */
|
| 426 |
+
memmove (e->data + 8, e->data, e->size);
|
| 427 |
+
memcpy (e->data, "ASCII\0\0\0", 8);
|
| 428 |
+
e->size += 8;
|
| 429 |
+
e->components += 8;
|
| 430 |
+
exif_entry_log (e, EXIF_LOG_CODE_DEBUG,
|
| 431 |
+
_("Tag 'UserComment' did not start with a "
|
| 432 |
+
"format identifier. This has been fixed."));
|
| 433 |
+
break;
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
break;
|
| 437 |
+
default:
|
| 438 |
+
break;
|
| 439 |
+
}
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
+
/*! Format the value of an ExifEntry for human display in a generic way.
|
| 443 |
+
* The output is localized. The formatting is independent of the tag number
|
| 444 |
+
* and is based entirely on the data type.
|
| 445 |
+
* \pre The ExifEntry is already a member of an ExifData.
|
| 446 |
+
* \param[in] e EXIF entry
|
| 447 |
+
* \param[out] val buffer in which to store value
|
| 448 |
+
* \param[in] maxlen the length of the buffer val
|
| 449 |
+
*/
|
| 450 |
+
static void
|
| 451 |
+
exif_entry_format_value(ExifEntry *e, char *val, size_t maxlen)
|
| 452 |
+
{
|
| 453 |
+
ExifByte v_byte;
|
| 454 |
+
ExifShort v_short;
|
| 455 |
+
ExifSShort v_sshort;
|
| 456 |
+
ExifLong v_long;
|
| 457 |
+
ExifRational v_rat;
|
| 458 |
+
ExifSRational v_srat;
|
| 459 |
+
ExifSLong v_slong;
|
| 460 |
+
unsigned int i;
|
| 461 |
+
size_t len;
|
| 462 |
+
const ExifByteOrder o = exif_data_get_byte_order (e->parent->parent);
|
| 463 |
+
|
| 464 |
+
if (!e->size || !maxlen)
|
| 465 |
+
return;
|
| 466 |
+
switch (e->format) {
|
| 467 |
+
case EXIF_FORMAT_UNDEFINED:
|
| 468 |
+
snprintf (val, maxlen, _("%i bytes undefined data"), e->size);
|
| 469 |
+
break;
|
| 470 |
+
case EXIF_FORMAT_BYTE:
|
| 471 |
+
case EXIF_FORMAT_SBYTE:
|
| 472 |
+
v_byte = e->data[0];
|
| 473 |
+
snprintf (val, maxlen, "0x%02x", v_byte);
|
| 474 |
+
len = strlen (val);
|
| 475 |
+
for (i = 1; i < e->components; i++) {
|
| 476 |
+
v_byte = e->data[i];
|
| 477 |
+
snprintf (val+len, maxlen-len, ", 0x%02x", v_byte);
|
| 478 |
+
len += strlen (val+len);
|
| 479 |
+
if (len >= maxlen-1) break;
|
| 480 |
+
}
|
| 481 |
+
break;
|
| 482 |
+
case EXIF_FORMAT_SHORT:
|
| 483 |
+
v_short = exif_get_short (e->data, o);
|
| 484 |
+
snprintf (val, maxlen, "%u", v_short);
|
| 485 |
+
len = strlen (val);
|
| 486 |
+
for (i = 1; i < e->components; i++) {
|
| 487 |
+
v_short = exif_get_short (e->data +
|
| 488 |
+
exif_format_get_size (e->format) * i, o);
|
| 489 |
+
snprintf (val+len, maxlen-len, ", %u", v_short);
|
| 490 |
+
len += strlen (val+len);
|
| 491 |
+
if (len >= maxlen-1) break;
|
| 492 |
+
}
|
| 493 |
+
break;
|
| 494 |
+
case EXIF_FORMAT_SSHORT:
|
| 495 |
+
v_sshort = exif_get_sshort (e->data, o);
|
| 496 |
+
snprintf (val, maxlen, "%i", v_sshort);
|
| 497 |
+
len = strlen (val);
|
| 498 |
+
for (i = 1; i < e->components; i++) {
|
| 499 |
+
v_sshort = exif_get_short (e->data +
|
| 500 |
+
exif_format_get_size (e->format) *
|
| 501 |
+
i, o);
|
| 502 |
+
snprintf (val+len, maxlen-len, ", %i", v_sshort);
|
| 503 |
+
len += strlen (val+len);
|
| 504 |
+
if (len >= maxlen-1) break;
|
| 505 |
+
}
|
| 506 |
+
break;
|
| 507 |
+
case EXIF_FORMAT_LONG:
|
| 508 |
+
v_long = exif_get_long (e->data, o);
|
| 509 |
+
snprintf (val, maxlen, "%lu", (unsigned long) v_long);
|
| 510 |
+
len = strlen (val);
|
| 511 |
+
for (i = 1; i < e->components; i++) {
|
| 512 |
+
v_long = exif_get_long (e->data +
|
| 513 |
+
exif_format_get_size (e->format) *
|
| 514 |
+
i, o);
|
| 515 |
+
snprintf (val+len, maxlen-len, ", %lu", (unsigned long) v_long);
|
| 516 |
+
len += strlen (val+len);
|
| 517 |
+
if (len >= maxlen-1) break;
|
| 518 |
+
}
|
| 519 |
+
break;
|
| 520 |
+
case EXIF_FORMAT_SLONG:
|
| 521 |
+
v_slong = exif_get_slong (e->data, o);
|
| 522 |
+
snprintf (val, maxlen, "%li", (long) v_slong);
|
| 523 |
+
len = strlen (val);
|
| 524 |
+
for (i = 1; i < e->components; i++) {
|
| 525 |
+
v_slong = exif_get_slong (e->data +
|
| 526 |
+
exif_format_get_size (e->format) * i, o);
|
| 527 |
+
snprintf (val+len, maxlen-len, ", %li", (long) v_slong);
|
| 528 |
+
len += strlen (val+len);
|
| 529 |
+
if (len >= maxlen-1) break;
|
| 530 |
+
}
|
| 531 |
+
break;
|
| 532 |
+
case EXIF_FORMAT_ASCII:
|
| 533 |
+
strncpy (val, (char *) e->data, MIN (maxlen-1, e->size));
|
| 534 |
+
val[MIN (maxlen-1, e->size)] = 0;
|
| 535 |
+
break;
|
| 536 |
+
case EXIF_FORMAT_RATIONAL:
|
| 537 |
+
len = 0;
|
| 538 |
+
for (i = 0; i < e->components; i++) {
|
| 539 |
+
if (i > 0) {
|
| 540 |
+
snprintf (val+len, maxlen-len, ", ");
|
| 541 |
+
len += strlen (val+len);
|
| 542 |
+
}
|
| 543 |
+
v_rat = exif_get_rational (
|
| 544 |
+
e->data + 8 * i, o);
|
| 545 |
+
if (v_rat.denominator) {
|
| 546 |
+
/*
|
| 547 |
+
* Choose the number of significant digits to
|
| 548 |
+
* display based on the size of the denominator.
|
| 549 |
+
* It is scaled so that denominators within the
|
| 550 |
+
* range 13..120 will show 2 decimal points.
|
| 551 |
+
*/
|
| 552 |
+
int decimals = (int)(log10(v_rat.denominator)-0.08+1.0);
|
| 553 |
+
snprintf (val+len, maxlen-len, "%2.*f",
|
| 554 |
+
decimals,
|
| 555 |
+
(double) v_rat.numerator /
|
| 556 |
+
(double) v_rat.denominator);
|
| 557 |
+
} else
|
| 558 |
+
snprintf (val+len, maxlen-len, "%lu/%lu",
|
| 559 |
+
(unsigned long) v_rat.numerator,
|
| 560 |
+
(unsigned long) v_rat.denominator);
|
| 561 |
+
len += strlen (val+len);
|
| 562 |
+
if (len >= maxlen-1) break;
|
| 563 |
+
}
|
| 564 |
+
break;
|
| 565 |
+
case EXIF_FORMAT_SRATIONAL:
|
| 566 |
+
len = 0;
|
| 567 |
+
for (i = 0; i < e->components; i++) {
|
| 568 |
+
if (i > 0) {
|
| 569 |
+
snprintf (val+len, maxlen-len, ", ");
|
| 570 |
+
len += strlen (val+len);
|
| 571 |
+
}
|
| 572 |
+
v_srat = exif_get_srational (
|
| 573 |
+
e->data + 8 * i, o);
|
| 574 |
+
if (v_srat.denominator) {
|
| 575 |
+
int decimals = (int)(log10(abs(v_srat.denominator))-0.08+1.0);
|
| 576 |
+
snprintf (val+len, maxlen-len, "%2.*f",
|
| 577 |
+
decimals,
|
| 578 |
+
(double) v_srat.numerator /
|
| 579 |
+
(double) v_srat.denominator);
|
| 580 |
+
} else
|
| 581 |
+
snprintf (val+len, maxlen-len, "%li/%li",
|
| 582 |
+
(long) v_srat.numerator,
|
| 583 |
+
(long) v_srat.denominator);
|
| 584 |
+
len += strlen (val+len);
|
| 585 |
+
if (len >= maxlen-1) break;
|
| 586 |
+
}
|
| 587 |
+
break;
|
| 588 |
+
case EXIF_FORMAT_DOUBLE:
|
| 589 |
+
case EXIF_FORMAT_FLOAT:
|
| 590 |
+
default:
|
| 591 |
+
snprintf (val, maxlen, _("%i bytes unsupported data type"),
|
| 592 |
+
e->size);
|
| 593 |
+
break;
|
| 594 |
+
}
|
| 595 |
+
}
|
| 596 |
+
|
| 597 |
+
void
|
| 598 |
+
exif_entry_dump (ExifEntry *e, unsigned int indent)
|
| 599 |
+
{
|
| 600 |
+
char buf[1024];
|
| 601 |
+
char value[1024];
|
| 602 |
+
unsigned int l;
|
| 603 |
+
|
| 604 |
+
if (!e)
|
| 605 |
+
return;
|
| 606 |
+
|
| 607 |
+
l = MIN(sizeof(buf)-1, 2*indent);
|
| 608 |
+
memset(buf, ' ', l);
|
| 609 |
+
buf[l] = '\0';
|
| 610 |
+
|
| 611 |
+
printf ("%sTag: 0x%x ('%s')\n", buf, e->tag,
|
| 612 |
+
exif_tag_get_name_in_ifd (e->tag, exif_entry_get_ifd(e)));
|
| 613 |
+
printf ("%s Format: %i ('%s')\n", buf, e->format,
|
| 614 |
+
exif_format_get_name (e->format));
|
| 615 |
+
printf ("%s Components: %i\n", buf, (int) e->components);
|
| 616 |
+
printf ("%s Size: %i\n", buf, e->size);
|
| 617 |
+
printf ("%s Value: %s\n", buf, exif_entry_get_value (e, value, sizeof(value)));
|
| 618 |
+
}
|
| 619 |
+
|
| 620 |
+
/*! Check if a string consists entirely of a single, repeated character.
|
| 621 |
+
* Up to first n bytes are checked.
|
| 622 |
+
*
|
| 623 |
+
* \param[in] data pointer of string to check
|
| 624 |
+
* \param[in] ch character to match
|
| 625 |
+
* \param[in] n maximum number of characters to match
|
| 626 |
+
*
|
| 627 |
+
* \return 0 if the string matches or is of zero length, nonzero otherwise
|
| 628 |
+
*/
|
| 629 |
+
static int
|
| 630 |
+
match_repeated_char(const unsigned char *data, unsigned char ch, size_t n)
|
| 631 |
+
{
|
| 632 |
+
int i;
|
| 633 |
+
for (i=n; i; --i, ++data) {
|
| 634 |
+
if (*data == 0) {
|
| 635 |
+
i = 0; /* all bytes before NUL matched */
|
| 636 |
+
break;
|
| 637 |
+
}
|
| 638 |
+
if (*data != ch)
|
| 639 |
+
break;
|
| 640 |
+
}
|
| 641 |
+
return i;
|
| 642 |
+
}
|
| 643 |
+
|
| 644 |
+
#define CF(entry,target,v,maxlen) \
|
| 645 |
+
{ \
|
| 646 |
+
if (entry->format != target) { \
|
| 647 |
+
exif_entry_log (entry, EXIF_LOG_CODE_CORRUPT_DATA, \
|
| 648 |
+
_("The tag '%s' contains data of an invalid " \
|
| 649 |
+
"format ('%s', expected '%s')."), \
|
| 650 |
+
exif_tag_get_name (entry->tag), \
|
| 651 |
+
exif_format_get_name (entry->format), \
|
| 652 |
+
exif_format_get_name (target)); \
|
| 653 |
+
break; \
|
| 654 |
+
} \
|
| 655 |
+
}
|
| 656 |
+
|
| 657 |
+
#define CC(entry,target,v,maxlen) \
|
| 658 |
+
{ \
|
| 659 |
+
if (entry->components != target) { \
|
| 660 |
+
exif_entry_log (entry, EXIF_LOG_CODE_CORRUPT_DATA, \
|
| 661 |
+
_("The tag '%s' contains an invalid number of " \
|
| 662 |
+
"components (%i, expected %i)."), \
|
| 663 |
+
exif_tag_get_name (entry->tag), \
|
| 664 |
+
(int) entry->components, (int) target); \
|
| 665 |
+
break; \
|
| 666 |
+
} \
|
| 667 |
+
}
|
| 668 |
+
|
| 669 |
+
static const struct {
|
| 670 |
+
ExifTag tag;
|
| 671 |
+
const char *strings[10];
|
| 672 |
+
} list[] = {
|
| 673 |
+
#ifndef NO_VERBOSE_TAG_DATA
|
| 674 |
+
{ EXIF_TAG_PLANAR_CONFIGURATION,
|
| 675 |
+
{ N_("Chunky format"), N_("Planar format"), NULL}},
|
| 676 |
+
{ EXIF_TAG_SENSING_METHOD,
|
| 677 |
+
{ "", N_("Not defined"), N_("One-chip color area sensor"),
|
| 678 |
+
N_("Two-chip color area sensor"), N_("Three-chip color area sensor"),
|
| 679 |
+
N_("Color sequential area sensor"), "", N_("Trilinear sensor"),
|
| 680 |
+
N_("Color sequential linear sensor"), NULL}},
|
| 681 |
+
{ EXIF_TAG_ORIENTATION,
|
| 682 |
+
{ "", N_("Top-left"), N_("Top-right"), N_("Bottom-right"),
|
| 683 |
+
N_("Bottom-left"), N_("Left-top"), N_("Right-top"),
|
| 684 |
+
N_("Right-bottom"), N_("Left-bottom"), NULL}},
|
| 685 |
+
{ EXIF_TAG_YCBCR_POSITIONING,
|
| 686 |
+
{ "", N_("Centered"), N_("Co-sited"), NULL}},
|
| 687 |
+
{ EXIF_TAG_PHOTOMETRIC_INTERPRETATION,
|
| 688 |
+
{ N_("Reversed mono"), N_("Normal mono"), N_("RGB"), N_("Palette"), "",
|
| 689 |
+
N_("CMYK"), N_("YCbCr"), "", N_("CieLAB"), NULL}},
|
| 690 |
+
{ EXIF_TAG_CUSTOM_RENDERED,
|
| 691 |
+
{ N_("Normal process"), N_("Custom process"), NULL}},
|
| 692 |
+
{ EXIF_TAG_EXPOSURE_MODE,
|
| 693 |
+
{ N_("Auto exposure"), N_("Manual exposure"), N_("Auto bracket"), NULL}},
|
| 694 |
+
{ EXIF_TAG_WHITE_BALANCE,
|
| 695 |
+
{ N_("Auto white balance"), N_("Manual white balance"), NULL}},
|
| 696 |
+
{ EXIF_TAG_SCENE_CAPTURE_TYPE,
|
| 697 |
+
{ N_("Standard"), N_("Landscape"), N_("Portrait"),
|
| 698 |
+
N_("Night scene"), NULL}},
|
| 699 |
+
{ EXIF_TAG_GAIN_CONTROL,
|
| 700 |
+
{ N_("Normal"), N_("Low gain up"), N_("High gain up"),
|
| 701 |
+
N_("Low gain down"), N_("High gain down"), NULL}},
|
| 702 |
+
{ EXIF_TAG_SATURATION,
|
| 703 |
+
{ N_("Normal"), N_("Low saturation"), N_("High saturation"), NULL}},
|
| 704 |
+
{ EXIF_TAG_CONTRAST , {N_("Normal"), N_("Soft"), N_("Hard"), NULL}},
|
| 705 |
+
{ EXIF_TAG_SHARPNESS, {N_("Normal"), N_("Soft"), N_("Hard"), NULL}},
|
| 706 |
+
#endif
|
| 707 |
+
{ 0, {NULL}}
|
| 708 |
+
};
|
| 709 |
+
|
| 710 |
+
static const struct {
|
| 711 |
+
ExifTag tag;
|
| 712 |
+
struct {
|
| 713 |
+
ExifShort index;
|
| 714 |
+
const char *values[4]; /*!< list of progressively shorter string
|
| 715 |
+
descriptions; the longest one that fits will be
|
| 716 |
+
selected */
|
| 717 |
+
} elem[25];
|
| 718 |
+
} list2[] = {
|
| 719 |
+
#ifndef NO_VERBOSE_TAG_DATA
|
| 720 |
+
{ EXIF_TAG_METERING_MODE,
|
| 721 |
+
{ { 0, {N_("Unknown"), NULL}},
|
| 722 |
+
{ 1, {N_("Average"), N_("Avg"), NULL}},
|
| 723 |
+
{ 2, {N_("Center-weighted average"), N_("Center-weight"), NULL}},
|
| 724 |
+
{ 3, {N_("Spot"), NULL}},
|
| 725 |
+
{ 4, {N_("Multi spot"), NULL}},
|
| 726 |
+
{ 5, {N_("Pattern"), NULL}},
|
| 727 |
+
{ 6, {N_("Partial"), NULL}},
|
| 728 |
+
{255, {N_("Other"), NULL}},
|
| 729 |
+
{ 0, {NULL}}}},
|
| 730 |
+
{ EXIF_TAG_COMPRESSION,
|
| 731 |
+
{ {1, {N_("Uncompressed"), NULL}},
|
| 732 |
+
{5, {N_("LZW compression"), NULL}},
|
| 733 |
+
{6, {N_("JPEG compression"), NULL}},
|
| 734 |
+
{7, {N_("JPEG compression"), NULL}},
|
| 735 |
+
{8, {N_("Deflate/ZIP compression"), NULL}},
|
| 736 |
+
{32773, {N_("PackBits compression"), NULL}},
|
| 737 |
+
{0, {NULL}}}},
|
| 738 |
+
{ EXIF_TAG_LIGHT_SOURCE,
|
| 739 |
+
{ { 0, {N_("Unknown"), NULL}},
|
| 740 |
+
{ 1, {N_("Daylight"), NULL}},
|
| 741 |
+
{ 2, {N_("Fluorescent"), NULL}},
|
| 742 |
+
{ 3, {N_("Tungsten incandescent light"), N_("Tungsten"), NULL}},
|
| 743 |
+
{ 4, {N_("Flash"), NULL}},
|
| 744 |
+
{ 9, {N_("Fine weather"), NULL}},
|
| 745 |
+
{ 10, {N_("Cloudy weather"), N_("Cloudy"), NULL}},
|
| 746 |
+
{ 11, {N_("Shade"), NULL}},
|
| 747 |
+
{ 12, {N_("Daylight fluorescent"), NULL}},
|
| 748 |
+
{ 13, {N_("Day white fluorescent"), NULL}},
|
| 749 |
+
{ 14, {N_("Cool white fluorescent"), NULL}},
|
| 750 |
+
{ 15, {N_("White fluorescent"), NULL}},
|
| 751 |
+
{ 17, {N_("Standard light A"), NULL}},
|
| 752 |
+
{ 18, {N_("Standard light B"), NULL}},
|
| 753 |
+
{ 19, {N_("Standard light C"), NULL}},
|
| 754 |
+
{ 20, {N_("D55"), NULL}},
|
| 755 |
+
{ 21, {N_("D65"), NULL}},
|
| 756 |
+
{ 22, {N_("D75"), NULL}},
|
| 757 |
+
{ 24, {N_("ISO studio tungsten"),NULL}},
|
| 758 |
+
{255, {N_("Other"), NULL}},
|
| 759 |
+
{ 0, {NULL}}}},
|
| 760 |
+
{ EXIF_TAG_FOCAL_PLANE_RESOLUTION_UNIT,
|
| 761 |
+
{ {2, {N_("Inch"), N_("in"), NULL}},
|
| 762 |
+
{3, {N_("Centimeter"), N_("cm"), NULL}},
|
| 763 |
+
{0, {NULL}}}},
|
| 764 |
+
{ EXIF_TAG_RESOLUTION_UNIT,
|
| 765 |
+
{ {2, {N_("Inch"), N_("in"), NULL}},
|
| 766 |
+
{3, {N_("Centimeter"), N_("cm"), NULL}},
|
| 767 |
+
{0, {NULL}}}},
|
| 768 |
+
{ EXIF_TAG_EXPOSURE_PROGRAM,
|
| 769 |
+
{ {0, {N_("Not defined"), NULL}},
|
| 770 |
+
{1, {N_("Manual"), NULL}},
|
| 771 |
+
{2, {N_("Normal program"), N_("Normal"), NULL}},
|
| 772 |
+
{3, {N_("Aperture priority"), N_("Aperture"), NULL}},
|
| 773 |
+
{4, {N_("Shutter priority"),N_("Shutter"), NULL}},
|
| 774 |
+
{5, {N_("Creative program (biased toward depth of field)"),
|
| 775 |
+
N_("Creative"), NULL}},
|
| 776 |
+
{6, {N_("Creative program (biased toward fast shutter speed)"),
|
| 777 |
+
N_("Action"), NULL}},
|
| 778 |
+
{7, {N_("Portrait mode (for closeup photos with the background out "
|
| 779 |
+
"of focus)"), N_("Portrait"), NULL}},
|
| 780 |
+
{8, {N_("Landscape mode (for landscape photos with the background "
|
| 781 |
+
"in focus)"), N_("Landscape"), NULL}},
|
| 782 |
+
{0, {NULL}}}},
|
| 783 |
+
{ EXIF_TAG_SENSITIVITY_TYPE,
|
| 784 |
+
{ {0, {N_("Unknown"), NULL}},
|
| 785 |
+
{1, {N_("Standard output sensitivity (SOS)"), NULL}},
|
| 786 |
+
{2, {N_("Recommended exposure index (REI)"), NULL}},
|
| 787 |
+
{3, {N_("ISO speed"), NULL}},
|
| 788 |
+
{4, {N_("Standard output sensitivity (SOS) and recommended exposure index (REI)"), NULL}},
|
| 789 |
+
{5, {N_("Standard output sensitivity (SOS) and ISO speed"), NULL}},
|
| 790 |
+
{6, {N_("Recommended exposure index (REI) and ISO speed"), NULL}},
|
| 791 |
+
{7, {N_("Standard output sensitivity (SOS) and recommended exposure index (REI) and ISO speed"), NULL}},
|
| 792 |
+
{0, {NULL}}}},
|
| 793 |
+
{ EXIF_TAG_FLASH,
|
| 794 |
+
{ {0x0000, {N_("Flash did not fire"), N_("No flash"), NULL}},
|
| 795 |
+
{0x0001, {N_("Flash fired"), N_("Flash"), N_("Yes"), NULL}},
|
| 796 |
+
{0x0005, {N_("Strobe return light not detected"), N_("Without strobe"),
|
| 797 |
+
NULL}},
|
| 798 |
+
{0x0007, {N_("Strobe return light detected"), N_("With strobe"), NULL}},
|
| 799 |
+
{0x0008, {N_("Flash did not fire"), NULL}}, /* Olympus E-330 */
|
| 800 |
+
{0x0009, {N_("Flash fired, compulsory flash mode"), NULL}},
|
| 801 |
+
{0x000d, {N_("Flash fired, compulsory flash mode, return light "
|
| 802 |
+
"not detected"), NULL}},
|
| 803 |
+
{0x000f, {N_("Flash fired, compulsory flash mode, return light "
|
| 804 |
+
"detected"), NULL}},
|
| 805 |
+
{0x0010, {N_("Flash did not fire, compulsory flash mode"), NULL}},
|
| 806 |
+
{0x0018, {N_("Flash did not fire, auto mode"), NULL}},
|
| 807 |
+
{0x0019, {N_("Flash fired, auto mode"), NULL}},
|
| 808 |
+
{0x001d, {N_("Flash fired, auto mode, return light not detected"),
|
| 809 |
+
NULL}},
|
| 810 |
+
{0x001f, {N_("Flash fired, auto mode, return light detected"), NULL}},
|
| 811 |
+
{0x0020, {N_("No flash function"),NULL}},
|
| 812 |
+
{0x0041, {N_("Flash fired, red-eye reduction mode"), NULL}},
|
| 813 |
+
{0x0045, {N_("Flash fired, red-eye reduction mode, return light "
|
| 814 |
+
"not detected"), NULL}},
|
| 815 |
+
{0x0047, {N_("Flash fired, red-eye reduction mode, return light "
|
| 816 |
+
"detected"), NULL}},
|
| 817 |
+
{0x0049, {N_("Flash fired, compulsory flash mode, red-eye reduction "
|
| 818 |
+
"mode"), NULL}},
|
| 819 |
+
{0x004d, {N_("Flash fired, compulsory flash mode, red-eye reduction "
|
| 820 |
+
"mode, return light not detected"), NULL}},
|
| 821 |
+
{0x004f, {N_("Flash fired, compulsory flash mode, red-eye reduction mode, "
|
| 822 |
+
"return light detected"), NULL}},
|
| 823 |
+
{0x0058, {N_("Flash did not fire, auto mode, red-eye reduction mode"), NULL}},
|
| 824 |
+
{0x0059, {N_("Flash fired, auto mode, red-eye reduction mode"), NULL}},
|
| 825 |
+
{0x005d, {N_("Flash fired, auto mode, return light not detected, "
|
| 826 |
+
"red-eye reduction mode"), NULL}},
|
| 827 |
+
{0x005f, {N_("Flash fired, auto mode, return light detected, "
|
| 828 |
+
"red-eye reduction mode"), NULL}},
|
| 829 |
+
{0x0000, {NULL}}}},
|
| 830 |
+
{ EXIF_TAG_SUBJECT_DISTANCE_RANGE,
|
| 831 |
+
{ {0, {N_("Unknown"), N_("?"), NULL}},
|
| 832 |
+
{1, {N_("Macro"), NULL}},
|
| 833 |
+
{2, {N_("Close view"), N_("Close"), NULL}},
|
| 834 |
+
{3, {N_("Distant view"), N_("Distant"), NULL}},
|
| 835 |
+
{0, {NULL}}}},
|
| 836 |
+
{ EXIF_TAG_COLOR_SPACE,
|
| 837 |
+
{ {1, {N_("sRGB"), NULL}},
|
| 838 |
+
{2, {N_("Adobe RGB"), NULL}},
|
| 839 |
+
{0xffff, {N_("Uncalibrated"), NULL}},
|
| 840 |
+
{0x0000, {NULL}}}},
|
| 841 |
+
#endif
|
| 842 |
+
{0, { { 0, {NULL}}} }
|
| 843 |
+
};
|
| 844 |
+
|
| 845 |
+
const char *
|
| 846 |
+
exif_entry_get_value (ExifEntry *e, char *val, unsigned int maxlen)
|
| 847 |
+
{
|
| 848 |
+
unsigned int i, j, k;
|
| 849 |
+
ExifShort v_short, v_short2, v_short3, v_short4;
|
| 850 |
+
ExifByte v_byte;
|
| 851 |
+
ExifRational v_rat;
|
| 852 |
+
ExifSRational v_srat;
|
| 853 |
+
char b[64];
|
| 854 |
+
const char *c;
|
| 855 |
+
ExifByteOrder o;
|
| 856 |
+
double d;
|
| 857 |
+
ExifEntry *entry;
|
| 858 |
+
static const struct {
|
| 859 |
+
char label[5];
|
| 860 |
+
char major, minor;
|
| 861 |
+
} versions[] = {
|
| 862 |
+
{"0110", 1, 1},
|
| 863 |
+
{"0120", 1, 2},
|
| 864 |
+
{"0200", 2, 0},
|
| 865 |
+
{"0210", 2, 1},
|
| 866 |
+
{"0220", 2, 2},
|
| 867 |
+
{"0221", 2, 21},
|
| 868 |
+
{"0230", 2, 3},
|
| 869 |
+
{"0231", 2, 31},
|
| 870 |
+
{"0232", 2, 32},
|
| 871 |
+
{"" , 0, 0}
|
| 872 |
+
};
|
| 873 |
+
|
| 874 |
+
(void) bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
| 875 |
+
|
| 876 |
+
if (!e || !e->parent || !e->parent->parent || !maxlen || !val)
|
| 877 |
+
return val;
|
| 878 |
+
|
| 879 |
+
/* make sure the returned string is zero terminated */
|
| 880 |
+
/* FIXME: this is inefficient in the case of long buffers and should
|
| 881 |
+
* instead be taken care of on each write instead. */
|
| 882 |
+
memset (val, 0, maxlen);
|
| 883 |
+
|
| 884 |
+
/* We need the byte order */
|
| 885 |
+
o = exif_data_get_byte_order (e->parent->parent);
|
| 886 |
+
|
| 887 |
+
/* Sanity check */
|
| 888 |
+
if (e->size != e->components * exif_format_get_size (e->format)) {
|
| 889 |
+
snprintf (val, maxlen, _("Invalid size of entry (%i, "
|
| 890 |
+
"expected %li x %i)."), e->size, e->components,
|
| 891 |
+
exif_format_get_size (e->format));
|
| 892 |
+
return val;
|
| 893 |
+
}
|
| 894 |
+
|
| 895 |
+
switch (e->tag) {
|
| 896 |
+
case EXIF_TAG_USER_COMMENT:
|
| 897 |
+
|
| 898 |
+
/*
|
| 899 |
+
* The specification says UNDEFINED, but some
|
| 900 |
+
* manufacturers don't care and use ASCII. If this is the
|
| 901 |
+
* case here, only refuse to read it if there is no chance
|
| 902 |
+
* of finding readable data.
|
| 903 |
+
*/
|
| 904 |
+
if ((e->format != EXIF_FORMAT_ASCII) ||
|
| 905 |
+
(e->size <= 8) ||
|
| 906 |
+
( memcmp (e->data, "ASCII\0\0\0" , 8) &&
|
| 907 |
+
memcmp (e->data, "UNICODE\0" , 8) &&
|
| 908 |
+
memcmp (e->data, "JIS\0\0\0\0\0", 8) &&
|
| 909 |
+
memcmp (e->data, "\0\0\0\0\0\0\0\0", 8)))
|
| 910 |
+
CF (e, EXIF_FORMAT_UNDEFINED, val, maxlen);
|
| 911 |
+
|
| 912 |
+
/*
|
| 913 |
+
* Note that, according to the specification (V2.1, p 40),
|
| 914 |
+
* the user comment field does not have to be
|
| 915 |
+
* NULL terminated.
|
| 916 |
+
*/
|
| 917 |
+
if ((e->size >= 8) && !memcmp (e->data, "ASCII\0\0\0", 8)) {
|
| 918 |
+
strncpy (val, (char *) e->data + 8, MIN (e->size - 8, maxlen-1));
|
| 919 |
+
break;
|
| 920 |
+
}
|
| 921 |
+
if ((e->size >= 8) && !memcmp (e->data, "UNICODE\0", 8)) {
|
| 922 |
+
strncpy (val, _("Unsupported UNICODE string"), maxlen-1);
|
| 923 |
+
/* FIXME: use iconv to convert into the locale encoding.
|
| 924 |
+
* EXIF 2.2 implies (but does not say) that this encoding is
|
| 925 |
+
* UCS-2.
|
| 926 |
+
*/
|
| 927 |
+
break;
|
| 928 |
+
}
|
| 929 |
+
if ((e->size >= 8) && !memcmp (e->data, "JIS\0\0\0\0\0", 8)) {
|
| 930 |
+
strncpy (val, _("Unsupported JIS string"), maxlen-1);
|
| 931 |
+
/* FIXME: use iconv to convert into the locale encoding */
|
| 932 |
+
break;
|
| 933 |
+
}
|
| 934 |
+
|
| 935 |
+
/* Check if there is really some information in the tag. */
|
| 936 |
+
for (i = 0; (i < e->size) &&
|
| 937 |
+
(!e->data[i] || (e->data[i] == ' ')); i++);
|
| 938 |
+
if (i == e->size) break;
|
| 939 |
+
|
| 940 |
+
/*
|
| 941 |
+
* If we reach this point, the tag does not
|
| 942 |
+
* comply with the standard but seems to contain data.
|
| 943 |
+
* Print as much as possible.
|
| 944 |
+
* Note: make sure we do not overwrite the final \0 at maxlen-1
|
| 945 |
+
*/
|
| 946 |
+
exif_entry_log (e, EXIF_LOG_CODE_DEBUG,
|
| 947 |
+
_("Tag UserComment contains data but is "
|
| 948 |
+
"against specification."));
|
| 949 |
+
for (j = 0; (i < e->size) && (j < maxlen-1); i++, j++) {
|
| 950 |
+
exif_entry_log (e, EXIF_LOG_CODE_DEBUG,
|
| 951 |
+
_("Byte at position %i: 0x%02x"), i, e->data[i]);
|
| 952 |
+
val[j] = isprint (e->data[i]) ? e->data[i] : '.';
|
| 953 |
+
}
|
| 954 |
+
break;
|
| 955 |
+
|
| 956 |
+
case EXIF_TAG_EXIF_VERSION:
|
| 957 |
+
CF (e, EXIF_FORMAT_UNDEFINED, val, maxlen);
|
| 958 |
+
CC (e, 4, val, maxlen);
|
| 959 |
+
strncpy (val, _("Unknown Exif Version"), maxlen-1);
|
| 960 |
+
for (i = 0; *versions[i].label; i++) {
|
| 961 |
+
if (!memcmp (e->data, versions[i].label, 4)) {
|
| 962 |
+
snprintf (val, maxlen,
|
| 963 |
+
_("Exif Version %d.%d"),
|
| 964 |
+
versions[i].major,
|
| 965 |
+
versions[i].minor);
|
| 966 |
+
break;
|
| 967 |
+
}
|
| 968 |
+
}
|
| 969 |
+
break;
|
| 970 |
+
case EXIF_TAG_FLASH_PIX_VERSION:
|
| 971 |
+
CF (e, EXIF_FORMAT_UNDEFINED, val, maxlen);
|
| 972 |
+
CC (e, 4, val, maxlen);
|
| 973 |
+
if (!memcmp (e->data, "0100", 4))
|
| 974 |
+
strncpy (val, _("FlashPix Version 1.0"), maxlen-1);
|
| 975 |
+
else if (!memcmp (e->data, "0101", 4))
|
| 976 |
+
strncpy (val, _("FlashPix Version 1.01"), maxlen-1);
|
| 977 |
+
else
|
| 978 |
+
strncpy (val, _("Unknown FlashPix Version"), maxlen-1);
|
| 979 |
+
break;
|
| 980 |
+
case EXIF_TAG_COPYRIGHT:
|
| 981 |
+
CF (e, EXIF_FORMAT_ASCII, val, maxlen);
|
| 982 |
+
|
| 983 |
+
/*
|
| 984 |
+
* First part: Photographer.
|
| 985 |
+
* Some cameras store a string like " " here. Ignore it.
|
| 986 |
+
* Remember that a corrupted tag might not be NUL-terminated
|
| 987 |
+
*/
|
| 988 |
+
if (e->size && e->data && match_repeated_char(e->data, ' ', e->size))
|
| 989 |
+
strncpy (val, (char *) e->data, MIN (maxlen-1, e->size));
|
| 990 |
+
else
|
| 991 |
+
strncpy (val, _("[None]"), maxlen-1);
|
| 992 |
+
strncat (val, " ", maxlen-1 - strlen (val));
|
| 993 |
+
strncat (val, _("(Photographer)"), maxlen-1 - strlen (val));
|
| 994 |
+
|
| 995 |
+
/* Second part: Editor. */
|
| 996 |
+
strncat (val, " - ", maxlen-1 - strlen (val));
|
| 997 |
+
k = 0;
|
| 998 |
+
if (e->size && e->data) {
|
| 999 |
+
const unsigned char *tagdata = memchr(e->data, 0, e->size);
|
| 1000 |
+
if (tagdata++) {
|
| 1001 |
+
unsigned int editor_ofs = tagdata - e->data;
|
| 1002 |
+
unsigned int remaining = e->size - editor_ofs;
|
| 1003 |
+
if (match_repeated_char(tagdata, ' ', remaining)) {
|
| 1004 |
+
strncat (val, (const char*)tagdata, MIN (maxlen-1 - strlen (val), remaining));
|
| 1005 |
+
++k;
|
| 1006 |
+
}
|
| 1007 |
+
}
|
| 1008 |
+
}
|
| 1009 |
+
if (!k)
|
| 1010 |
+
strncat (val, _("[None]"), maxlen-1 - strlen (val));
|
| 1011 |
+
strncat (val, " ", maxlen-1 - strlen (val));
|
| 1012 |
+
strncat (val, _("(Editor)"), maxlen-1 - strlen (val));
|
| 1013 |
+
|
| 1014 |
+
break;
|
| 1015 |
+
case EXIF_TAG_FNUMBER:
|
| 1016 |
+
CF (e, EXIF_FORMAT_RATIONAL, val, maxlen);
|
| 1017 |
+
CC (e, 1, val, maxlen);
|
| 1018 |
+
v_rat = exif_get_rational (e->data, o);
|
| 1019 |
+
if (!v_rat.denominator) {
|
| 1020 |
+
exif_entry_format_value(e, val, maxlen);
|
| 1021 |
+
break;
|
| 1022 |
+
}
|
| 1023 |
+
d = (double) v_rat.numerator / (double) v_rat.denominator;
|
| 1024 |
+
snprintf (val, maxlen, "f/%.01f", d);
|
| 1025 |
+
break;
|
| 1026 |
+
case EXIF_TAG_APERTURE_VALUE:
|
| 1027 |
+
case EXIF_TAG_MAX_APERTURE_VALUE:
|
| 1028 |
+
CF (e, EXIF_FORMAT_RATIONAL, val, maxlen);
|
| 1029 |
+
CC (e, 1, val, maxlen);
|
| 1030 |
+
v_rat = exif_get_rational (e->data, o);
|
| 1031 |
+
if (!v_rat.denominator || (0x80000000 == v_rat.numerator)) {
|
| 1032 |
+
exif_entry_format_value(e, val, maxlen);
|
| 1033 |
+
break;
|
| 1034 |
+
}
|
| 1035 |
+
d = (double) v_rat.numerator / (double) v_rat.denominator;
|
| 1036 |
+
snprintf (val, maxlen, _("%.02f EV"), d);
|
| 1037 |
+
snprintf (b, sizeof (b), _(" (f/%.01f)"), pow (2, d / 2.));
|
| 1038 |
+
strncat (val, b, maxlen-1 - strlen (val));
|
| 1039 |
+
break;
|
| 1040 |
+
case EXIF_TAG_FOCAL_LENGTH:
|
| 1041 |
+
CF (e, EXIF_FORMAT_RATIONAL, val, maxlen);
|
| 1042 |
+
CC (e, 1, val, maxlen);
|
| 1043 |
+
v_rat = exif_get_rational (e->data, o);
|
| 1044 |
+
if (!v_rat.denominator) {
|
| 1045 |
+
exif_entry_format_value(e, val, maxlen);
|
| 1046 |
+
break;
|
| 1047 |
+
}
|
| 1048 |
+
|
| 1049 |
+
/*
|
| 1050 |
+
* For calculation of the 35mm equivalent,
|
| 1051 |
+
* Minolta cameras need a multiplier that depends on the
|
| 1052 |
+
* camera model.
|
| 1053 |
+
*/
|
| 1054 |
+
d = 0.;
|
| 1055 |
+
entry = exif_content_get_entry (
|
| 1056 |
+
e->parent->parent->ifd[EXIF_IFD_0], EXIF_TAG_MAKE);
|
| 1057 |
+
if (entry && entry->data && entry->size >= 7 &&
|
| 1058 |
+
!strncmp ((char *)entry->data, "Minolta", 7)) {
|
| 1059 |
+
entry = exif_content_get_entry (
|
| 1060 |
+
e->parent->parent->ifd[EXIF_IFD_0],
|
| 1061 |
+
EXIF_TAG_MODEL);
|
| 1062 |
+
if (entry && entry->data && entry->size >= 8) {
|
| 1063 |
+
if (!strncmp ((char *)entry->data, "DiMAGE 7", 8))
|
| 1064 |
+
d = 3.9;
|
| 1065 |
+
else if (!strncmp ((char *)entry->data, "DiMAGE 5", 8))
|
| 1066 |
+
d = 4.9;
|
| 1067 |
+
}
|
| 1068 |
+
}
|
| 1069 |
+
if (d)
|
| 1070 |
+
snprintf (b, sizeof (b), _(" (35 equivalent: %.0f mm)"),
|
| 1071 |
+
(d * (double) v_rat.numerator /
|
| 1072 |
+
(double) v_rat.denominator));
|
| 1073 |
+
else
|
| 1074 |
+
b[0] = 0;
|
| 1075 |
+
|
| 1076 |
+
d = (double) v_rat.numerator / (double) v_rat.denominator;
|
| 1077 |
+
snprintf (val, maxlen, "%.1f mm", d);
|
| 1078 |
+
strncat (val, b, maxlen-1 - strlen (val));
|
| 1079 |
+
break;
|
| 1080 |
+
case EXIF_TAG_SUBJECT_DISTANCE:
|
| 1081 |
+
CF (e, EXIF_FORMAT_RATIONAL, val, maxlen);
|
| 1082 |
+
CC (e, 1, val, maxlen);
|
| 1083 |
+
v_rat = exif_get_rational (e->data, o);
|
| 1084 |
+
if (!v_rat.denominator) {
|
| 1085 |
+
exif_entry_format_value(e, val, maxlen);
|
| 1086 |
+
break;
|
| 1087 |
+
}
|
| 1088 |
+
d = (double) v_rat.numerator / (double) v_rat.denominator;
|
| 1089 |
+
snprintf (val, maxlen, "%.1f m", d);
|
| 1090 |
+
break;
|
| 1091 |
+
case EXIF_TAG_EXPOSURE_TIME:
|
| 1092 |
+
CF (e, EXIF_FORMAT_RATIONAL, val, maxlen);
|
| 1093 |
+
CC (e, 1, val, maxlen);
|
| 1094 |
+
v_rat = exif_get_rational (e->data, o);
|
| 1095 |
+
if (!v_rat.denominator) {
|
| 1096 |
+
exif_entry_format_value(e, val, maxlen);
|
| 1097 |
+
break;
|
| 1098 |
+
}
|
| 1099 |
+
d = (double) v_rat.numerator / (double) v_rat.denominator;
|
| 1100 |
+
if (d < 1 && d)
|
| 1101 |
+
snprintf (val, maxlen, _("1/%.0f"), 1. / d);
|
| 1102 |
+
else
|
| 1103 |
+
snprintf (val, maxlen, "%.0f", d);
|
| 1104 |
+
strncat (val, _(" sec."), maxlen-1 - strlen (val));
|
| 1105 |
+
break;
|
| 1106 |
+
case EXIF_TAG_SHUTTER_SPEED_VALUE:
|
| 1107 |
+
CF (e, EXIF_FORMAT_SRATIONAL, val, maxlen);
|
| 1108 |
+
CC (e, 1, val, maxlen);
|
| 1109 |
+
v_srat = exif_get_srational (e->data, o);
|
| 1110 |
+
if (!v_srat.denominator) {
|
| 1111 |
+
exif_entry_format_value(e, val, maxlen);
|
| 1112 |
+
break;
|
| 1113 |
+
}
|
| 1114 |
+
d = (double) v_srat.numerator / (double) v_srat.denominator;
|
| 1115 |
+
snprintf (val, maxlen, _("%.02f EV"), d);
|
| 1116 |
+
if (pow (2, d))
|
| 1117 |
+
d = 1. / pow (2, d);
|
| 1118 |
+
if (d < 1 && d)
|
| 1119 |
+
snprintf (b, sizeof (b), _(" (1/%.0f sec.)"), 1. / d);
|
| 1120 |
+
else
|
| 1121 |
+
snprintf (b, sizeof (b), _(" (%.0f sec.)"), d);
|
| 1122 |
+
strncat (val, b, maxlen-1 - strlen (val));
|
| 1123 |
+
break;
|
| 1124 |
+
case EXIF_TAG_BRIGHTNESS_VALUE:
|
| 1125 |
+
CF (e, EXIF_FORMAT_SRATIONAL, val, maxlen);
|
| 1126 |
+
CC (e, 1, val, maxlen);
|
| 1127 |
+
v_srat = exif_get_srational (e->data, o);
|
| 1128 |
+
if (!v_srat.denominator) {
|
| 1129 |
+
exif_entry_format_value(e, val, maxlen);
|
| 1130 |
+
break;
|
| 1131 |
+
}
|
| 1132 |
+
d = (double) v_srat.numerator / (double) v_srat.denominator;
|
| 1133 |
+
snprintf (val, maxlen, _("%.02f EV"), d);
|
| 1134 |
+
snprintf (b, sizeof (b), _(" (%.02f cd/m^2)"),
|
| 1135 |
+
1. / (M_PI * 0.3048 * 0.3048) * pow (2, d));
|
| 1136 |
+
strncat (val, b, maxlen-1 - strlen (val));
|
| 1137 |
+
break;
|
| 1138 |
+
case EXIF_TAG_FILE_SOURCE:
|
| 1139 |
+
CF (e, EXIF_FORMAT_UNDEFINED, val, maxlen);
|
| 1140 |
+
CC (e, 1, val, maxlen);
|
| 1141 |
+
v_byte = e->data[0];
|
| 1142 |
+
if (v_byte == 3)
|
| 1143 |
+
strncpy (val, _("DSC"), maxlen-1);
|
| 1144 |
+
else
|
| 1145 |
+
snprintf (val, maxlen, _("Internal error (unknown "
|
| 1146 |
+
"value %i)"), v_byte);
|
| 1147 |
+
break;
|
| 1148 |
+
case EXIF_TAG_COMPONENTS_CONFIGURATION:
|
| 1149 |
+
CF (e, EXIF_FORMAT_UNDEFINED, val, maxlen);
|
| 1150 |
+
CC (e, 4, val, maxlen);
|
| 1151 |
+
for (i = 0; i < 4; i++) {
|
| 1152 |
+
switch (e->data[i]) {
|
| 1153 |
+
case 0: c = _("-"); break;
|
| 1154 |
+
case 1: c = _("Y"); break;
|
| 1155 |
+
case 2: c = _("Cb"); break;
|
| 1156 |
+
case 3: c = _("Cr"); break;
|
| 1157 |
+
case 4: c = _("R"); break;
|
| 1158 |
+
case 5: c = _("G"); break;
|
| 1159 |
+
case 6: c = _("B"); break;
|
| 1160 |
+
default: c = _("Reserved"); break;
|
| 1161 |
+
}
|
| 1162 |
+
strncat (val, c, maxlen-1 - strlen (val));
|
| 1163 |
+
if (i < 3)
|
| 1164 |
+
strncat (val, " ", maxlen-1 - strlen (val));
|
| 1165 |
+
}
|
| 1166 |
+
break;
|
| 1167 |
+
case EXIF_TAG_EXPOSURE_BIAS_VALUE:
|
| 1168 |
+
CF (e, EXIF_FORMAT_SRATIONAL, val, maxlen);
|
| 1169 |
+
CC (e, 1, val, maxlen);
|
| 1170 |
+
v_srat = exif_get_srational (e->data, o);
|
| 1171 |
+
if (!v_srat.denominator) {
|
| 1172 |
+
exif_entry_format_value(e, val, maxlen);
|
| 1173 |
+
break;
|
| 1174 |
+
}
|
| 1175 |
+
d = (double) v_srat.numerator / (double) v_srat.denominator;
|
| 1176 |
+
snprintf (val, maxlen, _("%.02f EV"), d);
|
| 1177 |
+
break;
|
| 1178 |
+
case EXIF_TAG_SCENE_TYPE:
|
| 1179 |
+
CF (e, EXIF_FORMAT_UNDEFINED, val, maxlen);
|
| 1180 |
+
CC (e, 1, val, maxlen);
|
| 1181 |
+
v_byte = e->data[0];
|
| 1182 |
+
if (v_byte == 1)
|
| 1183 |
+
strncpy (val, _("Directly photographed"), maxlen-1);
|
| 1184 |
+
else
|
| 1185 |
+
snprintf (val, maxlen, _("Internal error (unknown "
|
| 1186 |
+
"value %i)"), v_byte);
|
| 1187 |
+
break;
|
| 1188 |
+
case EXIF_TAG_YCBCR_SUB_SAMPLING:
|
| 1189 |
+
CF (e, EXIF_FORMAT_SHORT, val, maxlen);
|
| 1190 |
+
CC (e, 2, val, maxlen);
|
| 1191 |
+
v_short = exif_get_short (e->data, o);
|
| 1192 |
+
v_short2 = exif_get_short (
|
| 1193 |
+
e->data + exif_format_get_size (e->format),
|
| 1194 |
+
o);
|
| 1195 |
+
if ((v_short == 2) && (v_short2 == 1))
|
| 1196 |
+
strncpy (val, _("YCbCr4:2:2"), maxlen-1);
|
| 1197 |
+
else if ((v_short == 2) && (v_short2 == 2))
|
| 1198 |
+
strncpy (val, _("YCbCr4:2:0"), maxlen-1);
|
| 1199 |
+
else
|
| 1200 |
+
snprintf (val, maxlen, "%u, %u", v_short, v_short2);
|
| 1201 |
+
break;
|
| 1202 |
+
case EXIF_TAG_SUBJECT_AREA:
|
| 1203 |
+
CF (e, EXIF_FORMAT_SHORT, val, maxlen);
|
| 1204 |
+
switch (e->components) {
|
| 1205 |
+
case 2:
|
| 1206 |
+
v_short = exif_get_short (e->data, o);
|
| 1207 |
+
v_short2 = exif_get_short (e->data + 2, o);
|
| 1208 |
+
snprintf (val, maxlen, "(x,y) = (%i,%i)",
|
| 1209 |
+
v_short, v_short2);
|
| 1210 |
+
break;
|
| 1211 |
+
case 3:
|
| 1212 |
+
v_short = exif_get_short (e->data, o);
|
| 1213 |
+
v_short2 = exif_get_short (e->data + 2, o);
|
| 1214 |
+
v_short3 = exif_get_short (e->data + 4, o);
|
| 1215 |
+
snprintf (val, maxlen, _("Within distance %i of "
|
| 1216 |
+
"(x,y) = (%i,%i)"), v_short3, v_short,
|
| 1217 |
+
v_short2);
|
| 1218 |
+
break;
|
| 1219 |
+
case 4:
|
| 1220 |
+
v_short = exif_get_short (e->data, o);
|
| 1221 |
+
v_short2 = exif_get_short (e->data + 2, o);
|
| 1222 |
+
v_short3 = exif_get_short (e->data + 4, o);
|
| 1223 |
+
v_short4 = exif_get_short (e->data + 6, o);
|
| 1224 |
+
snprintf (val, maxlen, _("Within rectangle "
|
| 1225 |
+
"(width %i, height %i) around "
|
| 1226 |
+
"(x,y) = (%i,%i)"), v_short3, v_short4,
|
| 1227 |
+
v_short, v_short2);
|
| 1228 |
+
break;
|
| 1229 |
+
default:
|
| 1230 |
+
snprintf (val, maxlen, _("Unexpected number "
|
| 1231 |
+
"of components (%li, expected 2, 3, or 4)."),
|
| 1232 |
+
e->components);
|
| 1233 |
+
}
|
| 1234 |
+
break;
|
| 1235 |
+
case EXIF_TAG_GPS_VERSION_ID:
|
| 1236 |
+
/* This is only valid in the GPS IFD */
|
| 1237 |
+
CF (e, EXIF_FORMAT_BYTE, val, maxlen);
|
| 1238 |
+
CC (e, 4, val, maxlen);
|
| 1239 |
+
v_byte = e->data[0];
|
| 1240 |
+
snprintf (val, maxlen, "%u", v_byte);
|
| 1241 |
+
for (i = 1; i < e->components; i++) {
|
| 1242 |
+
v_byte = e->data[i];
|
| 1243 |
+
snprintf (b, sizeof (b), ".%u", v_byte);
|
| 1244 |
+
strncat (val, b, maxlen-1 - strlen (val));
|
| 1245 |
+
}
|
| 1246 |
+
break;
|
| 1247 |
+
case EXIF_TAG_INTEROPERABILITY_VERSION:
|
| 1248 |
+
/* a.k.a. case EXIF_TAG_GPS_LATITUDE: */
|
| 1249 |
+
/* This tag occurs in EXIF_IFD_INTEROPERABILITY */
|
| 1250 |
+
if (e->format == EXIF_FORMAT_UNDEFINED) {
|
| 1251 |
+
strncpy (val, (char *) e->data, MIN (maxlen-1, e->size));
|
| 1252 |
+
break;
|
| 1253 |
+
}
|
| 1254 |
+
/* EXIF_TAG_GPS_LATITUDE is the same numerically as
|
| 1255 |
+
* EXIF_TAG_INTEROPERABILITY_VERSION but in EXIF_IFD_GPS
|
| 1256 |
+
*/
|
| 1257 |
+
exif_entry_format_value(e, val, maxlen);
|
| 1258 |
+
break;
|
| 1259 |
+
case EXIF_TAG_GPS_ALTITUDE_REF:
|
| 1260 |
+
/* This is only valid in the GPS IFD */
|
| 1261 |
+
CF (e, EXIF_FORMAT_BYTE, val, maxlen);
|
| 1262 |
+
CC (e, 1, val, maxlen);
|
| 1263 |
+
v_byte = e->data[0];
|
| 1264 |
+
if (v_byte == 0)
|
| 1265 |
+
strncpy (val, _("Sea level"), maxlen-1);
|
| 1266 |
+
else if (v_byte == 1)
|
| 1267 |
+
strncpy (val, _("Sea level reference"), maxlen-1);
|
| 1268 |
+
else
|
| 1269 |
+
snprintf (val, maxlen, _("Internal error (unknown "
|
| 1270 |
+
"value %i)"), v_byte);
|
| 1271 |
+
break;
|
| 1272 |
+
case EXIF_TAG_GPS_TIME_STAMP:
|
| 1273 |
+
/* This is only valid in the GPS IFD */
|
| 1274 |
+
CF (e, EXIF_FORMAT_RATIONAL, val, maxlen);
|
| 1275 |
+
CC (e, 3, val, maxlen);
|
| 1276 |
+
|
| 1277 |
+
v_rat = exif_get_rational (e->data, o);
|
| 1278 |
+
if (!v_rat.denominator) {
|
| 1279 |
+
exif_entry_format_value(e, val, maxlen);
|
| 1280 |
+
break;
|
| 1281 |
+
}
|
| 1282 |
+
i = v_rat.numerator / v_rat.denominator;
|
| 1283 |
+
|
| 1284 |
+
v_rat = exif_get_rational (e->data +
|
| 1285 |
+
exif_format_get_size (e->format),
|
| 1286 |
+
o);
|
| 1287 |
+
if (!v_rat.denominator) {
|
| 1288 |
+
exif_entry_format_value(e, val, maxlen);
|
| 1289 |
+
break;
|
| 1290 |
+
}
|
| 1291 |
+
j = v_rat.numerator / v_rat.denominator;
|
| 1292 |
+
|
| 1293 |
+
v_rat = exif_get_rational (e->data +
|
| 1294 |
+
2*exif_format_get_size (e->format),
|
| 1295 |
+
o);
|
| 1296 |
+
if (!v_rat.denominator) {
|
| 1297 |
+
exif_entry_format_value(e, val, maxlen);
|
| 1298 |
+
break;
|
| 1299 |
+
}
|
| 1300 |
+
d = (double) v_rat.numerator / (double) v_rat.denominator;
|
| 1301 |
+
snprintf (val, maxlen, "%02u:%02u:%05.2f", i, j, d);
|
| 1302 |
+
break;
|
| 1303 |
+
|
| 1304 |
+
case EXIF_TAG_METERING_MODE:
|
| 1305 |
+
case EXIF_TAG_COMPRESSION:
|
| 1306 |
+
case EXIF_TAG_LIGHT_SOURCE:
|
| 1307 |
+
case EXIF_TAG_FOCAL_PLANE_RESOLUTION_UNIT:
|
| 1308 |
+
case EXIF_TAG_RESOLUTION_UNIT:
|
| 1309 |
+
case EXIF_TAG_EXPOSURE_PROGRAM:
|
| 1310 |
+
case EXIF_TAG_SENSITIVITY_TYPE:
|
| 1311 |
+
case EXIF_TAG_FLASH:
|
| 1312 |
+
case EXIF_TAG_SUBJECT_DISTANCE_RANGE:
|
| 1313 |
+
case EXIF_TAG_COLOR_SPACE:
|
| 1314 |
+
CF (e,EXIF_FORMAT_SHORT, val, maxlen);
|
| 1315 |
+
CC (e, 1, val, maxlen);
|
| 1316 |
+
v_short = exif_get_short (e->data, o);
|
| 1317 |
+
|
| 1318 |
+
/* Search the tag */
|
| 1319 |
+
for (i = 0; list2[i].tag && (list2[i].tag != e->tag); i++);
|
| 1320 |
+
if (!list2[i].tag) {
|
| 1321 |
+
snprintf (val, maxlen, _("Internal error (unknown "
|
| 1322 |
+
"value %i)"), v_short);
|
| 1323 |
+
break;
|
| 1324 |
+
}
|
| 1325 |
+
|
| 1326 |
+
/* Find the value */
|
| 1327 |
+
for (j = 0; list2[i].elem[j].values[0] &&
|
| 1328 |
+
(list2[i].elem[j].index < v_short); j++);
|
| 1329 |
+
if (list2[i].elem[j].index != v_short) {
|
| 1330 |
+
snprintf (val, maxlen, _("Internal error (unknown "
|
| 1331 |
+
"value %i)"), v_short);
|
| 1332 |
+
break;
|
| 1333 |
+
}
|
| 1334 |
+
|
| 1335 |
+
/* Find a short enough value */
|
| 1336 |
+
memset (val, 0, maxlen);
|
| 1337 |
+
for (k = 0; list2[i].elem[j].values[k]; k++) {
|
| 1338 |
+
size_t l = strlen (_(list2[i].elem[j].values[k]));
|
| 1339 |
+
if ((maxlen > l) && (strlen (val) < l))
|
| 1340 |
+
strncpy (val, _(list2[i].elem[j].values[k]), maxlen-1);
|
| 1341 |
+
}
|
| 1342 |
+
if (!val[0]) snprintf (val, maxlen, "%i", v_short);
|
| 1343 |
+
|
| 1344 |
+
break;
|
| 1345 |
+
|
| 1346 |
+
case EXIF_TAG_PLANAR_CONFIGURATION:
|
| 1347 |
+
case EXIF_TAG_SENSING_METHOD:
|
| 1348 |
+
case EXIF_TAG_ORIENTATION:
|
| 1349 |
+
case EXIF_TAG_YCBCR_POSITIONING:
|
| 1350 |
+
case EXIF_TAG_PHOTOMETRIC_INTERPRETATION:
|
| 1351 |
+
case EXIF_TAG_CUSTOM_RENDERED:
|
| 1352 |
+
case EXIF_TAG_EXPOSURE_MODE:
|
| 1353 |
+
case EXIF_TAG_WHITE_BALANCE:
|
| 1354 |
+
case EXIF_TAG_SCENE_CAPTURE_TYPE:
|
| 1355 |
+
case EXIF_TAG_GAIN_CONTROL:
|
| 1356 |
+
case EXIF_TAG_SATURATION:
|
| 1357 |
+
case EXIF_TAG_CONTRAST:
|
| 1358 |
+
case EXIF_TAG_SHARPNESS:
|
| 1359 |
+
CF (e, EXIF_FORMAT_SHORT, val, maxlen);
|
| 1360 |
+
CC (e, 1, val, maxlen);
|
| 1361 |
+
v_short = exif_get_short (e->data, o);
|
| 1362 |
+
|
| 1363 |
+
/* Search the tag */
|
| 1364 |
+
for (i = 0; list[i].tag && (list[i].tag != e->tag); i++);
|
| 1365 |
+
if (!list[i].tag) {
|
| 1366 |
+
snprintf (val, maxlen, _("Internal error (unknown "
|
| 1367 |
+
"value %i)"), v_short);
|
| 1368 |
+
break;
|
| 1369 |
+
}
|
| 1370 |
+
|
| 1371 |
+
/* Find the value */
|
| 1372 |
+
for (j = 0; list[i].strings[j] && (j < v_short); j++);
|
| 1373 |
+
if (!list[i].strings[j])
|
| 1374 |
+
snprintf (val, maxlen, "%i", v_short);
|
| 1375 |
+
else if (!*list[i].strings[j])
|
| 1376 |
+
snprintf (val, maxlen, _("Unknown value %i"), v_short);
|
| 1377 |
+
else
|
| 1378 |
+
strncpy (val, _(list[i].strings[j]), maxlen-1);
|
| 1379 |
+
break;
|
| 1380 |
+
|
| 1381 |
+
case EXIF_TAG_XP_TITLE:
|
| 1382 |
+
case EXIF_TAG_XP_COMMENT:
|
| 1383 |
+
case EXIF_TAG_XP_AUTHOR:
|
| 1384 |
+
case EXIF_TAG_XP_KEYWORDS:
|
| 1385 |
+
case EXIF_TAG_XP_SUBJECT:
|
| 1386 |
+
{
|
| 1387 |
+
unsigned char *utf16;
|
| 1388 |
+
|
| 1389 |
+
/* Sanity check the size to prevent overflow. Note EXIF files are 64kb at most. */
|
| 1390 |
+
if (e->size >= 65536 - sizeof(uint16_t)*2) break;
|
| 1391 |
+
|
| 1392 |
+
/* The tag may not be U+0000-terminated , so make a local
|
| 1393 |
+
U+0000-terminated copy before converting it */
|
| 1394 |
+
utf16 = exif_mem_alloc (e->priv->mem, e->size+sizeof(uint16_t)+1);
|
| 1395 |
+
if (!utf16) break;
|
| 1396 |
+
memcpy(utf16, e->data, e->size);
|
| 1397 |
+
|
| 1398 |
+
/* NUL terminate the string. If the size is odd (which isn't possible
|
| 1399 |
+
* for a valid UTF16 string), then this will overwrite the high byte of
|
| 1400 |
+
* the final half word, plus add a full zero NUL word at the end.
|
| 1401 |
+
*/
|
| 1402 |
+
utf16[e->size] = 0;
|
| 1403 |
+
utf16[e->size+1] = 0;
|
| 1404 |
+
utf16[e->size+2] = 0;
|
| 1405 |
+
|
| 1406 |
+
/* Warning! The texts are converted from UTF16 to UTF8 */
|
| 1407 |
+
/* FIXME: use iconv to convert into the locale encoding */
|
| 1408 |
+
exif_convert_utf16_to_utf8(val, utf16, maxlen);
|
| 1409 |
+
exif_mem_free(e->priv->mem, utf16);
|
| 1410 |
+
break;
|
| 1411 |
+
}
|
| 1412 |
+
|
| 1413 |
+
default:
|
| 1414 |
+
/* Use a generic value formatting */
|
| 1415 |
+
exif_entry_format_value(e, val, maxlen);
|
| 1416 |
+
}
|
| 1417 |
+
|
| 1418 |
+
return val;
|
| 1419 |
+
}
|
| 1420 |
+
|
| 1421 |
+
static
|
| 1422 |
+
void exif_entry_initialize_gps(ExifEntry *e, ExifTag tag) {
|
| 1423 |
+
const ExifGPSIfdTagInfo* info = exif_get_gps_tag_info(tag);
|
| 1424 |
+
|
| 1425 |
+
if(!info) {
|
| 1426 |
+
e->components = 0;
|
| 1427 |
+
e->format = EXIF_FORMAT_UNDEFINED;
|
| 1428 |
+
e->size = 0;
|
| 1429 |
+
e->data = NULL;
|
| 1430 |
+
return;
|
| 1431 |
+
}
|
| 1432 |
+
|
| 1433 |
+
e->format = info->format;
|
| 1434 |
+
e->components = info->components;
|
| 1435 |
+
|
| 1436 |
+
if(info->components == 0) {
|
| 1437 |
+
/* No pre-allocation */
|
| 1438 |
+
e->size = 0;
|
| 1439 |
+
e->data = NULL;
|
| 1440 |
+
} else {
|
| 1441 |
+
int hasDefault = (info->default_size && info->default_value);
|
| 1442 |
+
int allocSize = hasDefault ? info->default_size : (exif_format_get_size (e->format) * e->components);
|
| 1443 |
+
e->size = allocSize;
|
| 1444 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1445 |
+
if(!e->data) {
|
| 1446 |
+
clear_entry(e);
|
| 1447 |
+
return;
|
| 1448 |
+
}
|
| 1449 |
+
if(hasDefault) {
|
| 1450 |
+
memcpy(e->data, info->default_value, info->default_size);
|
| 1451 |
+
}
|
| 1452 |
+
}
|
| 1453 |
+
}
|
| 1454 |
+
|
| 1455 |
+
/*!
|
| 1456 |
+
* \bug Log and report failed exif_mem_malloc() calls.
|
| 1457 |
+
*/
|
| 1458 |
+
void
|
| 1459 |
+
exif_entry_initialize (ExifEntry *e, ExifTag tag)
|
| 1460 |
+
{
|
| 1461 |
+
ExifRational r;
|
| 1462 |
+
ExifByteOrder o;
|
| 1463 |
+
|
| 1464 |
+
/* We need the byte order */
|
| 1465 |
+
if (!e || !e->parent || e->data || !e->parent->parent)
|
| 1466 |
+
return;
|
| 1467 |
+
o = exif_data_get_byte_order (e->parent->parent);
|
| 1468 |
+
|
| 1469 |
+
e->tag = tag;
|
| 1470 |
+
|
| 1471 |
+
if(exif_entry_get_ifd(e) == EXIF_IFD_GPS) {
|
| 1472 |
+
exif_entry_initialize_gps(e, tag);
|
| 1473 |
+
return;
|
| 1474 |
+
}
|
| 1475 |
+
|
| 1476 |
+
switch (tag) {
|
| 1477 |
+
|
| 1478 |
+
/* LONG, 1 component, no default */
|
| 1479 |
+
case EXIF_TAG_PIXEL_X_DIMENSION:
|
| 1480 |
+
case EXIF_TAG_PIXEL_Y_DIMENSION:
|
| 1481 |
+
case EXIF_TAG_EXIF_IFD_POINTER:
|
| 1482 |
+
case EXIF_TAG_GPS_INFO_IFD_POINTER:
|
| 1483 |
+
case EXIF_TAG_INTEROPERABILITY_IFD_POINTER:
|
| 1484 |
+
case EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH:
|
| 1485 |
+
case EXIF_TAG_JPEG_INTERCHANGE_FORMAT:
|
| 1486 |
+
e->components = 1;
|
| 1487 |
+
e->format = EXIF_FORMAT_LONG;
|
| 1488 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1489 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1490 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1491 |
+
break;
|
| 1492 |
+
|
| 1493 |
+
/* SHORT, 1 component, no default */
|
| 1494 |
+
case EXIF_TAG_SUBJECT_LOCATION:
|
| 1495 |
+
case EXIF_TAG_SENSING_METHOD:
|
| 1496 |
+
case EXIF_TAG_PHOTOMETRIC_INTERPRETATION:
|
| 1497 |
+
case EXIF_TAG_COMPRESSION:
|
| 1498 |
+
case EXIF_TAG_EXPOSURE_MODE:
|
| 1499 |
+
case EXIF_TAG_WHITE_BALANCE:
|
| 1500 |
+
case EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM:
|
| 1501 |
+
case EXIF_TAG_GAIN_CONTROL:
|
| 1502 |
+
case EXIF_TAG_SUBJECT_DISTANCE_RANGE:
|
| 1503 |
+
case EXIF_TAG_FLASH:
|
| 1504 |
+
case EXIF_TAG_ISO_SPEED_RATINGS:
|
| 1505 |
+
case EXIF_TAG_SENSITIVITY_TYPE:
|
| 1506 |
+
|
| 1507 |
+
/* SHORT, 1 component, default 0 */
|
| 1508 |
+
case EXIF_TAG_IMAGE_WIDTH:
|
| 1509 |
+
case EXIF_TAG_IMAGE_LENGTH:
|
| 1510 |
+
case EXIF_TAG_EXPOSURE_PROGRAM:
|
| 1511 |
+
case EXIF_TAG_LIGHT_SOURCE:
|
| 1512 |
+
case EXIF_TAG_METERING_MODE:
|
| 1513 |
+
case EXIF_TAG_CUSTOM_RENDERED:
|
| 1514 |
+
case EXIF_TAG_SCENE_CAPTURE_TYPE:
|
| 1515 |
+
case EXIF_TAG_CONTRAST:
|
| 1516 |
+
case EXIF_TAG_SATURATION:
|
| 1517 |
+
case EXIF_TAG_SHARPNESS:
|
| 1518 |
+
e->components = 1;
|
| 1519 |
+
e->format = EXIF_FORMAT_SHORT;
|
| 1520 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1521 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1522 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1523 |
+
exif_set_short (e->data, o, 0);
|
| 1524 |
+
break;
|
| 1525 |
+
|
| 1526 |
+
/* SHORT, 1 component, default 1 */
|
| 1527 |
+
case EXIF_TAG_ORIENTATION:
|
| 1528 |
+
case EXIF_TAG_PLANAR_CONFIGURATION:
|
| 1529 |
+
case EXIF_TAG_YCBCR_POSITIONING:
|
| 1530 |
+
e->components = 1;
|
| 1531 |
+
e->format = EXIF_FORMAT_SHORT;
|
| 1532 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1533 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1534 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1535 |
+
exif_set_short (e->data, o, 1);
|
| 1536 |
+
break;
|
| 1537 |
+
|
| 1538 |
+
/* SHORT, 1 component, default 2 */
|
| 1539 |
+
case EXIF_TAG_RESOLUTION_UNIT:
|
| 1540 |
+
case EXIF_TAG_FOCAL_PLANE_RESOLUTION_UNIT:
|
| 1541 |
+
e->components = 1;
|
| 1542 |
+
e->format = EXIF_FORMAT_SHORT;
|
| 1543 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1544 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1545 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1546 |
+
exif_set_short (e->data, o, 2);
|
| 1547 |
+
break;
|
| 1548 |
+
|
| 1549 |
+
/* SHORT, 1 component, default 3 */
|
| 1550 |
+
case EXIF_TAG_SAMPLES_PER_PIXEL:
|
| 1551 |
+
e->components = 1;
|
| 1552 |
+
e->format = EXIF_FORMAT_SHORT;
|
| 1553 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1554 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1555 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1556 |
+
exif_set_short (e->data, o, 3);
|
| 1557 |
+
break;
|
| 1558 |
+
|
| 1559 |
+
/* SHORT, 1 component, default 0xffff */
|
| 1560 |
+
case EXIF_TAG_COLOR_SPACE:
|
| 1561 |
+
e->components = 1;
|
| 1562 |
+
e->format = EXIF_FORMAT_SHORT;
|
| 1563 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1564 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1565 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1566 |
+
exif_set_short (e->data, o, 0xffff);
|
| 1567 |
+
break;
|
| 1568 |
+
|
| 1569 |
+
/* SHORT, 3 components, default 8 8 8 */
|
| 1570 |
+
case EXIF_TAG_BITS_PER_SAMPLE:
|
| 1571 |
+
e->components = 3;
|
| 1572 |
+
e->format = EXIF_FORMAT_SHORT;
|
| 1573 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1574 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1575 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1576 |
+
exif_set_short (e->data, o, 8);
|
| 1577 |
+
exif_set_short (
|
| 1578 |
+
e->data + exif_format_get_size (e->format),
|
| 1579 |
+
o, 8);
|
| 1580 |
+
exif_set_short (
|
| 1581 |
+
e->data + 2 * exif_format_get_size (e->format),
|
| 1582 |
+
o, 8);
|
| 1583 |
+
break;
|
| 1584 |
+
|
| 1585 |
+
/* SHORT, 2 components, default 2 1 */
|
| 1586 |
+
case EXIF_TAG_YCBCR_SUB_SAMPLING:
|
| 1587 |
+
e->components = 2;
|
| 1588 |
+
e->format = EXIF_FORMAT_SHORT;
|
| 1589 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1590 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1591 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1592 |
+
exif_set_short (e->data, o, 2);
|
| 1593 |
+
exif_set_short (
|
| 1594 |
+
e->data + exif_format_get_size (e->format),
|
| 1595 |
+
o, 1);
|
| 1596 |
+
break;
|
| 1597 |
+
|
| 1598 |
+
/* SRATIONAL, 1 component, no default */
|
| 1599 |
+
case EXIF_TAG_EXPOSURE_BIAS_VALUE:
|
| 1600 |
+
case EXIF_TAG_BRIGHTNESS_VALUE:
|
| 1601 |
+
case EXIF_TAG_SHUTTER_SPEED_VALUE:
|
| 1602 |
+
e->components = 1;
|
| 1603 |
+
e->format = EXIF_FORMAT_SRATIONAL;
|
| 1604 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1605 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1606 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1607 |
+
break;
|
| 1608 |
+
|
| 1609 |
+
/* RATIONAL, 1 component, no default */
|
| 1610 |
+
case EXIF_TAG_EXPOSURE_TIME:
|
| 1611 |
+
case EXIF_TAG_FOCAL_PLANE_X_RESOLUTION:
|
| 1612 |
+
case EXIF_TAG_FOCAL_PLANE_Y_RESOLUTION:
|
| 1613 |
+
case EXIF_TAG_EXPOSURE_INDEX:
|
| 1614 |
+
case EXIF_TAG_FLASH_ENERGY:
|
| 1615 |
+
case EXIF_TAG_FNUMBER:
|
| 1616 |
+
case EXIF_TAG_FOCAL_LENGTH:
|
| 1617 |
+
case EXIF_TAG_SUBJECT_DISTANCE:
|
| 1618 |
+
case EXIF_TAG_MAX_APERTURE_VALUE:
|
| 1619 |
+
case EXIF_TAG_APERTURE_VALUE:
|
| 1620 |
+
case EXIF_TAG_COMPRESSED_BITS_PER_PIXEL:
|
| 1621 |
+
case EXIF_TAG_PRIMARY_CHROMATICITIES:
|
| 1622 |
+
case EXIF_TAG_DIGITAL_ZOOM_RATIO:
|
| 1623 |
+
e->components = 1;
|
| 1624 |
+
e->format = EXIF_FORMAT_RATIONAL;
|
| 1625 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1626 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1627 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1628 |
+
break;
|
| 1629 |
+
|
| 1630 |
+
/* RATIONAL, 1 component, default 72/1 */
|
| 1631 |
+
case EXIF_TAG_X_RESOLUTION:
|
| 1632 |
+
case EXIF_TAG_Y_RESOLUTION:
|
| 1633 |
+
e->components = 1;
|
| 1634 |
+
e->format = EXIF_FORMAT_RATIONAL;
|
| 1635 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1636 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1637 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1638 |
+
r.numerator = 72;
|
| 1639 |
+
r.denominator = 1;
|
| 1640 |
+
exif_set_rational (e->data, o, r);
|
| 1641 |
+
break;
|
| 1642 |
+
|
| 1643 |
+
/* RATIONAL, 2 components, no default */
|
| 1644 |
+
case EXIF_TAG_WHITE_POINT:
|
| 1645 |
+
e->components = 2;
|
| 1646 |
+
e->format = EXIF_FORMAT_RATIONAL;
|
| 1647 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1648 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1649 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1650 |
+
break;
|
| 1651 |
+
|
| 1652 |
+
/* RATIONAL, 6 components */
|
| 1653 |
+
case EXIF_TAG_REFERENCE_BLACK_WHITE:
|
| 1654 |
+
e->components = 6;
|
| 1655 |
+
e->format = EXIF_FORMAT_RATIONAL;
|
| 1656 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1657 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1658 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1659 |
+
r.denominator = 1;
|
| 1660 |
+
r.numerator = 0;
|
| 1661 |
+
exif_set_rational (e->data, o, r);
|
| 1662 |
+
r.numerator = 255;
|
| 1663 |
+
exif_set_rational (
|
| 1664 |
+
e->data + exif_format_get_size (e->format), o, r);
|
| 1665 |
+
r.numerator = 0;
|
| 1666 |
+
exif_set_rational (
|
| 1667 |
+
e->data + 2 * exif_format_get_size (e->format), o, r);
|
| 1668 |
+
r.numerator = 255;
|
| 1669 |
+
exif_set_rational (
|
| 1670 |
+
e->data + 3 * exif_format_get_size (e->format), o, r);
|
| 1671 |
+
r.numerator = 0;
|
| 1672 |
+
exif_set_rational (
|
| 1673 |
+
e->data + 4 * exif_format_get_size (e->format), o, r);
|
| 1674 |
+
r.numerator = 255;
|
| 1675 |
+
exif_set_rational (
|
| 1676 |
+
e->data + 5 * exif_format_get_size (e->format), o, r);
|
| 1677 |
+
break;
|
| 1678 |
+
|
| 1679 |
+
/* ASCII, 20 components */
|
| 1680 |
+
case EXIF_TAG_DATE_TIME:
|
| 1681 |
+
case EXIF_TAG_DATE_TIME_ORIGINAL:
|
| 1682 |
+
case EXIF_TAG_DATE_TIME_DIGITIZED:
|
| 1683 |
+
{
|
| 1684 |
+
time_t t;
|
| 1685 |
+
#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S)
|
| 1686 |
+
struct tm tms;
|
| 1687 |
+
#endif
|
| 1688 |
+
struct tm *tm;
|
| 1689 |
+
|
| 1690 |
+
t = time (NULL);
|
| 1691 |
+
#ifdef HAVE_LOCALTIME_R
|
| 1692 |
+
tm = localtime_r (&t, &tms);
|
| 1693 |
+
#elif HAVE_LOCALTIME_S
|
| 1694 |
+
localtime_s (&tms, &t);
|
| 1695 |
+
tm = &tms;
|
| 1696 |
+
#else
|
| 1697 |
+
tm = localtime (&t);
|
| 1698 |
+
#endif
|
| 1699 |
+
e->components = 20;
|
| 1700 |
+
e->format = EXIF_FORMAT_ASCII;
|
| 1701 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1702 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1703 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1704 |
+
snprintf ((char *) e->data, e->size,
|
| 1705 |
+
"%04i:%02i:%02i %02i:%02i:%02i",
|
| 1706 |
+
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
|
| 1707 |
+
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
| 1708 |
+
break;
|
| 1709 |
+
}
|
| 1710 |
+
|
| 1711 |
+
/* ASCII, no default */
|
| 1712 |
+
case EXIF_TAG_SUB_SEC_TIME:
|
| 1713 |
+
case EXIF_TAG_SUB_SEC_TIME_ORIGINAL:
|
| 1714 |
+
case EXIF_TAG_SUB_SEC_TIME_DIGITIZED:
|
| 1715 |
+
e->components = 0;
|
| 1716 |
+
e->format = EXIF_FORMAT_ASCII;
|
| 1717 |
+
e->size = 0;
|
| 1718 |
+
e->data = NULL;
|
| 1719 |
+
break;
|
| 1720 |
+
|
| 1721 |
+
/* ASCII, default "[None]" */
|
| 1722 |
+
case EXIF_TAG_IMAGE_DESCRIPTION:
|
| 1723 |
+
case EXIF_TAG_MAKE:
|
| 1724 |
+
case EXIF_TAG_MODEL:
|
| 1725 |
+
case EXIF_TAG_SOFTWARE:
|
| 1726 |
+
case EXIF_TAG_ARTIST:
|
| 1727 |
+
e->components = strlen (_("[None]")) + 1;
|
| 1728 |
+
e->format = EXIF_FORMAT_ASCII;
|
| 1729 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1730 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1731 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1732 |
+
strncpy ((char *)e->data, _("[None]"), e->size);
|
| 1733 |
+
break;
|
| 1734 |
+
/* ASCII, default "[None]\0[None]\0" */
|
| 1735 |
+
case EXIF_TAG_COPYRIGHT:
|
| 1736 |
+
e->components = (strlen (_("[None]")) + 1) * 2;
|
| 1737 |
+
e->format = EXIF_FORMAT_ASCII;
|
| 1738 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1739 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1740 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1741 |
+
strcpy (((char *)e->data) + 0, _("[None]"));
|
| 1742 |
+
strcpy (((char *)e->data) + strlen (_("[None]")) + 1, _("[None]"));
|
| 1743 |
+
break;
|
| 1744 |
+
|
| 1745 |
+
/* UNDEFINED, 1 component, default 1 */
|
| 1746 |
+
case EXIF_TAG_SCENE_TYPE:
|
| 1747 |
+
e->components = 1;
|
| 1748 |
+
e->format = EXIF_FORMAT_UNDEFINED;
|
| 1749 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1750 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1751 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1752 |
+
e->data[0] = 0x01;
|
| 1753 |
+
break;
|
| 1754 |
+
|
| 1755 |
+
/* UNDEFINED, 1 component, default 3 */
|
| 1756 |
+
case EXIF_TAG_FILE_SOURCE:
|
| 1757 |
+
e->components = 1;
|
| 1758 |
+
e->format = EXIF_FORMAT_UNDEFINED;
|
| 1759 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1760 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1761 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1762 |
+
e->data[0] = 0x03;
|
| 1763 |
+
break;
|
| 1764 |
+
|
| 1765 |
+
/* UNDEFINED, 4 components, default 48 49 48 48 */
|
| 1766 |
+
case EXIF_TAG_FLASH_PIX_VERSION:
|
| 1767 |
+
e->components = 4;
|
| 1768 |
+
e->format = EXIF_FORMAT_UNDEFINED;
|
| 1769 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1770 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1771 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1772 |
+
memcpy (e->data, "0100", 4);
|
| 1773 |
+
break;
|
| 1774 |
+
|
| 1775 |
+
/* UNDEFINED, 4 components, default 48 50 49 48 */
|
| 1776 |
+
case EXIF_TAG_EXIF_VERSION:
|
| 1777 |
+
e->components = 4;
|
| 1778 |
+
e->format = EXIF_FORMAT_UNDEFINED;
|
| 1779 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1780 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1781 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1782 |
+
memcpy (e->data, "0210", 4);
|
| 1783 |
+
break;
|
| 1784 |
+
|
| 1785 |
+
/* UNDEFINED, 4 components, default 1 2 3 0 */
|
| 1786 |
+
case EXIF_TAG_COMPONENTS_CONFIGURATION:
|
| 1787 |
+
e->components = 4;
|
| 1788 |
+
e->format = EXIF_FORMAT_UNDEFINED;
|
| 1789 |
+
e->size = exif_format_get_size (e->format) * e->components;
|
| 1790 |
+
e->data = exif_entry_alloc (e, e->size);
|
| 1791 |
+
if (!e->data) { clear_entry(e); break; }
|
| 1792 |
+
e->data[0] = 1;
|
| 1793 |
+
e->data[1] = 2;
|
| 1794 |
+
e->data[2] = 3;
|
| 1795 |
+
e->data[3] = 0;
|
| 1796 |
+
break;
|
| 1797 |
+
|
| 1798 |
+
/* UNDEFINED, no components, no default */
|
| 1799 |
+
/* Use this if the tag is otherwise unsupported */
|
| 1800 |
+
case EXIF_TAG_MAKER_NOTE:
|
| 1801 |
+
case EXIF_TAG_USER_COMMENT:
|
| 1802 |
+
default:
|
| 1803 |
+
e->components = 0;
|
| 1804 |
+
e->format = EXIF_FORMAT_UNDEFINED;
|
| 1805 |
+
e->size = 0;
|
| 1806 |
+
e->data = NULL;
|
| 1807 |
+
break;
|
| 1808 |
+
}
|
| 1809 |
+
}
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-entry.h
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*! \file exif-entry.h
|
| 2 |
+
* \brief Handling EXIF entries
|
| 3 |
+
*/
|
| 4 |
+
/*
|
| 5 |
+
* Copyright (c) 2001 Lutz Mueller <[email protected]>
|
| 6 |
+
*
|
| 7 |
+
* This library is free software; you can redistribute it and/or
|
| 8 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 9 |
+
* License as published by the Free Software Foundation; either
|
| 10 |
+
* version 2 of the License, or (at your option) any later version.
|
| 11 |
+
*
|
| 12 |
+
* This library is distributed in the hope that it will be useful,
|
| 13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 15 |
+
* Lesser General Public License for more details.
|
| 16 |
+
*
|
| 17 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 18 |
+
* License along with this library; if not, write to the
|
| 19 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 20 |
+
* Boston, MA 02110-1301 USA.
|
| 21 |
+
*/
|
| 22 |
+
|
| 23 |
+
#ifndef __EXIF_ENTRY_H__
|
| 24 |
+
#define __EXIF_ENTRY_H__
|
| 25 |
+
|
| 26 |
+
#ifdef __cplusplus
|
| 27 |
+
extern "C" {
|
| 28 |
+
#endif /* __cplusplus */
|
| 29 |
+
|
| 30 |
+
/*! Data found in one EXIF tag.
|
| 31 |
+
* The #exif_entry_get_value function can provide access to the
|
| 32 |
+
* formatted contents, or the struct members can be used directly to
|
| 33 |
+
* access the raw contents.
|
| 34 |
+
*/
|
| 35 |
+
typedef struct _ExifEntry ExifEntry;
|
| 36 |
+
typedef struct _ExifEntryPrivate ExifEntryPrivate;
|
| 37 |
+
|
| 38 |
+
#include <libexif/exif-content.h>
|
| 39 |
+
#include <libexif/exif-format.h>
|
| 40 |
+
#include <libexif/exif-mem.h>
|
| 41 |
+
|
| 42 |
+
/*! Data found in one EXIF tag */
|
| 43 |
+
struct _ExifEntry {
|
| 44 |
+
/*! EXIF tag for this entry */
|
| 45 |
+
ExifTag tag;
|
| 46 |
+
|
| 47 |
+
/*! Type of data in this entry */
|
| 48 |
+
ExifFormat format;
|
| 49 |
+
|
| 50 |
+
/*! Number of elements in the array, if this is an array entry.
|
| 51 |
+
* Contains 1 for non-array data types. */
|
| 52 |
+
unsigned long components;
|
| 53 |
+
|
| 54 |
+
/*! Pointer to the raw EXIF data for this entry. It is allocated
|
| 55 |
+
* by #exif_entry_initialize and is NULL beforehand. Data contained
|
| 56 |
+
* here may be manipulated using the functions in exif-utils.h */
|
| 57 |
+
unsigned char *data;
|
| 58 |
+
|
| 59 |
+
/*! Number of bytes in the buffer at \c data. This must be no less
|
| 60 |
+
* than exif_format_get_size(format)*components */
|
| 61 |
+
unsigned int size;
|
| 62 |
+
|
| 63 |
+
/*! #ExifContent containing this entry.
|
| 64 |
+
* \see exif_entry_get_ifd */
|
| 65 |
+
ExifContent *parent;
|
| 66 |
+
|
| 67 |
+
/*! Internal data to be used by libexif itself */
|
| 68 |
+
ExifEntryPrivate *priv;
|
| 69 |
+
};
|
| 70 |
+
|
| 71 |
+
/* Lifecycle */
|
| 72 |
+
|
| 73 |
+
/*! Reserve memory for and initialize a new #ExifEntry.
|
| 74 |
+
* No memory is allocated for the \c data element of the returned #ExifEntry.
|
| 75 |
+
*
|
| 76 |
+
* \return new allocated #ExifEntry, or NULL on error
|
| 77 |
+
*
|
| 78 |
+
* \see exif_entry_new_mem, exif_entry_unref
|
| 79 |
+
*/
|
| 80 |
+
ExifEntry *exif_entry_new (void);
|
| 81 |
+
|
| 82 |
+
/*! Reserve memory for and initialize new #ExifEntry using the specified
|
| 83 |
+
* memory allocator.
|
| 84 |
+
* No memory is allocated for the \c data element of the returned #ExifEntry.
|
| 85 |
+
*
|
| 86 |
+
* \return new allocated #ExifEntry, or NULL on error
|
| 87 |
+
*
|
| 88 |
+
* \see exif_entry_new, exif_entry_unref
|
| 89 |
+
*/
|
| 90 |
+
ExifEntry *exif_entry_new_mem (ExifMem *);
|
| 91 |
+
|
| 92 |
+
/*! Increase reference counter for #ExifEntry.
|
| 93 |
+
*
|
| 94 |
+
* \param[in] entry #ExifEntry
|
| 95 |
+
*
|
| 96 |
+
* \see exif_entry_unref
|
| 97 |
+
*/
|
| 98 |
+
void exif_entry_ref (ExifEntry *entry);
|
| 99 |
+
|
| 100 |
+
/*! Decrease reference counter for #ExifEntry.
|
| 101 |
+
* When the reference count drops to zero, free the entry.
|
| 102 |
+
*
|
| 103 |
+
* \param[in] entry #ExifEntry
|
| 104 |
+
*/
|
| 105 |
+
void exif_entry_unref (ExifEntry *entry);
|
| 106 |
+
|
| 107 |
+
/*! Actually free the #ExifEntry.
|
| 108 |
+
*
|
| 109 |
+
* \deprecated Should not be called directly. Use #exif_entry_ref and
|
| 110 |
+
* #exif_entry_unref instead.
|
| 111 |
+
*
|
| 112 |
+
* \param[in] entry EXIF entry
|
| 113 |
+
*/
|
| 114 |
+
void exif_entry_free (ExifEntry *entry);
|
| 115 |
+
|
| 116 |
+
/*! Initialize an empty #ExifEntry with default data in the correct format
|
| 117 |
+
* for the given tag. If the entry is already initialized, this function
|
| 118 |
+
* does nothing.
|
| 119 |
+
* This call allocates memory for the \c data element of the given #ExifEntry.
|
| 120 |
+
* That memory is freed at the same time as the #ExifEntry.
|
| 121 |
+
*
|
| 122 |
+
* \param[out] e entry to initialize
|
| 123 |
+
* \param[in] tag tag number to initialize as
|
| 124 |
+
*/
|
| 125 |
+
void exif_entry_initialize (ExifEntry *e, ExifTag tag);
|
| 126 |
+
|
| 127 |
+
/*! Fix the type or format of the given EXIF entry to bring it into spec.
|
| 128 |
+
* If the data for this EXIF tag is in of the wrong type or is in an invalid
|
| 129 |
+
* format according to the EXIF specification, then it is converted to make it
|
| 130 |
+
* valid. This may involve, for example, converting an EXIF_FORMAT_LONG into a
|
| 131 |
+
* EXIF_FORMAT_SHORT. If the tag is unknown, its value is untouched.
|
| 132 |
+
*
|
| 133 |
+
* \note Unfortunately, some conversions are to a type with a more restricted
|
| 134 |
+
* range, which could have the side effect that the converted data becomes
|
| 135 |
+
* invalid. This is unlikely as the range of each tag in the standard is
|
| 136 |
+
* designed to encompass all likely data.
|
| 137 |
+
*
|
| 138 |
+
* \param[in,out] entry EXIF entry
|
| 139 |
+
*/
|
| 140 |
+
void exif_entry_fix (ExifEntry *entry);
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
/* For your convenience */
|
| 144 |
+
|
| 145 |
+
/*! Return a localized textual representation of the value of the EXIF entry.
|
| 146 |
+
* This is meant for display to the user. The format of each tag is subject
|
| 147 |
+
* to change between locales and in newer versions of libexif. Users who
|
| 148 |
+
* require the tag data in an unambiguous form should access the data members
|
| 149 |
+
* of the #ExifEntry structure directly.
|
| 150 |
+
*
|
| 151 |
+
* \warning The character set of the returned string may be in
|
| 152 |
+
* the encoding of the current locale or the native encoding
|
| 153 |
+
* of the camera.
|
| 154 |
+
* \bug The EXIF_TAG_XP_* tags are currently always returned in UTF-8,
|
| 155 |
+
* regardless of locale, and code points above U+FFFF are not
|
| 156 |
+
* supported.
|
| 157 |
+
*
|
| 158 |
+
* \param[in] entry EXIF entry
|
| 159 |
+
* \param[out] val buffer in which to store value; if entry is valid and
|
| 160 |
+
* maxlen > 0 then this string will be NUL-terminated
|
| 161 |
+
* \param[in] maxlen length of the buffer val
|
| 162 |
+
* \return val pointer
|
| 163 |
+
*/
|
| 164 |
+
const char *exif_entry_get_value (ExifEntry *entry, char *val,
|
| 165 |
+
unsigned int maxlen);
|
| 166 |
+
|
| 167 |
+
/*! Dump text representation of #ExifEntry to stdout.
|
| 168 |
+
* This is intended for diagnostic purposes only.
|
| 169 |
+
*
|
| 170 |
+
* \param[in] entry EXIF tag data
|
| 171 |
+
* \param[in] indent how many levels deep to indent the data
|
| 172 |
+
*/
|
| 173 |
+
void exif_entry_dump (ExifEntry *entry, unsigned int indent);
|
| 174 |
+
|
| 175 |
+
/*! Return the IFD number of the given #ExifEntry
|
| 176 |
+
*
|
| 177 |
+
* \param[in] e an #ExifEntry*
|
| 178 |
+
* \return #ExifIfd, or #EXIF_IFD_COUNT on error
|
| 179 |
+
*/
|
| 180 |
+
#define exif_entry_get_ifd(e) ((e)?exif_content_get_ifd((e)->parent):EXIF_IFD_COUNT)
|
| 181 |
+
|
| 182 |
+
#ifdef __cplusplus
|
| 183 |
+
}
|
| 184 |
+
#endif /* __cplusplus */
|
| 185 |
+
|
| 186 |
+
#endif /* __EXIF_ENTRY_H__ */
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-format.c
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* exif-format.c
|
| 2 |
+
*
|
| 3 |
+
* Copyright (c) 2001 Lutz Mueller <[email protected]>
|
| 4 |
+
*
|
| 5 |
+
* This library is free software; you can redistribute it and/or
|
| 6 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 7 |
+
* License as published by the Free Software Foundation; either
|
| 8 |
+
* version 2 of the License, or (at your option) any later version.
|
| 9 |
+
*
|
| 10 |
+
* This library is distributed in the hope that it will be useful,
|
| 11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
+
* Lesser General Public License for more details.
|
| 14 |
+
*
|
| 15 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 16 |
+
* License along with this library; if not, write to the
|
| 17 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 18 |
+
* Boston, MA 02110-1301 USA.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#include <config.h>
|
| 22 |
+
|
| 23 |
+
#include <libexif/exif-format.h>
|
| 24 |
+
#include <libexif/i18n.h>
|
| 25 |
+
|
| 26 |
+
#include <stdlib.h>
|
| 27 |
+
|
| 28 |
+
/*! Table of data format types, descriptions and sizes.
|
| 29 |
+
* This table should be sorted in decreasing order of popularity in order
|
| 30 |
+
* to decrease the total average lookup time.
|
| 31 |
+
*/
|
| 32 |
+
static const struct {
|
| 33 |
+
ExifFormat format;
|
| 34 |
+
const char *name;
|
| 35 |
+
unsigned char size;
|
| 36 |
+
} ExifFormatTable[] = {
|
| 37 |
+
{EXIF_FORMAT_SHORT, N_("Short"), 2},
|
| 38 |
+
{EXIF_FORMAT_RATIONAL, N_("Rational"), 8},
|
| 39 |
+
{EXIF_FORMAT_SRATIONAL, N_("SRational"), 8},
|
| 40 |
+
{EXIF_FORMAT_UNDEFINED, N_("Undefined"), 1},
|
| 41 |
+
{EXIF_FORMAT_ASCII, N_("ASCII"), 1},
|
| 42 |
+
{EXIF_FORMAT_LONG, N_("Long"), 4},
|
| 43 |
+
{EXIF_FORMAT_BYTE, N_("Byte"), 1},
|
| 44 |
+
{EXIF_FORMAT_SBYTE, N_("SByte"), 1},
|
| 45 |
+
{EXIF_FORMAT_SSHORT, N_("SShort"), 2},
|
| 46 |
+
{EXIF_FORMAT_SLONG, N_("SLong"), 4},
|
| 47 |
+
{EXIF_FORMAT_FLOAT, N_("Float"), 4},
|
| 48 |
+
{EXIF_FORMAT_DOUBLE, N_("Double"), 8},
|
| 49 |
+
{0, NULL, 0}
|
| 50 |
+
};
|
| 51 |
+
|
| 52 |
+
const char *
|
| 53 |
+
exif_format_get_name (ExifFormat format)
|
| 54 |
+
{
|
| 55 |
+
unsigned int i;
|
| 56 |
+
|
| 57 |
+
(void) bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
| 58 |
+
|
| 59 |
+
for (i = 0; ExifFormatTable[i].name; i++)
|
| 60 |
+
if (ExifFormatTable[i].format == format)
|
| 61 |
+
return _(ExifFormatTable[i].name);
|
| 62 |
+
return NULL;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
unsigned char
|
| 66 |
+
exif_format_get_size (ExifFormat format)
|
| 67 |
+
{
|
| 68 |
+
unsigned int i;
|
| 69 |
+
|
| 70 |
+
for (i = 0; ExifFormatTable[i].size; i++)
|
| 71 |
+
if (ExifFormatTable[i].format == format)
|
| 72 |
+
return ExifFormatTable[i].size;
|
| 73 |
+
return 0;
|
| 74 |
+
}
|
local-test-libexif-delta-01-exif-003/afc-libexif/libexif/exif-format.h
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*! \file exif-format.h
|
| 2 |
+
* \brief Handling native EXIF data types
|
| 3 |
+
*/
|
| 4 |
+
/*
|
| 5 |
+
*
|
| 6 |
+
* Copyright (c) 2001 Lutz Mueller <[email protected]>
|
| 7 |
+
*
|
| 8 |
+
* This library is free software; you can redistribute it and/or
|
| 9 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 10 |
+
* License as published by the Free Software Foundation; either
|
| 11 |
+
* version 2 of the License, or (at your option) any later version.
|
| 12 |
+
*
|
| 13 |
+
* This library is distributed in the hope that it will be useful,
|
| 14 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 15 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 16 |
+
* Lesser General Public License for more details.
|
| 17 |
+
*
|
| 18 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 19 |
+
* License along with this library; if not, write to the
|
| 20 |
+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| 21 |
+
* Boston, MA 02110-1301 USA.
|
| 22 |
+
*/
|
| 23 |
+
|
| 24 |
+
#ifndef __EXIF_FORMAT_H__
|
| 25 |
+
#define __EXIF_FORMAT_H__
|
| 26 |
+
|
| 27 |
+
#ifdef __cplusplus
|
| 28 |
+
extern "C" {
|
| 29 |
+
#endif /* __cplusplus */
|
| 30 |
+
|
| 31 |
+
/*! EXIF tag data formats */
|
| 32 |
+
typedef enum {
|
| 33 |
+
EXIF_FORMAT_BYTE = 1,
|
| 34 |
+
EXIF_FORMAT_ASCII = 2,
|
| 35 |
+
EXIF_FORMAT_SHORT = 3,
|
| 36 |
+
EXIF_FORMAT_LONG = 4,
|
| 37 |
+
EXIF_FORMAT_RATIONAL = 5,
|
| 38 |
+
EXIF_FORMAT_SBYTE = 6,
|
| 39 |
+
EXIF_FORMAT_UNDEFINED = 7,
|
| 40 |
+
EXIF_FORMAT_SSHORT = 8,
|
| 41 |
+
EXIF_FORMAT_SLONG = 9,
|
| 42 |
+
EXIF_FORMAT_SRATIONAL = 10,
|
| 43 |
+
EXIF_FORMAT_FLOAT = 11,
|
| 44 |
+
EXIF_FORMAT_DOUBLE = 12
|
| 45 |
+
} ExifFormat;
|
| 46 |
+
|
| 47 |
+
/*! Return a textual representation of the given EXIF data type.
|
| 48 |
+
*
|
| 49 |
+
* \param[in] format EXIF data format
|
| 50 |
+
* \return localized textual name, or NULL if unknown
|
| 51 |
+
*/
|
| 52 |
+
const char *exif_format_get_name (ExifFormat format);
|
| 53 |
+
|
| 54 |
+
/*! Return the raw size of the given EXIF data type.
|
| 55 |
+
*
|
| 56 |
+
* \param[in] format EXIF data format
|
| 57 |
+
* \return size in bytes
|
| 58 |
+
*/
|
| 59 |
+
unsigned char exif_format_get_size (ExifFormat format);
|
| 60 |
+
|
| 61 |
+
#ifdef __cplusplus
|
| 62 |
+
}
|
| 63 |
+
#endif /* __cplusplus */
|
| 64 |
+
|
| 65 |
+
#endif /* __EXIF_FORMAT_H__ */
|