ffmpeg | branch: release/7.1 | James Almer <jamr...@gmail.com> | Mon Sep 30 13:43:23 2024 -0300| [779b0fe015b166f83a607e4126d1c55810c46855] | committer: James Almer
avformat/mov: factorize getting the current item Signed-off-by: James Almer <jamr...@gmail.com> (cherry picked from commit 58c265d956f4ce2efb0004c398e2c1f030f9398a) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=779b0fe015b166f83a607e4126d1c55810c46855 --- libavformat/mov.c | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 5b0b23ffc1..75951d6b4c 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -188,6 +188,24 @@ static int mov_read_mac_string(MOVContext *c, AVIOContext *pb, int len, return p - dst; } +/** + * Get the current item in the parsing process. + */ +static HEIFItem *heif_cur_item(MOVContext *c) +{ + HEIFItem *item = NULL; + + for (int i = 0; i < c->nb_heif_item; i++) { + if (c->heif_item[i].item_id != c->cur_item_id) + continue; + + item = &c->heif_item[i]; + break; + } + + return item; +} + /** * Get the current stream in the parsing process. This can either be the * latest stream added to the context, or the stream referenced by an item. @@ -195,23 +213,17 @@ static int mov_read_mac_string(MOVContext *c, AVIOContext *pb, int len, static AVStream *get_curr_st(MOVContext *c) { AVStream *st = NULL; + HEIFItem *item; if (c->fc->nb_streams < 1) return NULL; - for (int i = 0; i < c->nb_heif_item; i++) { - HEIFItem *item = &c->heif_item[i]; - - if (!item->st) - continue; - if (item->st->id != c->cur_item_id) - continue; + if (c->cur_item_id == -1) + return c->fc->streams[c->fc->nb_streams-1]; + item = heif_cur_item(c); + if (item) st = item->st; - break; - } - if (!st && c->cur_item_id == -1) - st = c->fc->streams[c->fc->nb_streams-1]; return st; } @@ -8912,6 +8924,7 @@ static int mov_read_iref(MOVContext *c, AVIOContext *pb, MOVAtom atom) static int mov_read_ispe(MOVContext *c, AVIOContext *pb, MOVAtom atom) { + HEIFItem *item; uint32_t width, height; avio_r8(pb); /* version */ @@ -8922,12 +8935,10 @@ static int mov_read_ispe(MOVContext *c, AVIOContext *pb, MOVAtom atom) av_log(c->fc, AV_LOG_TRACE, "ispe: item_id %d, width %u, height %u\n", c->cur_item_id, width, height); - for (int i = 0; i < c->nb_heif_item; i++) { - if (c->heif_item[i].item_id == c->cur_item_id) { - c->heif_item[i].width = width; - c->heif_item[i].height = height; - break; - } + item = heif_cur_item(c); + if (item) { + item->width = width; + item->height = height; } return 0; _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".