[FFmpeg-devel] [PATCH 1/2] avformat/mov: Rework the AVIF parser to handle multiple items

James Zern jzern at google.com
Tue Jul 12 01:25:05 EEST 2022


On Thu, Jun 30, 2022 at 2:04 PM Vignesh Venkatasubramanian
<vigneshv-at-google.com at ffmpeg.org> wrote:
>
> Stores the item ids of all the items found in the file and
> processes the primary item at the end of the meta box. This patch
> does not change any behavior. It sets up the code for parsing
> alpha channel (and possibly images with 'grid') in follow up
> patches.
>
> Signed-off-by: Vignesh Venkatasubramanian <vigneshv at google.com>
> ---
>  libavformat/isom.h |   4 ++
>  libavformat/mov.c  | 148 ++++++++++++++++++++++++++++-----------------
>  2 files changed, 97 insertions(+), 55 deletions(-)
>
> [...]

@@ -4692,9 +4755,25 @@ static int mov_read_meta(MOVContext *c,
AVIOContext *pb, MOVAtom atom)
         tag = avio_rl32(pb);
         atom.size -= 4;
         if (tag == MKTAG('h','d','l','r')) {
+            int ret;
             avio_seek(pb, -8, SEEK_CUR);
             atom.size += 8;
-            return mov_read_default(c, pb, atom);
+            ret = mov_read_default(c, pb, atom);
+            if (ret < 0)

In some other cases these two lines are combined, if ((ret = ...

+                return ret;
+            if (c->is_still_picture_avif) {
+                int ret;
+                // Add a stream for the YUV planes (primary item).
+                ret = avif_add_stream(c, c->primary_item_id);
+                if (ret)

This could be updated too and use '< 0' to match other code.

+                    return ret;
+                // For still AVIF images, the meta box contains all the
+                // necessary information that would generally be
provided by the
+                // moov box. So simply mark that we have found the moov box so
+                // that parsing can continue.
+                c->found_moov = 1;
+            }
+            return ret;
         }


More information about the ffmpeg-devel mailing list