mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-17 20:17:55 +02:00
avcodec/exif: remove GetByteContext usage from avpriv_exif_decode_ifd()
This prevents potential ABI issues with GetByteContext. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
6bd665b7c5
commit
ae100046ca
@ -92,7 +92,7 @@ static int exif_decode_tag(void *logctx, GetByteContext *gbytes, int le,
|
|||||||
// store metadata or proceed with next IFD
|
// store metadata or proceed with next IFD
|
||||||
ret = ff_tis_ifd(id);
|
ret = ff_tis_ifd(id);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ret = avpriv_exif_decode_ifd(logctx, gbytes, le, depth + 1, metadata);
|
ret = ff_exif_decode_ifd(logctx, gbytes, le, depth + 1, metadata);
|
||||||
} else {
|
} else {
|
||||||
const char *name = exif_get_tag_name(id);
|
const char *name = exif_get_tag_name(id);
|
||||||
char *use_name = (char*) name;
|
char *use_name = (char*) name;
|
||||||
@ -119,8 +119,8 @@ static int exif_decode_tag(void *logctx, GetByteContext *gbytes, int le,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int avpriv_exif_decode_ifd(void *logctx, GetByteContext *gbytes, int le,
|
int ff_exif_decode_ifd(void *logctx, GetByteContext *gbytes,
|
||||||
int depth, AVDictionary **metadata)
|
int le, int depth, AVDictionary **metadata)
|
||||||
{
|
{
|
||||||
int i, ret;
|
int i, ret;
|
||||||
int entries;
|
int entries;
|
||||||
@ -140,3 +140,13 @@ int avpriv_exif_decode_ifd(void *logctx, GetByteContext *gbytes, int le,
|
|||||||
// return next IDF offset or 0x000000000 or a value < 0 for failure
|
// return next IDF offset or 0x000000000 or a value < 0 for failure
|
||||||
return ff_tget_long(gbytes, le);
|
return ff_tget_long(gbytes, le);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int avpriv_exif_decode_ifd(void *logctx, const uint8_t *buf, int size,
|
||||||
|
int le, int depth, AVDictionary **metadata)
|
||||||
|
{
|
||||||
|
GetByteContext gb;
|
||||||
|
|
||||||
|
bytestream2_init(&gb, buf, size);
|
||||||
|
|
||||||
|
return ff_exif_decode_ifd(logctx, &gb, le, depth, metadata);
|
||||||
|
}
|
||||||
|
@ -164,7 +164,10 @@ static const struct exif_tag tag_list[] = { // JEITA CP-3451 EXIF specification:
|
|||||||
|
|
||||||
/** Recursively decodes all IFD's and
|
/** Recursively decodes all IFD's and
|
||||||
* adds included TAGS into the metadata dictionary. */
|
* adds included TAGS into the metadata dictionary. */
|
||||||
int avpriv_exif_decode_ifd(void *logctx, GetByteContext *gbytes, int le,
|
int avpriv_exif_decode_ifd(void *logctx, const uint8_t *buf, int size,
|
||||||
|
int le, int depth, AVDictionary **metadata);
|
||||||
|
|
||||||
|
int ff_exif_decode_ifd(void *logctx, GetByteContext *gbytes, int le,
|
||||||
int depth, AVDictionary **metadata);
|
int depth, AVDictionary **metadata);
|
||||||
|
|
||||||
#endif /* AVCODEC_EXIF_H */
|
#endif /* AVCODEC_EXIF_H */
|
||||||
|
@ -1867,7 +1867,7 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
|
|||||||
|
|
||||||
// read 0th IFD and store the metadata
|
// read 0th IFD and store the metadata
|
||||||
// (return values > 0 indicate the presence of subimage metadata)
|
// (return values > 0 indicate the presence of subimage metadata)
|
||||||
ret = avpriv_exif_decode_ifd(s->avctx, &gbytes, le, 0, &s->exif_metadata);
|
ret = ff_exif_decode_ifd(s->avctx, &gbytes, le, 0, &s->exif_metadata);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "mjpeg: error decoding EXIF data\n");
|
av_log(s->avctx, AV_LOG_ERROR, "mjpeg: error decoding EXIF data\n");
|
||||||
}
|
}
|
||||||
|
@ -1504,7 +1504,7 @@ static int webp_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bytestream2_seek(&exif_gb, ifd_offset, SEEK_SET);
|
bytestream2_seek(&exif_gb, ifd_offset, SEEK_SET);
|
||||||
if (avpriv_exif_decode_ifd(avctx, &exif_gb, le, 0, &exif_metadata) < 0) {
|
if (ff_exif_decode_ifd(avctx, &exif_gb, le, 0, &exif_metadata) < 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "error decoding Exif data\n");
|
av_log(avctx, AV_LOG_ERROR, "error decoding Exif data\n");
|
||||||
goto exif_end;
|
goto exif_end;
|
||||||
}
|
}
|
||||||
|
@ -401,10 +401,10 @@ static int avi_extract_stream_metadata(AVFormatContext *s, AVStream *st)
|
|||||||
// skip 4 byte padding
|
// skip 4 byte padding
|
||||||
bytestream2_skip(&gb, 4);
|
bytestream2_skip(&gb, 4);
|
||||||
offset = bytestream2_tell(&gb);
|
offset = bytestream2_tell(&gb);
|
||||||
bytestream2_init(&gb, data + offset, data_size - offset);
|
|
||||||
|
|
||||||
// decode EXIF tags from IFD, AVI is always little-endian
|
// decode EXIF tags from IFD, AVI is always little-endian
|
||||||
return avpriv_exif_decode_ifd(s, &gb, 1, 0, &st->metadata);
|
return avpriv_exif_decode_ifd(s, data + offset, data_size - offset,
|
||||||
|
1, 0, &st->metadata);
|
||||||
break;
|
break;
|
||||||
case MKTAG('C', 'A', 'S', 'I'):
|
case MKTAG('C', 'A', 'S', 'I'):
|
||||||
avpriv_request_sample(s, "RIFF stream data tag type CASI (%u)", tag);
|
avpriv_request_sample(s, "RIFF stream data tag type CASI (%u)", tag);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user