FFmpeg
Loading...
Searching...
No Matches
tiff_common.h
Go to the documentation of this file.
1/*
2 * TIFF Common Routines
3 * Copyright (c) 2013 Thilo Borgmann <thilo.borgmann _at_ mail.de>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg 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.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg 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 FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22/**
23 * @file
24 * TIFF Common Routines
25 * @author Thilo Borgmann <thilo.borgmann _at_ mail.de>
26 */
27
28#ifndef AVCODEC_TIFF_COMMON_H
29#define AVCODEC_TIFF_COMMON_H
30
31#include <stdint.h>
32#include "libavutil/dict.h"
33#include "bytestream.h"
34#include "exif.h"
35
36/** sizes of various TIFF field types (string size = 100)*/
37static const uint8_t type_sizes[14] = {
38 0, 1, 100, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 4
39};
40
41static const uint16_t ifd_tags[] = {
42 0x8769, // EXIF IFD
43 0x8825, // GPS IFD
44 0xA005 // Interoperability IFD
45};
46
47
48/** Returns a value > 0 if the tag is a known IFD-tag.
49 * The return value is the array index + 1 within ifd_tags[].
50 */
51int ff_tis_ifd(unsigned tag);
52
53/** Reads a short from the bytestream using given endianness. */
54unsigned ff_tget_short(GetByteContext *gb, int le);
55
56/** Reads a long from the bytestream using given endianness. */
57unsigned ff_tget_long(GetByteContext *gb, int le);
58
59/** Reads a double from the bytestream using given endianness. */
60double ff_tget_double(GetByteContext *gb, int le);
61
62/** Reads a byte from the bytestream using given endianness. */
63unsigned ff_tget(GetByteContext *gb, int type, int le);
64
65/** Adds count doubles converted to a string
66 * into the metadata dictionary.
67 */
68int ff_tadd_doubles_metadata(int count, const char *name, const char *sep,
69 GetByteContext *gb, int le, AVDictionary **metadata);
70
71/** Adds count shorts converted to a string
72 * into the metadata dictionary.
73 */
74int ff_tadd_shorts_metadata(int count, const char *name, const char *sep,
75 GetByteContext *gb, int le, int is_signed, AVDictionary **metadata);
76
77/** Adds a string of count characters
78 * into the metadata dictionary.
79 */
80int ff_tadd_string_metadata(int count, const char *name,
81 GetByteContext *gb, int le, AVDictionary **metadata);
82
83/** Decodes a TIFF header from the input bytestream
84 * and sets the endianness in *le and the offset to
85 * the first IFD in *ifd_offset accordingly.
86 */
87int ff_tdecode_header(GetByteContext *gb, int *le, int *ifd_offset);
88
89/** Reads the first 3 fields of a TIFF tag, which are
90 * the tag id, the tag type and the count of values for that tag.
91 * Afterwards the bytestream is located at the first value to read and
92 * *next holds the bytestream offset of the following tag.
93 */
94int ff_tread_tag(GetByteContext *gb, int le, unsigned *tag, unsigned *type,
95 unsigned *count, int *next);
96
97#endif /* AVCODEC_TIFF_COMMON_H */
static int FUNC metadata(CodedBitstreamContext *ctx, RWContext *rw, APVRawMetadata *current)
Public dictionary API.
EXIF metadata parser.
cl_device_type type
uint32_t tag
Definition movenc.c:2073
const char * name
Definition qsvenc.c:142
unsigned ff_tget(GetByteContext *gb, int type, int le)
Reads a byte from the bytestream using given endianness.
Definition tiff_common.c:64
int ff_tis_ifd(unsigned tag)
Returns a value > 0 if the tag is a known IFD-tag.
Definition tiff_common.c:33
int ff_tadd_shorts_metadata(int count, const char *name, const char *sep, GetByteContext *gb, int le, int is_signed, AVDictionary **metadata)
Adds count shorts converted to a string into the metadata dictionary.
int ff_tadd_string_metadata(int count, const char *name, GetByteContext *gb, int le, AVDictionary **metadata)
Adds a string of count characters into the metadata dictionary.
int ff_tread_tag(GetByteContext *gb, int le, unsigned *tag, unsigned *type, unsigned *count, int *next)
Reads the first 3 fields of a TIFF tag, which are the tag id, the tag type and the count of values fo...
int ff_tdecode_header(GetByteContext *gb, int *le, int *ifd_offset)
Decodes a TIFF header from the input bytestream and sets the endianness in *le and the offset to the ...
unsigned ff_tget_short(GetByteContext *gb, int le)
Reads a short from the bytestream using given endianness.
Definition tiff_common.c:45
int ff_tadd_doubles_metadata(int count, const char *name, const char *sep, GetByteContext *gb, int le, AVDictionary **metadata)
Adds count doubles converted to a string into the metadata dictionary.
double ff_tget_double(GetByteContext *gb, int le)
Reads a double from the bytestream using given endianness.
Definition tiff_common.c:57
static const uint16_t ifd_tags[]
Definition tiff_common.h:41
unsigned ff_tget_long(GetByteContext *gb, int le)
Reads a long from the bytestream using given endianness.
Definition tiff_common.c:51
static const uint8_t type_sizes[14]
sizes of various TIFF field types (string size = 100)
Definition tiff_common.h:37