webp/examples/metadata.h
James Zern 63aba3aef1 cwebp: add metadata framework
unused currently, but the intent is to allow each format to populate
exif/xmp/icc with cwebp then transferring it to the webp file.

Change-Id: I0514f62de52fa7f89c595ee7ef2ad7dced910a41
2012-12-06 14:29:10 -08:00

54 lines
1.3 KiB
C

// Copyright 2012 Google Inc. All Rights Reserved.
//
// This code is licensed under the same terms as WebM:
// Software License Agreement: http://www.webmproject.org/license/software/
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
// -----------------------------------------------------------------------------
//
// Metadata types and functions.
//
#ifndef WEBP_EXAMPLES_METADATA_H_
#define WEBP_EXAMPLES_METADATA_H_
#include "webp/types.h"
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
typedef struct MetadataPayload {
uint8_t* bytes;
size_t size;
} MetadataPayload;
typedef struct Metadata {
MetadataPayload exif;
MetadataPayload iccp;
MetadataPayload xmp;
} Metadata;
#define METADATA_OFFSET(x) offsetof(Metadata, x)
static void MetadataInit(Metadata* const m) {
memset(m, 0, sizeof(*m));
}
static void MetadataPayloadDelete(MetadataPayload* const payload) {
free(payload->bytes);
payload->bytes = NULL;
payload->size = 0;
}
static void MetadataFree(Metadata* const m) {
MetadataPayloadDelete(&m->exif);
MetadataPayloadDelete(&m->iccp);
MetadataPayloadDelete(&m->xmp);
}
#if defined(__cplusplus) || defined(c_plusplus)
} // extern "C"
#endif
#endif // WEBP_EXAMPLES_METADATA_H_