[FFmpeg-devel] [PATCH] avformat/mov: don't use an allocated array for sample_size with HEIF images (PR #20258)
James Almer
code at ffmpeg.org
Sat Aug 16 20:47:47 EEST 2025
PR #20258 opened by James Almer (jamrial)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20258
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20258.patch
The array is only ever needed for streams where each sample entry may have a different value. Given that for non animated HEIF there's a single value that applies to the image, use the field defined for that.
From 0e8ac57af0b937f1beee14e348680893faedb665 Mon Sep 17 00:00:00 2001
From: James Almer <jamrial at gmail.com>
Date: Sat, 16 Aug 2025 14:16:38 -0300
Subject: [PATCH] avformat/mov: don't use an allocated array for sample_size
with HEIF images
The array is only ever needed for streams where each sample entry may have a
different value. Given for non animated HEIF there's a single value that
applies to the image, use the field defined for that.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavformat/mov.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 86037c6712..a44b268ff1 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5456,9 +5456,6 @@ static int heif_add_stream(MOVContext *c, HEIFItem *item)
if (!sc->chunk_offsets)
goto fail;
sc->chunk_count = 1;
- sc->sample_sizes = av_malloc_array(1, sizeof(*sc->sample_sizes));
- if (!sc->sample_sizes)
- goto fail;
sc->sample_count = 1;
sc->stts_data = av_malloc_array(1, sizeof(*sc->stts_data));
if (!sc->stts_data)
@@ -10471,11 +10468,12 @@ static int mov_parse_heif_items(AVFormatContext *s)
st->codecpar->width = item->width;
st->codecpar->height = item->height;
+ sc->sample_size = sc->stsz_sample_size = item->extent_length;
+
err = sanity_checks(s, sc, item->item_id);
- if (err || !sc->sample_count)
+ if (err)
return AVERROR_INVALIDDATA;
- sc->sample_sizes[0] = item->extent_length;
sc->chunk_offsets[0] = item->extent_offset + offset;
if (item->item_id == mov->primary_item_id)
--
2.49.1
More information about the ffmpeg-devel
mailing list