From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id F273F40C77 for ; Mon, 9 May 2022 16:33:04 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2AA1968B373; Mon, 9 May 2022 19:33:02 +0300 (EEST) Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7603A68B289 for ; Mon, 9 May 2022 19:32:55 +0300 (EEST) Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-2f7b815ac06so151016997b3.3 for ; Mon, 09 May 2022 09:32:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=9kzxJzwNGy8mQ1vbUkAO2oR4OvuIoMBk4p4O6B240Rw=; b=SMgTexSDjRPYgn5ZedQMxn9Pzg5YgGrrTvNjxMOf+2YUGgeNNsOHtjqX3bZZZ2VANA g0iEsoy6mZ2u1i3VIzBk/7mwWEyeLbkDI1Jbw8XQX3jtG8M8mElhd1G0XIEX+5gt1Qdf QZlZ+JBmcCojDXt1EsiTJ/wH+vtnNcRGNXby1tVzfyW9sWMd+McnIpyw8mjtkwVVSfRS WUjW06XEfyUJD88Y8ldnVkPVplPa54kanLrIe6NEmYebalwBEjtdZ+vXx8U23Gu9mQKW PoDbvdRw/NXgthtWMsvfquxn1X/CJOAYDUXtsvfOxRerRXGKgVPslDe6sMhxNGfhPPn3 yXNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=9kzxJzwNGy8mQ1vbUkAO2oR4OvuIoMBk4p4O6B240Rw=; b=rx9KfkF9fo+BEctHjc9A7MQIrpHrVv/xTvNdEuPQhwK5/5nN3OPvi4mWjn0u6KWNbk XQ1W1KYyQO1UmnKDD2M+4cicTZ455+/dCII53bdfVRgR8k/T1ljPVHb0/NOGukKSt+PK WaDV3dzyf5i1s3G7YybxyFxsb1dCPuYs0mzJGj9Ktt3qxpvBXXcsnKJX6HtIt8h5JUdu fcVEbD/Fb5T6m6sOn/aB1yHBxq/bb1JHFtsCUdsK6I+0u2yCuq8YWIFidTzUUoBbag3E 0opHZYE3LH0d2o/NNCHYPjn8oxz0rloMTpaf4vpHmcenCH/2s5QOn0rwrDRJ+iDiGxD2 ntMg== X-Gm-Message-State: AOAM533WtE+bbNjDn30Xyje5fYDKnXlkv4cVhE05FMZEKxGzsYDLtEld p8v+F+7Rh6T7XFPIaoPWbiWCEZ5RMYIZ2jc7SvlyDsgSKk0= X-Google-Smtp-Source: ABdhPJzptURHAs68dCSHNj9QYfDVh00aXKK+tgjUM+RCzJ1LBqaNYgaHoaDETplmWOpkdVPjLnixMYA0on7HevuMStw= X-Received: by 2002:a81:742:0:b0:2f8:d996:1085 with SMTP id 63-20020a810742000000b002f8d9961085mr15269459ywh.150.1652113973003; Mon, 09 May 2022 09:32:53 -0700 (PDT) MIME-Version: 1.0 References: <20220424183514.986374-1-vigneshv@google.com> In-Reply-To: From: Vignesh Venkatasubramanian Date: Mon, 9 May 2022 09:32:41 -0700 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH] avformat/mov: Only read the primary item for AVIF X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Mon, May 2, 2022 at 2:39 PM Vignesh Venkatasubramanian wrote: > > On Sun, Apr 24, 2022 at 11:35 AM Vignesh Venkatasubramanian > wrote: > > > > Update the still AVIF parser to only read the primary item. With this > > patch, AVIF still images with exif/icc/alpha channel will no longer > > fail to parse. > > > > For example, this patch enables parsing of files in: > > https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Microsoft > > > > Partially fixes trac ticket #7621 > > > > Signed-off-by: Vignesh Venkatasubramanian > > --- > > libavformat/isom.h | 1 + > > libavformat/mov.c | 41 +++++++++++++++++++++-------------------- > > 2 files changed, 22 insertions(+), 20 deletions(-) > > > > diff --git a/libavformat/isom.h b/libavformat/isom.h > > index cf36f04d5b..f05c2d9c28 100644 > > --- a/libavformat/isom.h > > +++ b/libavformat/isom.h > > @@ -317,6 +317,7 @@ typedef struct MOVContext { > > uint32_t mfra_size; > > uint32_t max_stts_delta; > > int is_still_picture_avif; > > + int primary_item_id; > > } MOVContext; > > > > int ff_mp4_read_descr_len(AVIOContext *pb); > > diff --git a/libavformat/mov.c b/libavformat/mov.c > > index 3e83e54a77..6be0f317ca 100644 > > --- a/libavformat/mov.c > > +++ b/libavformat/mov.c > > @@ -7449,6 +7449,13 @@ static int rb_size(AVIOContext *pb, uint64_t* value, int size) > > return size; > > } > > > > +static int mov_read_pitm(MOVContext *c, AVIOContext *pb, MOVAtom atom) > > +{ > > + avio_rb32(pb); // version & flags. > > + c->primary_item_id = avio_rb16(pb); > > + return atom.size; > > +} > > + > > static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) > > { > > int version, offset_size, length_size, base_offset_size, index_size; > > @@ -7505,34 +7512,25 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) > > return AVERROR_PATCHWELCOME; > > } > > item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb); > > - if (item_count > 1) { > > - // For still AVIF images, we only support one item. Second item will > > - // generally be found for AVIF images with alpha channel. We don't > > - // support them as of now. > > - av_log(c->fc, AV_LOG_ERROR, "iloc: item_count > 1 not supported.\n"); > > - return AVERROR_PATCHWELCOME; > > - } > > > > // Populate the necessary fields used by mov_build_index. > > - sc->stsc_count = item_count; > > - sc->stsc_data = av_malloc_array(item_count, sizeof(*sc->stsc_data)); > > + sc->stsc_count = 1; > > + sc->stsc_data = av_malloc_array(1, sizeof(*sc->stsc_data)); > > if (!sc->stsc_data) > > return AVERROR(ENOMEM); > > sc->stsc_data[0].first = 1; > > sc->stsc_data[0].count = 1; > > sc->stsc_data[0].id = 1; > > - sc->chunk_count = item_count; > > - sc->chunk_offsets = > > - av_malloc_array(item_count, sizeof(*sc->chunk_offsets)); > > + sc->chunk_count = 1; > > + sc->chunk_offsets = av_malloc_array(1, sizeof(*sc->chunk_offsets)); > > if (!sc->chunk_offsets) > > return AVERROR(ENOMEM); > > - sc->sample_count = item_count; > > - sc->sample_sizes = > > - av_malloc_array(item_count, sizeof(*sc->sample_sizes)); > > + sc->sample_count = 1; > > + sc->sample_sizes = av_malloc_array(1, sizeof(*sc->sample_sizes)); > > if (!sc->sample_sizes) > > return AVERROR(ENOMEM); > > - sc->stts_count = item_count; > > - sc->stts_data = av_malloc_array(item_count, sizeof(*sc->stts_data)); > > + sc->stts_count = 1; > > + sc->stts_data = av_malloc_array(1, sizeof(*sc->stts_data)); > > if (!sc->stts_data) > > return AVERROR(ENOMEM); > > sc->stts_data[0].count = 1; > > @@ -7540,7 +7538,7 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) > > sc->stts_data[0].duration = 0; > > > > for (int i = 0; i < item_count; i++) { > > - (version < 2) ? avio_rb16(pb) : avio_rb32(pb); // item_id; > > + int item_id = (version < 2) ? avio_rb16(pb) : avio_rb32(pb); > > if (version > 0) > > avio_rb16(pb); // construction_method. > > avio_rb16(pb); // data_reference_index. > > @@ -7556,8 +7554,10 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) > > if (rb_size(pb, &extent_offset, offset_size) < 0 || > > rb_size(pb, &extent_length, length_size) < 0) > > return AVERROR_INVALIDDATA; > > - sc->sample_sizes[0] = extent_length; > > - sc->chunk_offsets[0] = base_offset + extent_offset; > > + if (item_id == c->primary_item_id) { > > + sc->sample_sizes[0] = extent_length; > > + sc->chunk_offsets[0] = base_offset + extent_offset; > > + } > > } > > } > > > > @@ -7674,6 +7674,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { > > { MKTAG('S','A','3','D'), mov_read_SA3D }, /* ambisonic audio box */ > > { MKTAG('S','A','N','D'), mov_read_SAND }, /* non diegetic audio box */ > > { MKTAG('i','l','o','c'), mov_read_iloc }, > > +{ MKTAG('p','i','t','m'), mov_read_pitm }, > > { 0, NULL } > > }; > > > > -- > > 2.36.0.rc2.479.g8af0fa9b8e-goog > > > > Any comments on this one? If not, can this be merged please? :) > Another ping on this. > -- > Vignesh -- Vignesh _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".