FFmpeg
Data Structures | Macros | Enumerations | Functions
exif.h File Reference
#include <stddef.h>
#include <stdint.h>
#include "libavutil/buffer.h"
#include "libavutil/dict.h"
#include "libavutil/rational.h"
#include "version_major.h"

Go to the source code of this file.

Data Structures

struct   AVExifMetadata
 
struct   AVExifEntry
 

Macros

#define  AV_EXIF_FLAG_RECURSIVE   (1 << 0)
  Also check subdirectories. More...
 

Enumerations

  Data type identifiers for TIFF tags. More...
 
 

Functions

const char *  av_exif_get_tag_name (uint16_t id)
  Retrieves the tag name associated with the provided tag ID. More...
 
  Retrieves the tag ID associated with the provided tag string name. More...
 
int  av_exif_set_entry (void *logctx, AVExifMetadata *ifd, uint16_t id, enum AVTiffDataType type, uint32_t count, const uint8_t *ifd_lead, uint32_t ifd_offset, const void *value)
  Add an entry to the provided EXIF metadata struct. More...
 
int  av_exif_get_entry (void *logctx, AVExifMetadata *ifd, uint16_t id, int flags, AVExifEntry **value)
  Get an entry with the tagged ID from the EXIF metadata struct. More...
 
int  av_exif_remove_entry (void *logctx, AVExifMetadata *ifd, uint16_t id, int flags)
  Remove an entry from the provided EXIF metadata struct. More...
 
int  av_exif_parse_buffer (void *logctx, const uint8_t *data, size_t size, AVExifMetadata *ifd, enum AVExifHeaderMode header_mode)
  Decodes the EXIF data provided in the buffer and writes it into the struct *ifd. More...
 
int  av_exif_write (void *logctx, const AVExifMetadata *ifd, AVBufferRef **buffer, enum AVExifHeaderMode header_mode)
  Allocates a buffer using av_malloc of an appropriate size and writes the EXIF data represented by ifd into that buffer. More...
 
  Frees all resources associated with the given EXIF metadata struct. More...
 
int  av_exif_ifd_to_dict (void *logctx, const AVExifMetadata *ifd, AVDictionary **metadata)
  Recursively reads all tags from the IFD and stores them in the provided metadata dictionary. More...
 
  Allocates a duplicate of the provided EXIF metadata struct. More...
 
  Convert a display matrix used by AV_FRAME_DATA_DISPLAYMATRIX into an orientation constant used by EXIF's orientation tag. More...
 
int  av_exif_orientation_to_matrix (int32_t *matrix, int orientation)
  Convert an orientation constant used by EXIF's orientation tag into a display matrix used by AV_FRAME_DATA_DISPLAYMATRIX. More...
 

Detailed Description

EXIF metadata parser

Author
Thilo Borgmann <thilo.borgmann at mail.de>
Leo Izen leo.i.nosp@m.zen@.nosp@m.gmail.nosp@m..com

Definition in file exif.h.

Macro Definition Documentation

AV_EXIF_FLAG_RECURSIVE

#define AV_EXIF_FLAG_RECURSIVE   (1 << 0)

Also check subdirectories.

Definition at line 150 of file exif.h.

Enumeration Type Documentation

AVTiffDataType

Data type identifiers for TIFF tags.

Enumerator
AV_TIFF_BYTE 
AV_TIFF_STRING 
AV_TIFF_SHORT 
AV_TIFF_LONG 
AV_TIFF_RATIONAL 
AV_TIFF_SBYTE 
AV_TIFF_UNDEFINED 
AV_TIFF_SSHORT 
AV_TIFF_SLONG 
AV_TIFF_SRATIONAL 
AV_TIFF_FLOAT 
AV_TIFF_DOUBLE 
AV_TIFF_IFD 

Definition at line 42 of file exif.h.

AVExifHeaderMode

Enumerator
AV_EXIF_TIFF_HEADER 

