From: Vignesh Venkatasubramanian <vigneshv-at-google.com@ffmpeg.org> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH] avformat/mov: Only read the primary item for AVIF Date: Tue, 31 May 2022 12:11:39 -0700 Message-ID: <CAOJaEPLPZi0sb1=zZNxtax-5ywuuWW5WYYzD_6VFX0pK04t1sg@mail.gmail.com> (raw) In-Reply-To: <CAOJaEPJhP8-+Ou8cmHtRjR5KeEbkp42HcRyOpV3kbb3gixJxMw@mail.gmail.com> On Thu, May 19, 2022 at 9:13 AM Vignesh Venkatasubramanian <vigneshv@google.com> wrote: > > On Mon, May 16, 2022 at 9:59 AM Vignesh Venkatasubramanian > <vigneshv@google.com> 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 <vigneshv@google.com> > > --- > > 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 d7be593a86..9310a393fe 100644 > > --- a/libavformat/mov.c > > +++ b/libavformat/mov.c > > @@ -7445,6 +7445,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; > > @@ -7501,34 +7508,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; > > @@ -7536,7 +7534,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. > > @@ -7552,8 +7550,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; > > + } > > } > > } > > > > @@ -7670,6 +7670,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.550.gb090851708-goog > > > > Any comments on this one? If not, can this be merged please? > Another ping on this please? > -- > 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".
next prev parent reply other threads:[~2022-05-31 19:12 UTC|newest] Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-24 18:35 Vignesh Venkatasubramanian 2022-05-02 21:39 ` Vignesh Venkatasubramanian 2022-05-09 16:32 ` Vignesh Venkatasubramanian 2022-05-16 16:59 ` Vignesh Venkatasubramanian 2022-05-19 16:13 ` Vignesh Venkatasubramanian 2022-05-31 19:11 ` Vignesh Venkatasubramanian [this message] 2022-06-01 17:30 ` James Zern 2022-06-01 20:38 ` Vignesh Venkatasubramanian 2022-06-02 20:34 ` James Zern 2022-06-08 17:21 ` Vignesh Venkatasubramanian 2022-06-09 7:50 ` Gyan Doshi 2022-06-10 17:30 ` Vignesh Venkatasubramanian 2022-06-10 17:33 ` Andreas Rheinhardt 2022-06-10 17:37 ` Vignesh Venkatasubramanian 2022-06-10 17:34 ` Vignesh Venkatasubramanian 2022-06-13 16:32 ` Vignesh Venkatasubramanian 2022-06-21 17:12 ` Vignesh Venkatasubramanian 2022-06-27 16:44 ` Vignesh Venkatasubramanian 2022-06-28 18:21 ` James Zern 2022-06-28 18:56 ` Vignesh Venkatasubramanian 2022-06-28 19:02 ` James Zern 2022-06-29 19:20 ` James Zern 2022-06-28 18:58 ` Vignesh Venkatasubramanian
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to='CAOJaEPLPZi0sb1=zZNxtax-5ywuuWW5WYYzD_6VFX0pK04t1sg@mail.gmail.com' \ --to=vigneshv-at-google.com@ffmpeg.org \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git