Revert "avformat/mov: ignore item boxes for animated heif"

This reverts commit f6b7b473d4.
The image in the item boxes and the animation in the trak box are not
necessarely the same, so both should be exported.

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2024-03-28 21:33:25 -03:00
parent f8fbec8686
commit e37b233ee2
1 changed files with 4 additions and 40 deletions

View File

@ -83,7 +83,6 @@ typedef struct MOVParseTableEntry {
static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom);
static int mov_read_mfra(MOVContext *c, AVIOContext *f);
static void mov_free_stream_context(AVFormatContext *s, AVStream *st);
static int64_t add_ctts_entry(MOVCtts** ctts_data, unsigned int* ctts_count, unsigned int* allocated_size,
int count, int duration);
@ -4860,25 +4859,6 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
MOVStreamContext *sc;
int ret;
if (c->found_iinf) {
// * For animated heif, if the iinf box showed up before the moov
// box, we need to clear all the streams read in the former.
for (int i = c->nb_heif_item - 1; i >= 0; i--) {
HEIFItem *item = &c->heif_item[i];
av_freep(&item->name);
if (!item->st)
continue;
mov_free_stream_context(c->fc, item->st);
ff_remove_stream(c->fc, item->st);
}
av_freep(&c->heif_item);
c->nb_heif_item = 0;
c->found_iinf = c->found_iloc = 0;
}
st = avformat_new_stream(c->fc, NULL);
if (!st) return AVERROR(ENOMEM);
st->id = -1;
@ -8065,9 +8045,8 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int64_t base_offset, extent_offset, extent_length;
uint8_t value;
if (c->found_moov) {
// * For animated heif, we don't care about the iloc box as all the
// necessary information can be found in the moov box.
if (c->found_iloc) {
av_log(c->fc, AV_LOG_INFO, "Duplicate iloc box found\n");
return 0;
}
@ -8198,11 +8177,6 @@ static int mov_read_iinf(MOVContext *c, AVIOContext *pb, MOVAtom atom)
av_log(c->fc, AV_LOG_WARNING, "Duplicate iinf box found\n");
return 0;
}
if (c->found_moov) {
// * For animated heif, we don't care about the iinf box as all the
// necessary information can be found in the moov box.
return 0;
}
version = avio_r8(pb);
avio_rb24(pb); // flags.
@ -8356,12 +8330,6 @@ static int mov_read_ispe(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
uint32_t width, height;
if (c->found_moov) {
// * For animated heif, we don't care about the ispe box as all the
// necessary information can be found in the moov box.
return 0;
}
avio_r8(pb); /* version */
avio_rb24(pb); /* flags */
width = avio_rb32(pb);
@ -8396,12 +8364,6 @@ static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int version, flags;
int ret;
if (c->found_moov) {
// * For animated heif, we don't care about the iprp box as all the
// necessary information can be found in the moov box.
return 0;
}
a.size = avio_rb32(pb);
a.type = avio_rl32(pb);
@ -8485,6 +8447,7 @@ static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
ret = 0;
fail:
c->cur_item_id = -1;
for (int i = 0; i < nb_atoms; i++)
av_free(atoms[i].data);
av_free(atoms);
@ -9508,6 +9471,7 @@ static int mov_read_header(AVFormatContext *s)
mov->trak_index = -1;
mov->thmb_item_id = -1;
mov->primary_item_id = -1;
mov->cur_item_id = -1;
/* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */
if (pb->seekable & AVIO_SEEKABLE_NORMAL)
atom.size = avio_size(pb);