The TIFF header starts with 0x49492a00, or 0x4d4d002a.

This one is used internally by FFmpeg.

AV_EXIF_ASSUME_LE 

skip the TIFF header, assume little endian

AV_EXIF_ASSUME_BE 

skip the TIFF header, assume big endian

AV_EXIF_T_OFF 

The first four bytes point to the actual start, then it's AV_EXIF_TIFF_HEADER.

AV_EXIF_EXIF00 

The first six bytes contain "Exif0円0円", then it's AV_EXIF_TIFF_HEADER.

Definition at line 58 of file exif.h.

Function Documentation

av_exif_get_tag_name()

const char* av_exif_get_tag_name ( uint16_t  id )

Retrieves the tag name associated with the provided tag ID.

If the tag ID is unknown, NULL is returned.

For example, av_exif_get_tag_name(0x112) returns "Orientation".

Definition at line 215 of file exif.c.

Referenced by exif_ifd_to_dict().

av_exif_get_tag_id()

int32_t av_exif_get_tag_id ( const char *  name )

Retrieves the tag ID associated with the provided tag string name.

If the tag name is unknown, a negative number is returned. Otherwise it always fits inside a uint16_t integer.

For example, av_exif_get_tag_id("Orientation") returns 274 (0x0112).

Definition at line 225 of file exif.c.

Referenced by exif_attach_ifd(), libjxl_attach_sidedata(), libjxl_preprocess_stream(), mov_parse_exif_item(), and side_data_exif_parse().

av_exif_set_entry()

int av_exif_set_entry ( void *  logctx,
AVExifMetadataifd,
uint16_t  id,
enum AVTiffDataType  type,
uint32_t  count,
const uint8_t *  ifd_lead,
uint32_t  ifd_offset,
const void *  value 
)

Add an entry to the provided EXIF metadata struct.

If one already exists with the provided ID, it will set the existing one to have the other information provided. Otherwise, it will allocate a new entry.

This function reallocates ifd->entries using av_realloc and allocates (using av_malloc) a new value member of the entry, then copies the contents of value into that buffer.

Definition at line 1059 of file exif.c.

Referenced by ff_exif_sanitize_ifd().

av_exif_get_entry()

int av_exif_get_entry ( void *  logctx,
AVExifMetadataifd,
uint16_t  id,
int  flags,
AVExifEntry **  value 
)

Get an entry with the tagged ID from the EXIF metadata struct.

A pointer to the entry will be written into *value.

If the entry was present and returned successfully, a positive number is returned. If the entry was not found, *value is left untouched and zero is returned. If an error occurred, a negative number is returned.

Definition at line 1054 of file exif.c.

Referenced by av_exif_set_entry(), ff_exif_sanitize_ifd(), libjxl_preprocess_stream(), and side_data_exif_parse().

av_exif_remove_entry()

int av_exif_remove_entry ( void *  logctx,
AVExifMetadataifd,
uint16_t  id,
int  flags 
)

Remove an entry from the provided EXIF metadata struct.

If the entry was present and removed successfully, a positive number is returned. If the entry was not found, zero is returned. If an error occurred, a negative number is returned.

Definition at line 1143 of file exif.c.

Referenced by exif_attach_ifd(), libjxl_attach_sidedata(), libjxl_preprocess_stream(), mov_parse_exif_item(), and side_data_exif_parse().

av_exif_parse_buffer()

int av_exif_parse_buffer ( void *  logctx,
const uint8_t *  data,
size_t  size,
AVExifMetadataifd,
enum AVExifHeaderMode  header_mode 
)

Decodes the EXIF data provided in the buffer and writes it into the struct *ifd.

If this function succeeds, the IFD is owned by the caller and must be cleared after use by calling av_exif_free(); If this function fails and returns a negative value, it will call av_exif_free(ifd) before returning.

Definition at line 767 of file exif.c.

