FFmpeg
Loading...
Searching...
No Matches
exif_internal.h
Go to the documentation of this file.
1/*
2 * EXIF metadata parser - internal functions
3 * Copyright (c) 2013 Thilo Borgmann <thilo.borgmann _at_ mail.de>
4 * Copyright (c) 2024-2025 Leo Izen <leo.izen@gmail.com>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg 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.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg 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 FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23/**
24 * @file
25 * EXIF metadata parser - internal functions
26 * @author Thilo Borgmann <thilo.borgmann _at_ mail.de>
27 * @author Leo Izen <leo.izen@gmail.com>
28 */
29
30#ifndef AVCODEC_EXIF_INTERNAL_H
31#define AVCODEC_EXIF_INTERNAL_H
32
33#include "libavutil/buffer.h"
34#include "libavutil/frame.h"
35
36#include "exif.h"
37
38/**
39 * Compares values in the IFD with data in the provided AVFrame and sets the values
40 * in that IFD to match the ones in that AVFrame. This is mostly useful for an
41 * encoder that wishes to use ff_exif_get_buffer, but would prefer to modify the
42 * IFD after it is sanitized and call av_exif_write afterward.
43 */
44int ff_exif_sanitize_ifd(void *logctx, const AVFrame *frame, AVExifMetadata *ifd);
45
46/**
47 * Gets all relevant side data, collects it into an IFD, and writes it into the
48 * corresponding buffer pointer. This includes both AV_FRAME_DATA_EXIF and other
49 * side data types that are included in the frame data, such as possibly an
50 * instance of AV_FRAME_DATA_DISPLAYMATRIX. It also sets width and height tags
51 * to match those of the AVFrame if they are different.
52 * The *buffer argument must be NULL before calling.
53 *
54 * On success, a positive number is returned, and the buffer becomes owned by the caller.
55 * A negative AVERROR return value means that an error occurred.
56 * A zero return value means that there was no EXIF data to write.
57 * In both the negative and zero cases, *buffer will be NULL.
58 */
59int ff_exif_get_buffer(void *logctx, const AVFrame *frame, AVBufferRef **buffer, enum AVExifHeaderMode header_mode);
60
61struct AVCodecContext;
62/**
63 * Attach the data buffer to the frame. This is mostly a wrapper for
64 * av_side_data_new_from_buffer, but it checks if the orientation tag is
65 * present in the provided EXIF buffer. If it is, it zeroes it out and
66 * attaches that information as an AV_FRAME_DATA_DISPLAYMATRIX instead
67 * of including it in the AV_FRAME_DATA_EXIF side data buffer.
68 *
69 * *buf is ALWAYS consumed by this function and NULL written in its place, even
70 * on failure.
71 */
73 enum AVExifHeaderMode header_mode);
74
75/**
76 * Attach an already-parsed EXIF metadata struct to the frame as a side data
77 * buffer. It writes the EXIF IFD into the buffer and attaches the buffer to
78 * the frame.
79 *
80 * If the metadata struct contains an orientation tag, it will be zeroed before
81 * writing, and instead, an AV_FRAME_DATA_DISPLAYMATRIX will be attached in
82 * addition to the AV_FRAME_DATA_EXIF side data.
83 */
85 const struct AVExifMetadata *ifd);
86
87#endif /* AVCODEC_EXIF_INTERNAL_H */
refcounted data buffer API
static AVFrame * frame
EXIF metadata parser.
AVExifHeaderMode
Definition exif.h:57
int ff_decode_exif_attach_buffer(struct AVCodecContext *avctx, AVFrame *frame, AVBufferRef **buf, enum AVExifHeaderMode header_mode)
Attach the data buffer to the frame.
Definition decode.c:2498
int ff_exif_get_buffer(void *logctx, const AVFrame *frame, AVBufferRef **buffer, enum AVExifHeaderMode header_mode)
Gets all relevant side data, collects it into an IFD, and writes it into the corresponding buffer poi...
Definition exif.c:1493
int ff_decode_exif_attach_ifd(struct AVCodecContext *avctx, AVFrame *frame, const struct AVExifMetadata *ifd)
Attach an already-parsed EXIF metadata struct to the frame as a side data buffer.
int ff_exif_sanitize_ifd(void *logctx, const AVFrame *frame, AVExifMetadata *ifd)
Compares values in the IFD with data in the provided AVFrame and sets the values in that IFD to match...
Definition exif.c:1364
reference-counted frame API
A reference to a data buffer.
Definition buffer.h:82
main external API structure.
Definition avcodec.h:443
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
static char buffer[20]
Definition seek.c:32