avcodec/exif: make the get and remove helpers take a flags argument as input

This makes the functions extensible, as future behavior change flags can be
introduced.

This is strictly speaking not an API break. Only if a user was setting
recursive to anything other than 1 it would now behave differently, but given
these functions have been in the tree for only a few days, the chances for that
are practically zero.

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer
2025-08-23 19:52:06 -03:00
committed by Leo Izen
parent b3ea558492
commit 368b5e0ffc
4 changed files with 17 additions and 11 deletions

View File

@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2025-03-28
API changes, most recent first: API changes, most recent first:
2025-08-xx - xxxxxxxx - lavc 62.13.101 - exif.h
Add AV_EXIF_FLAG_RECURSIVE
2025-08-19 - ad77345a5d1..fe496b0308f - lavc 62.13.100 - exif.h 2025-08-19 - ad77345a5d1..fe496b0308f - lavc 62.13.100 - exif.h
Add: Add:
- enum AVTiffDataType, enum AVExifHeaderMode - enum AVTiffDataType, enum AVExifHeaderMode

View File

@@ -1038,9 +1038,9 @@ static int exif_get_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, int de
return 0; return 0;
} }
int av_exif_get_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, int recursive, AVExifEntry **value) int av_exif_get_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, int flags, AVExifEntry **value)
{ {
return exif_get_entry(logctx, ifd, id, recursive ? 0 : INT_MAX, value); return exif_get_entry(logctx, ifd, id, (flags & AV_EXIF_FLAG_RECURSIVE) ? 0 : INT_MAX, value);
} }
int av_exif_set_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, enum AVTiffDataType type, int av_exif_set_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, enum AVTiffDataType type,
@@ -1127,9 +1127,9 @@ static int exif_remove_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, int
return 1 + (ifd->count - index); return 1 + (ifd->count - index);
} }
int av_exif_remove_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, int recursive) int av_exif_remove_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, int flags)
{ {
return exif_remove_entry(logctx, ifd, id, recursive ? 0 : INT_MAX); return exif_remove_entry(logctx, ifd, id, (flags & AV_EXIF_FLAG_RECURSIVE) ? 0 : INT_MAX);
} }
AVExifMetadata *av_exif_clone_ifd(const AVExifMetadata *ifd) AVExifMetadata *av_exif_clone_ifd(const AVExifMetadata *ifd)

View File

@@ -144,26 +144,29 @@ int32_t av_exif_get_tag_id(const char *name);
int av_exif_set_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, enum AVTiffDataType type, 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); uint32_t count, const uint8_t *ifd_lead, uint32_t ifd_offset, const void *value);
/**
* Also check subdirectories.
*/
#define AV_EXIF_FLAG_RECURSIVE (1 << 0)
/** /**
* Get an entry with the tagged ID from the EXIF metadata struct. A pointer to the entry * Get an entry with the tagged ID from the EXIF metadata struct. A pointer to the entry
* will be written into *value. If the recursive flag is set to true, this function will check * will be written into *value.
* subdirectories as well.
* *
* If the entry was present and returned successfully, a positive number is returned. * 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 the entry was not found, *value is left untouched and zero is returned.
* If an error occurred, a negative number is returned. * If an error occurred, a negative number is returned.
*/ */
int av_exif_get_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, int recursive, AVExifEntry **value); int av_exif_get_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, int flags, AVExifEntry **value);
/** /**
* Remove an entry from the provided EXIF metadata struct. If the recursive flag is set * Remove an entry from the provided EXIF metadata struct.
* to true, then this function will check subdirectories as well.
* *
* If the entry was present and removed successfully, a positive number is returned. * If the entry was present and removed successfully, a positive number is returned.
* If the entry was not found, zero is returned. * If the entry was not found, zero is returned.
* If an error occurred, a negative number is returned. * If an error occurred, a negative number is returned.
*/ */
int av_exif_remove_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, int recursive); int av_exif_remove_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, int flags);
/** /**
* Decodes the EXIF data provided in the buffer and writes it into the * Decodes the EXIF data provided in the buffer and writes it into the

View File

@@ -30,7 +30,7 @@
#include "version_major.h" #include "version_major.h"
#define LIBAVCODEC_VERSION_MINOR 13 #define LIBAVCODEC_VERSION_MINOR 13
#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \ LIBAVCODEC_VERSION_MINOR, \