Referenced by avi_extract_stream_metadata(), decode_frame(), ff_decode_exif_attach_buffer(), ff_exif_get_buffer(), libjxl_attach_sidedata(), libjxl_preprocess_stream(), mjpeg_decode_app(), mov_parse_exif_item(), and side_data_exif_parse().

av_exif_write()

int av_exif_write ( void *  logctx,
const AVExifMetadataifd,
AVBufferRef **  buffer,
enum AVExifHeaderMode  header_mode 
)

Allocates a buffer using av_malloc of an appropriate size and writes the EXIF data represented by ifd into that buffer.

Upon error, *buffer will be NULL. The buffer becomes owned by the caller upon success. The *buffer argument must be NULL before calling.

Definition at line 706 of file exif.c.

Referenced by exif_attach_ifd(), ff_exif_get_buffer(), libjxl_preprocess_stream(), mov_parse_exif_item(), and side_data_exif_parse().

av_exif_free()

void av_exif_free ( AVExifMetadataifd )

Frees all resources associated with the given EXIF metadata struct.

Does not free the pointer passed itself, in case it is stack-allocated. The pointer passed to this function must be freed by the caller, if it is heap-allocated. Passing NULL is permitted.

Definition at line 612 of file exif.c.

Referenced by av_exif_clone_ifd(), av_exif_parse_buffer(), avi_extract_stream_metadata(), avpriv_exif_decode_ifd(), decode_frame(), exif_attach_ifd(), exif_clone_entry(), exif_decode_tag(), exif_free_entry(), ff_decode_exif_attach_buffer(), ff_exif_get_buffer(), ff_exif_sanitize_ifd(), ff_mjpeg_decode_end(), ff_mjpeg_decode_frame_from_buf(), libjxl_attach_sidedata(), libjxl_preprocess_stream(), mov_parse_exif_item(), side_data_exif_parse(), and tiff_end().

av_exif_ifd_to_dict()

int av_exif_ifd_to_dict ( void *  logctx,
const AVExifMetadataifd,
AVDictionary **  metadata 
)

Recursively reads all tags from the IFD and stores them in the provided metadata dictionary.

Definition at line 917 of file exif.c.

Referenced by avi_extract_stream_metadata(), avpriv_exif_decode_ifd(), exif_attach_ifd(), and side_data_exif_parse().

av_exif_clone_ifd()

AVExifMetadata* av_exif_clone_ifd ( const AVExifMetadataifd )

Allocates a duplicate of the provided EXIF metadata struct.

The caller owns the duplicate and must free it with av_exif_free. Returns NULL if the duplication process failed.

Definition at line 1148 of file exif.c.

Referenced by exif_attach_ifd(), and exif_clone_entry().

av_exif_matrix_to_orientation()

int av_exif_matrix_to_orientation ( const int32_tmatrix )

Convert a display matrix used by AV_FRAME_DATA_DISPLAYMATRIX into an orientation constant used by EXIF's orientation tag.

Returns an EXIF orientation between 1 and 8 (inclusive) depending on the rotation and flip factors. Returns 0 if the matrix is singular.

Definition at line 1184 of file exif.c.

Referenced by encode_frame(), ff_exif_sanitize_ifd(), and libjxl_preprocess_stream().

av_exif_orientation_to_matrix()

int av_exif_orientation_to_matrix ( int32_tmatrix,
int  orientation 
)

Convert an orientation constant used by EXIF's orientation tag into a display matrix used by AV_FRAME_DATA_DISPLAYMATRIX.

Returns 0 on success and negative if the orientation is invalid, i.e. not between 1 and 8 (inclusive).

Definition at line 1197 of file exif.c.

Referenced by attach_displaymatrix(), libjxl_preprocess_stream(), and side_data_exif_parse().


Generated on Tue Nov 18 2025 19:23:53 for FFmpeg by   doxygen 1.8.17

AltStyle によって変換されたページ (->オリジナル) /