* [FFmpeg-devel] [PATCH] avformat/mov: Add support for demuxing still HEIC images @ 2023-09-26 17:37 Vignesh Venkatasubramanian via ffmpeg-devel 2023-10-03 22:56 ` Vignesh Venkat via ffmpeg-devel 2023-10-04 2:35 ` Leo Izen 0 siblings, 2 replies; 20+ messages in thread From: Vignesh Venkatasubramanian via ffmpeg-devel @ 2023-09-26 17:37 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Vignesh Venkatasubramanian They are similar to AVIF images (both use the HEIF container). The only additional work needed is to parse the hvcC box and put it in the extradata. With this patch applied, ffmpeg (when built with an HEVC decoder) is able to decode the files in https://github.com/nokiatech/heif/tree/gh-pages/content/images Partially fixes trac ticket #6521. Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavformat/isom.h | 2 ++ libavformat/mov.c | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index 3d375d7a46..b30b9da65e 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -327,6 +327,8 @@ typedef struct MOVContext { int64_t extent_offset; } *avif_info; int avif_info_size; + int64_t hvcC_offset; + int hvcC_size; int interleaved_read; } MOVContext; diff --git a/libavformat/mov.c b/libavformat/mov.c index 1996e0028c..cec9cb5fe1 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1218,7 +1218,8 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom) c->isom = 1; av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type); av_dict_set(&c->fc->metadata, "major_brand", type, 0); - c->is_still_picture_avif = !strncmp(type, "avif", 4); + c->is_still_picture_avif = !strncmp(type, "avif", 4) || + !strncmp(type, "mif1", 4); minor_ver = avio_rb32(pb); /* minor version */ av_dict_set_int(&c->fc->metadata, "minor_version", minor_ver, 0); @@ -4911,6 +4912,16 @@ static int avif_add_stream(MOVContext *c, int item_id) st->priv_data = sc; st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; st->codecpar->codec_id = AV_CODEC_ID_AV1; + if (c->hvcC_offset >= 0) { + int ret; + int64_t pos = avio_tell(c->fc->pb); + st->codecpar->codec_id = AV_CODEC_ID_HEVC; + avio_seek(c->fc->pb, c->hvcC_offset, SEEK_SET); + ret = ff_get_extradata(c->fc, st->codecpar, c->fc->pb, c->hvcC_size); + if (ret < 0) + return ret; + avio_seek(c->fc->pb, pos, SEEK_SET); + } sc->ffindex = st->index; c->trak_index = st->index; st->avg_frame_rate.num = st->avg_frame_rate.den = 1; @@ -4953,6 +4964,8 @@ static int avif_add_stream(MOVContext *c, int item_id) static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom) { + c->hvcC_offset = -1; + c->hvcC_size = 0; while (atom.size > 8) { uint32_t tag; if (avio_feof(pb)) @@ -7826,6 +7839,28 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) return atom.size; } +static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + int size = avio_rb32(pb); + if (avio_rl32(pb) != MKTAG('i','p','c','o')) + return AVERROR_INVALIDDATA; + size -= 8; + while (size > 0) { + int sub_size, sub_type; + sub_size = avio_rb32(pb); + sub_type = avio_rl32(pb); + sub_size -= 8; + size -= sub_size + 8; + if (sub_type == MKTAG('h','v','c','C')) { + c->hvcC_offset = avio_tell(pb); + c->hvcC_size = sub_size; + break; + } + avio_skip(pb, sub_size); + } + return atom.size; +} + static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('A','C','L','R'), mov_read_aclr }, { MKTAG('A','P','R','G'), mov_read_avid }, @@ -7933,6 +7968,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('p','c','m','C'), mov_read_pcmc }, /* PCM configuration box */ { MKTAG('p','i','t','m'), mov_read_pitm }, { MKTAG('e','v','c','C'), mov_read_glbl }, +{ MKTAG('i','p','r','p'), mov_read_iprp }, { 0, NULL } }; -- 2.42.0.515.g380fc7ccd1-goog _______________________________________________ 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mov: Add support for demuxing still HEIC images 2023-09-26 17:37 [FFmpeg-devel] [PATCH] avformat/mov: Add support for demuxing still HEIC images Vignesh Venkatasubramanian via ffmpeg-devel @ 2023-10-03 22:56 ` Vignesh Venkat via ffmpeg-devel 2023-10-04 0:29 ` Steven Liu 2023-10-04 2:35 ` Leo Izen 1 sibling, 1 reply; 20+ messages in thread From: Vignesh Venkat via ffmpeg-devel @ 2023-10-03 22:56 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Vignesh Venkat On Tue, Sep 26, 2023 at 10:37 AM Vignesh Venkatasubramanian <vigneshv@google.com> wrote: > > They are similar to AVIF images (both use the HEIF container). > The only additional work needed is to parse the hvcC box and put > it in the extradata. > > With this patch applied, ffmpeg (when built with an HEVC decoder) > is able to decode the files in > https://github.com/nokiatech/heif/tree/gh-pages/content/images > > Partially fixes trac ticket #6521. > > Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> > --- > libavformat/isom.h | 2 ++ > libavformat/mov.c | 38 +++++++++++++++++++++++++++++++++++++- > 2 files changed, 39 insertions(+), 1 deletion(-) > > diff --git a/libavformat/isom.h b/libavformat/isom.h > index 3d375d7a46..b30b9da65e 100644 > --- a/libavformat/isom.h > +++ b/libavformat/isom.h > @@ -327,6 +327,8 @@ typedef struct MOVContext { > int64_t extent_offset; > } *avif_info; > int avif_info_size; > + int64_t hvcC_offset; > + int hvcC_size; > int interleaved_read; > } MOVContext; > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 1996e0028c..cec9cb5fe1 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -1218,7 +1218,8 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom) > c->isom = 1; > av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type); > av_dict_set(&c->fc->metadata, "major_brand", type, 0); > - c->is_still_picture_avif = !strncmp(type, "avif", 4); > + c->is_still_picture_avif = !strncmp(type, "avif", 4) || > + !strncmp(type, "mif1", 4); > minor_ver = avio_rb32(pb); /* minor version */ > av_dict_set_int(&c->fc->metadata, "minor_version", minor_ver, 0); > > @@ -4911,6 +4912,16 @@ static int avif_add_stream(MOVContext *c, int item_id) > st->priv_data = sc; > st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; > st->codecpar->codec_id = AV_CODEC_ID_AV1; > + if (c->hvcC_offset >= 0) { > + int ret; > + int64_t pos = avio_tell(c->fc->pb); > + st->codecpar->codec_id = AV_CODEC_ID_HEVC; > + avio_seek(c->fc->pb, c->hvcC_offset, SEEK_SET); > + ret = ff_get_extradata(c->fc, st->codecpar, c->fc->pb, c->hvcC_size); > + if (ret < 0) > + return ret; > + avio_seek(c->fc->pb, pos, SEEK_SET); > + } > sc->ffindex = st->index; > c->trak_index = st->index; > st->avg_frame_rate.num = st->avg_frame_rate.den = 1; > @@ -4953,6 +4964,8 @@ static int avif_add_stream(MOVContext *c, int item_id) > > static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom) > { > + c->hvcC_offset = -1; > + c->hvcC_size = 0; > while (atom.size > 8) { > uint32_t tag; > if (avio_feof(pb)) > @@ -7826,6 +7839,28 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) > return atom.size; > } > > +static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) > +{ > + int size = avio_rb32(pb); > + if (avio_rl32(pb) != MKTAG('i','p','c','o')) > + return AVERROR_INVALIDDATA; > + size -= 8; > + while (size > 0) { > + int sub_size, sub_type; > + sub_size = avio_rb32(pb); > + sub_type = avio_rl32(pb); > + sub_size -= 8; > + size -= sub_size + 8; > + if (sub_type == MKTAG('h','v','c','C')) { > + c->hvcC_offset = avio_tell(pb); > + c->hvcC_size = sub_size; > + break; > + } > + avio_skip(pb, sub_size); > + } > + return atom.size; > +} > + > static const MOVParseTableEntry mov_default_parse_table[] = { > { MKTAG('A','C','L','R'), mov_read_aclr }, > { MKTAG('A','P','R','G'), mov_read_avid }, > @@ -7933,6 +7968,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { > { MKTAG('p','c','m','C'), mov_read_pcmc }, /* PCM configuration box */ > { MKTAG('p','i','t','m'), mov_read_pitm }, > { MKTAG('e','v','c','C'), mov_read_glbl }, > +{ MKTAG('i','p','r','p'), mov_read_iprp }, > { 0, NULL } > }; > > -- > 2.42.0.515.g380fc7ccd1-goog > Any comments/objections on merging this? -- 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mov: Add support for demuxing still HEIC images 2023-10-03 22:56 ` Vignesh Venkat via ffmpeg-devel @ 2023-10-04 0:29 ` Steven Liu 2023-10-04 1:31 ` Vittorio Giovara 2023-10-04 4:28 ` Vignesh Venkat via ffmpeg-devel 0 siblings, 2 replies; 20+ messages in thread From: Steven Liu @ 2023-10-04 0:29 UTC (permalink / raw) To: FFmpeg development discussions and patches Vignesh Venkat via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>于2023年10月4日 周三06:57写道: > On Tue, Sep 26, 2023 at 10:37 AM Vignesh Venkatasubramanian > <vigneshv@google.com> wrote: > > > > They are similar to AVIF images (both use the HEIF container). > > The only additional work needed is to parse the hvcC box and put > > it in the extradata. > > > > With this patch applied, ffmpeg (when built with an HEVC decoder) > > is able to decode the files in > > https://github.com/nokiatech/heif/tree/gh-pages/content/images > > > > Partially fixes trac ticket #6521. > > > > Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> > > --- > > libavformat/isom.h | 2 ++ > > libavformat/mov.c | 38 +++++++++++++++++++++++++++++++++++++- > > 2 files changed, 39 insertions(+), 1 deletion(-) > > > > diff --git a/libavformat/isom.h b/libavformat/isom.h > > index 3d375d7a46..b30b9da65e 100644 > > --- a/libavformat/isom.h > > +++ b/libavformat/isom.h > > @@ -327,6 +327,8 @@ typedef struct MOVContext { > > int64_t extent_offset; > > } *avif_info; > > int avif_info_size; > > + int64_t hvcC_offset; > > + int hvcC_size; > > int interleaved_read; > > } MOVContext; > > > > diff --git a/libavformat/mov.c b/libavformat/mov.c > > index 1996e0028c..cec9cb5fe1 100644 > > --- a/libavformat/mov.c > > +++ b/libavformat/mov.c > > @@ -1218,7 +1218,8 @@ static int mov_read_ftyp(MOVContext *c, > AVIOContext *pb, MOVAtom atom) > > c->isom = 1; > > av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: > %.4s\n",(char *)&type); > > av_dict_set(&c->fc->metadata, "major_brand", type, 0); > > - c->is_still_picture_avif = !strncmp(type, "avif", 4); > > + c->is_still_picture_avif = !strncmp(type, "avif", 4) || > > + !strncmp(type, "mif1", 4); > > minor_ver = avio_rb32(pb); /* minor version */ > > av_dict_set_int(&c->fc->metadata, "minor_version", minor_ver, 0); > > > > @@ -4911,6 +4912,16 @@ static int avif_add_stream(MOVContext *c, int > item_id) > > st->priv_data = sc; > > st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; > > st->codecpar->codec_id = AV_CODEC_ID_AV1; > > + if (c->hvcC_offset >= 0) { > > + int ret; > > + int64_t pos = avio_tell(c->fc->pb); > > + st->codecpar->codec_id = AV_CODEC_ID_HEVC; > > + avio_seek(c->fc->pb, c->hvcC_offset, SEEK_SET); > > + ret = ff_get_extradata(c->fc, st->codecpar, c->fc->pb, > c->hvcC_size); > > + if (ret < 0) > > + return ret; > > + avio_seek(c->fc->pb, pos, SEEK_SET); > > + } > > sc->ffindex = st->index; > > c->trak_index = st->index; > > st->avg_frame_rate.num = st->avg_frame_rate.den = 1; > > @@ -4953,6 +4964,8 @@ static int avif_add_stream(MOVContext *c, int > item_id) > > > > static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom) > > { > > + c->hvcC_offset = -1; > > + c->hvcC_size = 0; > > while (atom.size > 8) { > > uint32_t tag; > > if (avio_feof(pb)) > > @@ -7826,6 +7839,28 @@ static int mov_read_iloc(MOVContext *c, > AVIOContext *pb, MOVAtom atom) > > return atom.size; > > } > > > > +static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) > > +{ > > + int size = avio_rb32(pb); > > + if (avio_rl32(pb) != MKTAG('i','p','c','o')) > > + return AVERROR_INVALIDDATA; > > + size -= 8; > > + while (size > 0) { > > + int sub_size, sub_type; > > + sub_size = avio_rb32(pb); > > + sub_type = avio_rl32(pb); > > + sub_size -= 8; > > + size -= sub_size + 8; > > + if (sub_type == MKTAG('h','v','c','C')) { > > + c->hvcC_offset = avio_tell(pb); > > + c->hvcC_size = sub_size; > > + break; > > + } > > + avio_skip(pb, sub_size); > > + } > > + return atom.size; > > +} > > + > > static const MOVParseTableEntry mov_default_parse_table[] = { > > { MKTAG('A','C','L','R'), mov_read_aclr }, > > { MKTAG('A','P','R','G'), mov_read_avid }, > > @@ -7933,6 +7968,7 @@ static const MOVParseTableEntry > mov_default_parse_table[] = { > > { MKTAG('p','c','m','C'), mov_read_pcmc }, /* PCM configuration box */ > > { MKTAG('p','i','t','m'), mov_read_pitm }, > > { MKTAG('e','v','c','C'), mov_read_glbl }, > > +{ MKTAG('i','p','r','p'), mov_read_iprp }, > > { 0, NULL } > > }; > > > > -- > > 2.42.0.515.g380fc7ccd1-goog > > > > Any comments/objections on merging this? Can this patch support tiled hevc coded or sequence heif? > > > -- > 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". > _______________________________________________ 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mov: Add support for demuxing still HEIC images 2023-10-04 0:29 ` Steven Liu @ 2023-10-04 1:31 ` Vittorio Giovara 2023-10-04 4:01 ` Vignesh Venkat via ffmpeg-devel 2023-10-04 4:28 ` Vignesh Venkat via ffmpeg-devel 1 sibling, 1 reply; 20+ messages in thread From: Vittorio Giovara @ 2023-10-04 1:31 UTC (permalink / raw) To: FFmpeg development discussions and patches On Tue, Oct 3, 2023 at 8:30 PM Steven Liu <lingjiujianke@gmail.com> wrote: > > > 2.42.0.515.g380fc7ccd1-goog > > > > > > > Any comments/objections on merging this? > > > Can this patch support tiled hevc coded or sequence heif?= > I believe that will be possible only after AVStreamGroup is implemented. Vignesh is there a sample available? Could we add a test? -- Vittorio _______________________________________________ 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mov: Add support for demuxing still HEIC images 2023-10-04 1:31 ` Vittorio Giovara @ 2023-10-04 4:01 ` Vignesh Venkat via ffmpeg-devel 2023-10-04 4:40 ` Vittorio Giovara 0 siblings, 1 reply; 20+ messages in thread From: Vignesh Venkat via ffmpeg-devel @ 2023-10-04 4:01 UTC (permalink / raw) To: FFmpeg development discussions and patches; +Cc: Vignesh Venkat On Tue, Oct 3, 2023 at 6:32 PM Vittorio Giovara <vittorio.giovara@gmail.com> wrote: > > On Tue, Oct 3, 2023 at 8:30 PM Steven Liu <lingjiujianke@gmail.com> wrote: > > > > > 2.42.0.515.g380fc7ccd1-goog > > > > > > > > > > Any comments/objections on merging this? > > > > > > Can this patch support tiled hevc coded or sequence heif?= > > > > I believe that will be possible only after AVStreamGroup is implemented. > Yes, this patch only supports still HEIC images that don't have alpha and grids (tiles). Tiles and Alpha support will be possible only after AVStreamGroup is implemented. I will look into HEIC sequences in a follow-up. > Vignesh is there a sample available? Could we add a test? I tested it from the files in https://github.com/nokiatech/heif/tree/gh-pages/content/images. I am not sure about HEVC licensing and if we are allowed to copy some of those files in the ffmpeg fate server. Would generating a random image with ffmpeg and encoding it as HEIC be good enough? > -- > Vittorio > _______________________________________________ > 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". -- 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mov: Add support for demuxing still HEIC images 2023-10-04 4:01 ` Vignesh Venkat via ffmpeg-devel @ 2023-10-04 4:40 ` Vittorio Giovara 2023-10-04 16:36 ` Vignesh Venkat via ffmpeg-devel 0 siblings, 1 reply; 20+ messages in thread From: Vittorio Giovara @ 2023-10-04 4:40 UTC (permalink / raw) To: FFmpeg development discussions and patches; +Cc: Vignesh Venkat On Wed, Oct 4, 2023 at 12:02 AM Vignesh Venkat via ffmpeg-devel < ffmpeg-devel@ffmpeg.org> wrote: > On Tue, Oct 3, 2023 at 6:32 PM Vittorio Giovara > <vittorio.giovara@gmail.com> wrote: > > > > On Tue, Oct 3, 2023 at 8:30 PM Steven Liu <lingjiujianke@gmail.com> > wrote: > > > > > > > 2.42.0.515.g380fc7ccd1-goog > > > > > > > > > > > > > Any comments/objections on merging this? > > > > > > > > > Can this patch support tiled hevc coded or sequence heif?= > > > > > > > I believe that will be possible only after AVStreamGroup is implemented. > > > > Yes, this patch only supports still HEIC images that don't have alpha > and grids (tiles). > > Tiles and Alpha support will be possible only after AVStreamGroup is > implemented. I will look into HEIC sequences in a follow-up. > > > Vignesh is there a sample available? Could we add a test? > > I tested it from the files in > https://github.com/nokiatech/heif/tree/gh-pages/content/images. I am > not sure about HEVC licensing and if we are allowed to copy some of > those files in the ffmpeg fate server. Would generating a random image > with ffmpeg and encoding it as HEIC be good enough? > I would prefer a real world example and FATE has a bunch of conformance samples already. Adding the ones from https://github.com/nokiatech/heif_conformance shouldn't be a problem. Ideally the sample test should be added to this same patch. -- Vittorio _______________________________________________ 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mov: Add support for demuxing still HEIC images 2023-10-04 4:40 ` Vittorio Giovara @ 2023-10-04 16:36 ` Vignesh Venkat via ffmpeg-devel 2023-10-04 16:40 ` [FFmpeg-devel] [PATCH v3] " Vignesh Venkatasubramanian via ffmpeg-devel 2023-10-05 17:59 ` [FFmpeg-devel] [PATCH] " Andreas Rheinhardt 0 siblings, 2 replies; 20+ messages in thread From: Vignesh Venkat via ffmpeg-devel @ 2023-10-04 16:36 UTC (permalink / raw) To: Vittorio Giovara Cc: Vignesh Venkat, FFmpeg development discussions and patches [-- Attachment #1: Type: text/plain, Size: 1906 bytes --] On Tue, Oct 3, 2023 at 9:40 PM Vittorio Giovara <vittorio.giovara@gmail.com> wrote: > > > > On Wed, Oct 4, 2023 at 12:02 AM Vignesh Venkat via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> wrote: >> >> On Tue, Oct 3, 2023 at 6:32 PM Vittorio Giovara >> <vittorio.giovara@gmail.com> wrote: >> > >> > On Tue, Oct 3, 2023 at 8:30 PM Steven Liu <lingjiujianke@gmail.com> wrote: >> > >> > > > > 2.42.0.515.g380fc7ccd1-goog >> > > > > >> > > > >> > > > Any comments/objections on merging this? >> > > >> > > >> > > Can this patch support tiled hevc coded or sequence heif?= >> > > >> > >> > I believe that will be possible only after AVStreamGroup is implemented. >> > >> >> Yes, this patch only supports still HEIC images that don't have alpha >> and grids (tiles). >> >> Tiles and Alpha support will be possible only after AVStreamGroup is >> implemented. I will look into HEIC sequences in a follow-up. >> >> > Vignesh is there a sample available? Could we add a test? >> >> I tested it from the files in >> https://github.com/nokiatech/heif/tree/gh-pages/content/images. I am >> not sure about HEVC licensing and if we are allowed to copy some of >> those files in the ffmpeg fate server. Would generating a random image >> with ffmpeg and encoding it as HEIC be good enough? > > > I would prefer a real world example and FATE has a bunch of conformance samples already. > Adding the ones from https://github.com/nokiatech/heif_conformance shouldn't be a problem. > Ideally the sample test should be added to this same patch. Great, i have added two samples. Can you please upload C002.heic and C003.heic from the heif_conformance repository to the fate server under the "heif-conformance" sub-directory. I have also attached those two files in this email for reference. I will update the patch with the fate tests. > -- > Vittorio -- Vignesh [-- Attachment #2: C002.heic --] [-- Type: image/heif, Size: 111897 bytes --] [-- Attachment #3: C003.heic --] [-- Type: image/heif, Size: 224452 bytes --] [-- Attachment #4: Type: text/plain, Size: 251 bytes --] _______________________________________________ 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* [FFmpeg-devel] [PATCH v3] avformat/mov: Add support for demuxing still HEIC images 2023-10-04 16:36 ` Vignesh Venkat via ffmpeg-devel @ 2023-10-04 16:40 ` Vignesh Venkatasubramanian via ffmpeg-devel 2023-10-05 17:36 ` Vittorio Giovara 2024-01-09 12:39 ` James Almer 2023-10-05 17:59 ` [FFmpeg-devel] [PATCH] " Andreas Rheinhardt 1 sibling, 2 replies; 20+ messages in thread From: Vignesh Venkatasubramanian via ffmpeg-devel @ 2023-10-04 16:40 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Vignesh Venkatasubramanian They are similar to AVIF images (both use the HEIF container). The only additional work needed is to parse the hvcC box and put it in the extradata. With this patch applied, ffmpeg (when built with an HEVC decoder) is able to decode the files in https://github.com/nokiatech/heif/tree/gh-pages/content/images Also add a couple of fate tests with samples from https://github.com/nokiatech/heif_conformance/tree/master/conformance_files Partially fixes trac ticket #6521. Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavformat/isom.h | 2 + libavformat/mov.c | 41 ++++++++++++++++++- tests/fate/mov.mak | 6 +++ .../fate/mov-heic-demux-still-image-1-item | 11 +++++ .../mov-heic-demux-still-image-multiple-items | 11 +++++ 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 tests/ref/fate/mov-heic-demux-still-image-1-item create mode 100644 tests/ref/fate/mov-heic-demux-still-image-multiple-items diff --git a/libavformat/isom.h b/libavformat/isom.h index 3d375d7a46..b30b9da65e 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -327,6 +327,8 @@ typedef struct MOVContext { int64_t extent_offset; } *avif_info; int avif_info_size; + int64_t hvcC_offset; + int hvcC_size; int interleaved_read; } MOVContext; diff --git a/libavformat/mov.c b/libavformat/mov.c index 294c864fbd..d3747022bd 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1218,7 +1218,8 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom) c->isom = 1; av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type); av_dict_set(&c->fc->metadata, "major_brand", type, 0); - c->is_still_picture_avif = !strncmp(type, "avif", 4); + c->is_still_picture_avif = !strncmp(type, "avif", 4) || + !strncmp(type, "mif1", 4); minor_ver = avio_rb32(pb); /* minor version */ av_dict_set_int(&c->fc->metadata, "minor_version", minor_ver, 0); @@ -4911,6 +4912,19 @@ static int avif_add_stream(MOVContext *c, int item_id) st->priv_data = sc; st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; st->codecpar->codec_id = AV_CODEC_ID_AV1; + if (c->hvcC_offset >= 0) { + int ret; + int64_t pos = avio_tell(c->fc->pb); + st->codecpar->codec_id = AV_CODEC_ID_HEVC; + if (avio_seek(c->fc->pb, c->hvcC_offset, SEEK_SET) != c->hvcC_offset) { + av_log(c->fc, AV_LOG_ERROR, "Failed to seek to hvcC data.\n"); + return AVERROR_UNKNOWN; + } + ret = ff_get_extradata(c->fc, st->codecpar, c->fc->pb, c->hvcC_size); + if (ret < 0) + return ret; + avio_seek(c->fc->pb, pos, SEEK_SET); + } sc->ffindex = st->index; c->trak_index = st->index; st->avg_frame_rate.num = st->avg_frame_rate.den = 1; @@ -4953,6 +4967,8 @@ static int avif_add_stream(MOVContext *c, int item_id) static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom) { + c->hvcC_offset = -1; + c->hvcC_size = 0; while (atom.size > 8) { uint32_t tag; if (avio_feof(pb)) @@ -7827,6 +7843,28 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) return atom.size; } +static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + int size = avio_rb32(pb); + if (avio_rl32(pb) != MKTAG('i','p','c','o')) + return AVERROR_INVALIDDATA; + size -= 8; + while (size > 0) { + int sub_size, sub_type; + sub_size = avio_rb32(pb); + sub_type = avio_rl32(pb); + sub_size -= 8; + size -= sub_size + 8; + if (sub_type == MKTAG('h','v','c','C')) { + c->hvcC_offset = avio_tell(pb); + c->hvcC_size = sub_size; + break; + } + avio_skip(pb, sub_size); + } + return atom.size; +} + static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('A','C','L','R'), mov_read_aclr }, { MKTAG('A','P','R','G'), mov_read_avid }, @@ -7934,6 +7972,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('p','c','m','C'), mov_read_pcmc }, /* PCM configuration box */ { MKTAG('p','i','t','m'), mov_read_pitm }, { MKTAG('e','v','c','C'), mov_read_glbl }, +{ MKTAG('i','p','r','p'), mov_read_iprp }, { 0, NULL } }; diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index 6cb493ceab..a2d3cc8013 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -18,6 +18,8 @@ FATE_MOV = fate-mov-3elist \ fate-mov-neg-firstpts-discard-frames \ fate-mov-stream-shorter-than-movie \ fate-mov-pcm-remux \ + fate-mov-heic-demux-still-image-1-item \ + fate-mov-heic-demux-still-image-multiple-items \ # FIXME: Uncomment these two lines once the test files are uploaded to the fate # server. # fate-mov-avif-demux-still-image-1-item \ @@ -152,6 +154,10 @@ fate-mov-mp4-ttml-dfxp: CMD = transcode srt $(TARGET_SAMPLES)/sub/SubRip_capabil # parsed. #fate-mov-avif-demux-still-image-multiple-items: CMD = framemd5 -i $(TARGET_SAMPLES)/avif/still_image_exif.avif -c:v copy +fate-mov-heic-demux-still-image-1-item: CMD = framemd5 -i $(TARGET_SAMPLES)/heif-conformance/C002.heic -c:v copy + +fate-mov-heic-demux-still-image-multiple-items: CMD = framemd5 -i $(TARGET_SAMPLES)/heif-conformance/C003.heic -c:v copy + # Resulting remux should have: # 1. first audio stream with AV_DISPOSITION_HEARING_IMPAIRED # 2. second audio stream with AV_DISPOSITION_VISUAL_IMPAIRED | DESCRIPTIONS diff --git a/tests/ref/fate/mov-heic-demux-still-image-1-item b/tests/ref/fate/mov-heic-demux-still-image-1-item new file mode 100644 index 0000000000..c850c1ff9c --- /dev/null +++ b/tests/ref/fate/mov-heic-demux-still-image-1-item @@ -0,0 +1,11 @@ +#format: frame checksums +#version: 2 +#hash: MD5 +#extradata 0, 100, 5444bf01e03182c73ae957179d560f4d +#tb 0: 1/1 +#media_type 0: video +#codec_id 0: hevc +#dimensions 0: 1280x720 +#sar 0: 0/1 +#stream#, dts, pts, duration, size, hash +0, 0, 0, 1, 111554, 03ceabfab39afd2e2e796b9362111f32 diff --git a/tests/ref/fate/mov-heic-demux-still-image-multiple-items b/tests/ref/fate/mov-heic-demux-still-image-multiple-items new file mode 100644 index 0000000000..c850c1ff9c --- /dev/null +++ b/tests/ref/fate/mov-heic-demux-still-image-multiple-items @@ -0,0 +1,11 @@ +#format: frame checksums +#version: 2 +#hash: MD5 +#extradata 0, 100, 5444bf01e03182c73ae957179d560f4d +#tb 0: 1/1 +#media_type 0: video +#codec_id 0: hevc +#dimensions 0: 1280x720 +#sar 0: 0/1 +#stream#, dts, pts, duration, size, hash +0, 0, 0, 1, 111554, 03ceabfab39afd2e2e796b9362111f32 -- 2.42.0.582.g8ccd20d70d-goog _______________________________________________ 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3] avformat/mov: Add support for demuxing still HEIC images 2023-10-04 16:40 ` [FFmpeg-devel] [PATCH v3] " Vignesh Venkatasubramanian via ffmpeg-devel @ 2023-10-05 17:36 ` Vittorio Giovara 2023-10-05 22:40 ` Vignesh Venkat via ffmpeg-devel 2024-01-09 12:39 ` James Almer 1 sibling, 1 reply; 20+ messages in thread From: Vittorio Giovara @ 2023-10-05 17:36 UTC (permalink / raw) To: FFmpeg development discussions and patches; +Cc: Vignesh Venkatasubramanian On Wed, Oct 4, 2023 at 12:40 PM Vignesh Venkatasubramanian via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> wrote: > They are similar to AVIF images (both use the HEIF container). > The only additional work needed is to parse the hvcC box and put > it in the extradata. > > With this patch applied, ffmpeg (when built with an HEVC decoder) > is able to decode the files in > https://github.com/nokiatech/heif/tree/gh-pages/content/images > > Also add a couple of fate tests with samples from > https://github.com/nokiatech/heif_conformance/tree/master/conformance_files > > Partially fixes trac ticket #6521. > > Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> > --- > libavformat/isom.h | 2 + > libavformat/mov.c | 41 ++++++++++++++++++- > tests/fate/mov.mak | 6 +++ > .../fate/mov-heic-demux-still-image-1-item | 11 +++++ > .../mov-heic-demux-still-image-multiple-items | 11 +++++ > 5 files changed, 70 insertions(+), 1 deletion(-) > create mode 100644 tests/ref/fate/mov-heic-demux-still-image-1-item > create mode 100644 > tests/ref/fate/mov-heic-demux-still-image-multiple-items > > diff --git a/libavformat/isom.h b/libavformat/isom.h > index 3d375d7a46..b30b9da65e 100644 > --- a/libavformat/isom.h > +++ b/libavformat/isom.h > @@ -327,6 +327,8 @@ typedef struct MOVContext { > int64_t extent_offset; > } *avif_info; > int avif_info_size; > + int64_t hvcC_offset; > + int hvcC_size; > int interleaved_read; > } MOVContext; > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 294c864fbd..d3747022bd 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -1218,7 +1218,8 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext > *pb, MOVAtom atom) > c->isom = 1; > av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: > %.4s\n",(char *)&type); > av_dict_set(&c->fc->metadata, "major_brand", type, 0); > - c->is_still_picture_avif = !strncmp(type, "avif", 4); > + c->is_still_picture_avif = !strncmp(type, "avif", 4) || > + !strncmp(type, "mif1", 4); > minor_ver = avio_rb32(pb); /* minor version */ > av_dict_set_int(&c->fc->metadata, "minor_version", minor_ver, 0); > > @@ -4911,6 +4912,19 @@ static int avif_add_stream(MOVContext *c, int > item_id) > st->priv_data = sc; > st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; > st->codecpar->codec_id = AV_CODEC_ID_AV1; > + if (c->hvcC_offset >= 0) { > + int ret; > + int64_t pos = avio_tell(c->fc->pb); > + st->codecpar->codec_id = AV_CODEC_ID_HEVC; > + if (avio_seek(c->fc->pb, c->hvcC_offset, SEEK_SET) != > c->hvcC_offset) { > + av_log(c->fc, AV_LOG_ERROR, "Failed to seek to hvcC data.\n"); > + return AVERROR_UNKNOWN; > + } > + ret = ff_get_extradata(c->fc, st->codecpar, c->fc->pb, > c->hvcC_size); > + if (ret < 0) > + return ret; > + avio_seek(c->fc->pb, pos, SEEK_SET); > + } > sc->ffindex = st->index; > c->trak_index = st->index; > st->avg_frame_rate.num = st->avg_frame_rate.den = 1; > @@ -4953,6 +4967,8 @@ static int avif_add_stream(MOVContext *c, int > item_id) > > static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom) > { > + c->hvcC_offset = -1; > + c->hvcC_size = 0; > while (atom.size > 8) { > uint32_t tag; > if (avio_feof(pb)) > @@ -7827,6 +7843,28 @@ static int mov_read_iloc(MOVContext *c, AVIOContext > *pb, MOVAtom atom) > return atom.size; > } > > +static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) > +{ > + int size = avio_rb32(pb); > + if (avio_rl32(pb) != MKTAG('i','p','c','o')) > + return AVERROR_INVALIDDATA; > + size -= 8; > + while (size > 0) { > + int sub_size, sub_type; > + sub_size = avio_rb32(pb); > + sub_type = avio_rl32(pb); > + sub_size -= 8; > + size -= sub_size + 8; > + if (sub_type == MKTAG('h','v','c','C')) { > + c->hvcC_offset = avio_tell(pb); > + c->hvcC_size = sub_size; > + break; > + } > + avio_skip(pb, sub_size); > + } > + return atom.size; > +} > + > static const MOVParseTableEntry mov_default_parse_table[] = { > { MKTAG('A','C','L','R'), mov_read_aclr }, > { MKTAG('A','P','R','G'), mov_read_avid }, > @@ -7934,6 +7972,7 @@ static const MOVParseTableEntry > mov_default_parse_table[] = { > { MKTAG('p','c','m','C'), mov_read_pcmc }, /* PCM configuration box */ > { MKTAG('p','i','t','m'), mov_read_pitm }, > { MKTAG('e','v','c','C'), mov_read_glbl }, > +{ MKTAG('i','p','r','p'), mov_read_iprp }, > { 0, NULL } > }; > > diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak > index 6cb493ceab..a2d3cc8013 100644 > --- a/tests/fate/mov.mak > +++ b/tests/fate/mov.mak > @@ -18,6 +18,8 @@ FATE_MOV = fate-mov-3elist \ > fate-mov-neg-firstpts-discard-frames \ > fate-mov-stream-shorter-than-movie \ > fate-mov-pcm-remux \ > + fate-mov-heic-demux-still-image-1-item \ > + fate-mov-heic-demux-still-image-multiple-items \ > # FIXME: Uncomment these two lines once the test files are uploaded to > the fate > # server. > # fate-mov-avif-demux-still-image-1-item \ > @@ -152,6 +154,10 @@ fate-mov-mp4-ttml-dfxp: CMD = transcode srt > $(TARGET_SAMPLES)/sub/SubRip_capabil > # parsed. > #fate-mov-avif-demux-still-image-multiple-items: CMD = framemd5 -i > $(TARGET_SAMPLES)/avif/still_image_exif.avif -c:v copy > > +fate-mov-heic-demux-still-image-1-item: CMD = framemd5 -i > $(TARGET_SAMPLES)/heif-conformance/C002.heic -c:v copy > + > +fate-mov-heic-demux-still-image-multiple-items: CMD = framemd5 -i > $(TARGET_SAMPLES)/heif-conformance/C003.heic -c:v copy > + > # Resulting remux should have: > # 1. first audio stream with AV_DISPOSITION_HEARING_IMPAIRED > # 2. second audio stream with AV_DISPOSITION_VISUAL_IMPAIRED | > DESCRIPTIONS > diff --git a/tests/ref/fate/mov-heic-demux-still-image-1-item > b/tests/ref/fate/mov-heic-demux-still-image-1-item > new file mode 100644 > index 0000000000..c850c1ff9c > --- /dev/null > +++ b/tests/ref/fate/mov-heic-demux-still-image-1-item > @@ -0,0 +1,11 @@ > +#format: frame checksums > +#version: 2 > +#hash: MD5 > +#extradata 0, 100, > 5444bf01e03182c73ae957179d560f4d > +#tb 0: 1/1 > +#media_type 0: video > +#codec_id 0: hevc > +#dimensions 0: 1280x720 > +#sar 0: 0/1 > +#stream#, dts, pts, duration, size, hash > +0, 0, 0, 1, 111554, > 03ceabfab39afd2e2e796b9362111f32 > diff --git a/tests/ref/fate/mov-heic-demux-still-image-multiple-items > b/tests/ref/fate/mov-heic-demux-still-image-multiple-items > new file mode 100644 > index 0000000000..c850c1ff9c > --- /dev/null > +++ b/tests/ref/fate/mov-heic-demux-still-image-multiple-items > @@ -0,0 +1,11 @@ > +#format: frame checksums > +#version: 2 > +#hash: MD5 > +#extradata 0, 100, > 5444bf01e03182c73ae957179d560f4d > +#tb 0: 1/1 > +#media_type 0: video > +#codec_id 0: hevc > +#dimensions 0: 1280x720 > +#sar 0: 0/1 > +#stream#, dts, pts, duration, size, hash > +0, 0, 0, 1, 111554, > 03ceabfab39afd2e2e796b9362111f32 > -- patch lgtm. I dont have access to fate, can you send the samples to https://ffmpeg.org/fate.html#Uploading-new-samples-to-the-fate-suite? As soon as they are up, I'll merge this. Thanks -- Vittorio _______________________________________________ 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3] avformat/mov: Add support for demuxing still HEIC images 2023-10-05 17:36 ` Vittorio Giovara @ 2023-10-05 22:40 ` Vignesh Venkat via ffmpeg-devel 2023-10-09 18:52 ` Vignesh Venkat via ffmpeg-devel 0 siblings, 1 reply; 20+ messages in thread From: Vignesh Venkat via ffmpeg-devel @ 2023-10-05 22:40 UTC (permalink / raw) To: Vittorio Giovara Cc: Vignesh Venkat, FFmpeg development discussions and patches On Thu, Oct 5, 2023 at 10:36 AM Vittorio Giovara <vittorio.giovara@gmail.com> wrote: > > > On Wed, Oct 4, 2023 at 12:40 PM Vignesh Venkatasubramanian via > ffmpeg-devel <ffmpeg-devel@ffmpeg.org> wrote: > >> They are similar to AVIF images (both use the HEIF container). >> The only additional work needed is to parse the hvcC box and put >> it in the extradata. >> >> With this patch applied, ffmpeg (when built with an HEVC decoder) >> is able to decode the files in >> https://github.com/nokiatech/heif/tree/gh-pages/content/images >> >> Also add a couple of fate tests with samples from >> >> https://github.com/nokiatech/heif_conformance/tree/master/conformance_files >> >> Partially fixes trac ticket #6521. >> >> Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> >> --- >> libavformat/isom.h | 2 + >> libavformat/mov.c | 41 ++++++++++++++++++- >> tests/fate/mov.mak | 6 +++ >> .../fate/mov-heic-demux-still-image-1-item | 11 +++++ >> .../mov-heic-demux-still-image-multiple-items | 11 +++++ >> 5 files changed, 70 insertions(+), 1 deletion(-) >> create mode 100644 tests/ref/fate/mov-heic-demux-still-image-1-item >> create mode 100644 >> tests/ref/fate/mov-heic-demux-still-image-multiple-items >> >> diff --git a/libavformat/isom.h b/libavformat/isom.h >> index 3d375d7a46..b30b9da65e 100644 >> --- a/libavformat/isom.h >> +++ b/libavformat/isom.h >> @@ -327,6 +327,8 @@ typedef struct MOVContext { >> int64_t extent_offset; >> } *avif_info; >> int avif_info_size; >> + int64_t hvcC_offset; >> + int hvcC_size; >> int interleaved_read; >> } MOVContext; >> >> diff --git a/libavformat/mov.c b/libavformat/mov.c >> index 294c864fbd..d3747022bd 100644 >> --- a/libavformat/mov.c >> +++ b/libavformat/mov.c >> @@ -1218,7 +1218,8 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext >> *pb, MOVAtom atom) >> c->isom = 1; >> av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: >> %.4s\n",(char *)&type); >> av_dict_set(&c->fc->metadata, "major_brand", type, 0); >> - c->is_still_picture_avif = !strncmp(type, "avif", 4); >> + c->is_still_picture_avif = !strncmp(type, "avif", 4) || >> + !strncmp(type, "mif1", 4); >> minor_ver = avio_rb32(pb); /* minor version */ >> av_dict_set_int(&c->fc->metadata, "minor_version", minor_ver, 0); >> >> @@ -4911,6 +4912,19 @@ static int avif_add_stream(MOVContext *c, int >> item_id) >> st->priv_data = sc; >> st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; >> st->codecpar->codec_id = AV_CODEC_ID_AV1; >> + if (c->hvcC_offset >= 0) { >> + int ret; >> + int64_t pos = avio_tell(c->fc->pb); >> + st->codecpar->codec_id = AV_CODEC_ID_HEVC; >> + if (avio_seek(c->fc->pb, c->hvcC_offset, SEEK_SET) != >> c->hvcC_offset) { >> + av_log(c->fc, AV_LOG_ERROR, "Failed to seek to hvcC >> data.\n"); >> + return AVERROR_UNKNOWN; >> + } >> + ret = ff_get_extradata(c->fc, st->codecpar, c->fc->pb, >> c->hvcC_size); >> + if (ret < 0) >> + return ret; >> + avio_seek(c->fc->pb, pos, SEEK_SET); >> + } >> sc->ffindex = st->index; >> c->trak_index = st->index; >> st->avg_frame_rate.num = st->avg_frame_rate.den = 1; >> @@ -4953,6 +4967,8 @@ static int avif_add_stream(MOVContext *c, int >> item_id) >> >> static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom) >> { >> + c->hvcC_offset = -1; >> + c->hvcC_size = 0; >> while (atom.size > 8) { >> uint32_t tag; >> if (avio_feof(pb)) >> @@ -7827,6 +7843,28 @@ static int mov_read_iloc(MOVContext *c, >> AVIOContext *pb, MOVAtom atom) >> return atom.size; >> } >> >> +static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) >> +{ >> + int size = avio_rb32(pb); >> + if (avio_rl32(pb) != MKTAG('i','p','c','o')) >> + return AVERROR_INVALIDDATA; >> + size -= 8; >> + while (size > 0) { >> + int sub_size, sub_type; >> + sub_size = avio_rb32(pb); >> + sub_type = avio_rl32(pb); >> + sub_size -= 8; >> + size -= sub_size + 8; >> + if (sub_type == MKTAG('h','v','c','C')) { >> + c->hvcC_offset = avio_tell(pb); >> + c->hvcC_size = sub_size; >> + break; >> + } >> + avio_skip(pb, sub_size); >> + } >> + return atom.size; >> +} >> + >> static const MOVParseTableEntry mov_default_parse_table[] = { >> { MKTAG('A','C','L','R'), mov_read_aclr }, >> { MKTAG('A','P','R','G'), mov_read_avid }, >> @@ -7934,6 +7972,7 @@ static const MOVParseTableEntry >> mov_default_parse_table[] = { >> { MKTAG('p','c','m','C'), mov_read_pcmc }, /* PCM configuration box */ >> { MKTAG('p','i','t','m'), mov_read_pitm }, >> { MKTAG('e','v','c','C'), mov_read_glbl }, >> +{ MKTAG('i','p','r','p'), mov_read_iprp }, >> { 0, NULL } >> }; >> >> diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak >> index 6cb493ceab..a2d3cc8013 100644 >> --- a/tests/fate/mov.mak >> +++ b/tests/fate/mov.mak >> @@ -18,6 +18,8 @@ FATE_MOV = fate-mov-3elist \ >> fate-mov-neg-firstpts-discard-frames \ >> fate-mov-stream-shorter-than-movie \ >> fate-mov-pcm-remux \ >> + fate-mov-heic-demux-still-image-1-item \ >> + fate-mov-heic-demux-still-image-multiple-items \ >> # FIXME: Uncomment these two lines once the test files are uploaded to >> the fate >> # server. >> # fate-mov-avif-demux-still-image-1-item \ >> @@ -152,6 +154,10 @@ fate-mov-mp4-ttml-dfxp: CMD = transcode srt >> $(TARGET_SAMPLES)/sub/SubRip_capabil >> # parsed. >> #fate-mov-avif-demux-still-image-multiple-items: CMD = framemd5 -i >> $(TARGET_SAMPLES)/avif/still_image_exif.avif -c:v copy >> >> +fate-mov-heic-demux-still-image-1-item: CMD = framemd5 -i >> $(TARGET_SAMPLES)/heif-conformance/C002.heic -c:v copy >> + >> +fate-mov-heic-demux-still-image-multiple-items: CMD = framemd5 -i >> $(TARGET_SAMPLES)/heif-conformance/C003.heic -c:v copy >> + >> # Resulting remux should have: >> # 1. first audio stream with AV_DISPOSITION_HEARING_IMPAIRED >> # 2. second audio stream with AV_DISPOSITION_VISUAL_IMPAIRED | >> DESCRIPTIONS >> diff --git a/tests/ref/fate/mov-heic-demux-still-image-1-item >> b/tests/ref/fate/mov-heic-demux-still-image-1-item >> new file mode 100644 >> index 0000000000..c850c1ff9c >> --- /dev/null >> +++ b/tests/ref/fate/mov-heic-demux-still-image-1-item >> @@ -0,0 +1,11 @@ >> +#format: frame checksums >> +#version: 2 >> +#hash: MD5 >> +#extradata 0, 100, >> 5444bf01e03182c73ae957179d560f4d >> +#tb 0: 1/1 >> +#media_type 0: video >> +#codec_id 0: hevc >> +#dimensions 0: 1280x720 >> +#sar 0: 0/1 >> +#stream#, dts, pts, duration, size, hash >> +0, 0, 0, 1, 111554, >> 03ceabfab39afd2e2e796b9362111f32 >> diff --git a/tests/ref/fate/mov-heic-demux-still-image-multiple-items >> b/tests/ref/fate/mov-heic-demux-still-image-multiple-items >> new file mode 100644 >> index 0000000000..c850c1ff9c >> --- /dev/null >> +++ b/tests/ref/fate/mov-heic-demux-still-image-multiple-items >> @@ -0,0 +1,11 @@ >> +#format: frame checksums >> +#version: 2 >> +#hash: MD5 >> +#extradata 0, 100, >> 5444bf01e03182c73ae957179d560f4d >> +#tb 0: 1/1 >> +#media_type 0: video >> +#codec_id 0: hevc >> +#dimensions 0: 1280x720 >> +#sar 0: 0/1 >> +#stream#, dts, pts, duration, size, hash >> +0, 0, 0, 1, 111554, >> 03ceabfab39afd2e2e796b9362111f32 >> -- > > > patch lgtm. I dont have access to fate, can you send the samples to > https://ffmpeg.org/fate.html#Uploading-new-samples-to-the-fate-suite? > As soon as they are up, I'll merge this. > Thanks > Thank you. I have emailed the samples to samples-request@ffmpeg.org. I will ping this thread once they are uploaded. > -- > Vittorio > -- 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3] avformat/mov: Add support for demuxing still HEIC images 2023-10-05 22:40 ` Vignesh Venkat via ffmpeg-devel @ 2023-10-09 18:52 ` Vignesh Venkat via ffmpeg-devel 2023-10-27 16:52 ` Thilo Borgmann via ffmpeg-devel 0 siblings, 1 reply; 20+ messages in thread From: Vignesh Venkat via ffmpeg-devel @ 2023-10-09 18:52 UTC (permalink / raw) To: Vittorio Giovara Cc: Vignesh Venkat, FFmpeg development discussions and patches On Thu, Oct 5, 2023 at 3:40 PM Vignesh Venkat <vigneshv@google.com> wrote: > > > > On Thu, Oct 5, 2023 at 10:36 AM Vittorio Giovara <vittorio.giovara@gmail.com> wrote: >> >> >> >> On Wed, Oct 4, 2023 at 12:40 PM Vignesh Venkatasubramanian via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> wrote: >>> >>> They are similar to AVIF images (both use the HEIF container). >>> The only additional work needed is to parse the hvcC box and put >>> it in the extradata. >>> >>> With this patch applied, ffmpeg (when built with an HEVC decoder) >>> is able to decode the files in >>> https://github.com/nokiatech/heif/tree/gh-pages/content/images >>> >>> Also add a couple of fate tests with samples from >>> https://github.com/nokiatech/heif_conformance/tree/master/conformance_files >>> >>> Partially fixes trac ticket #6521. >>> >>> Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> >>> --- >>> libavformat/isom.h | 2 + >>> libavformat/mov.c | 41 ++++++++++++++++++- >>> tests/fate/mov.mak | 6 +++ >>> .../fate/mov-heic-demux-still-image-1-item | 11 +++++ >>> .../mov-heic-demux-still-image-multiple-items | 11 +++++ >>> 5 files changed, 70 insertions(+), 1 deletion(-) >>> create mode 100644 tests/ref/fate/mov-heic-demux-still-image-1-item >>> create mode 100644 tests/ref/fate/mov-heic-demux-still-image-multiple-items >>> >>> diff --git a/libavformat/isom.h b/libavformat/isom.h >>> index 3d375d7a46..b30b9da65e 100644 >>> --- a/libavformat/isom.h >>> +++ b/libavformat/isom.h >>> @@ -327,6 +327,8 @@ typedef struct MOVContext { >>> int64_t extent_offset; >>> } *avif_info; >>> int avif_info_size; >>> + int64_t hvcC_offset; >>> + int hvcC_size; >>> int interleaved_read; >>> } MOVContext; >>> >>> diff --git a/libavformat/mov.c b/libavformat/mov.c >>> index 294c864fbd..d3747022bd 100644 >>> --- a/libavformat/mov.c >>> +++ b/libavformat/mov.c >>> @@ -1218,7 +1218,8 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom) >>> c->isom = 1; >>> av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type); >>> av_dict_set(&c->fc->metadata, "major_brand", type, 0); >>> - c->is_still_picture_avif = !strncmp(type, "avif", 4); >>> + c->is_still_picture_avif = !strncmp(type, "avif", 4) || >>> + !strncmp(type, "mif1", 4); >>> minor_ver = avio_rb32(pb); /* minor version */ >>> av_dict_set_int(&c->fc->metadata, "minor_version", minor_ver, 0); >>> >>> @@ -4911,6 +4912,19 @@ static int avif_add_stream(MOVContext *c, int item_id) >>> st->priv_data = sc; >>> st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; >>> st->codecpar->codec_id = AV_CODEC_ID_AV1; >>> + if (c->hvcC_offset >= 0) { >>> + int ret; >>> + int64_t pos = avio_tell(c->fc->pb); >>> + st->codecpar->codec_id = AV_CODEC_ID_HEVC; >>> + if (avio_seek(c->fc->pb, c->hvcC_offset, SEEK_SET) != c->hvcC_offset) { >>> + av_log(c->fc, AV_LOG_ERROR, "Failed to seek to hvcC data.\n"); >>> + return AVERROR_UNKNOWN; >>> + } >>> + ret = ff_get_extradata(c->fc, st->codecpar, c->fc->pb, c->hvcC_size); >>> + if (ret < 0) >>> + return ret; >>> + avio_seek(c->fc->pb, pos, SEEK_SET); >>> + } >>> sc->ffindex = st->index; >>> c->trak_index = st->index; >>> st->avg_frame_rate.num = st->avg_frame_rate.den = 1; >>> @@ -4953,6 +4967,8 @@ static int avif_add_stream(MOVContext *c, int item_id) >>> >>> static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom) >>> { >>> + c->hvcC_offset = -1; >>> + c->hvcC_size = 0; >>> while (atom.size > 8) { >>> uint32_t tag; >>> if (avio_feof(pb)) >>> @@ -7827,6 +7843,28 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) >>> return atom.size; >>> } >>> >>> +static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) >>> +{ >>> + int size = avio_rb32(pb); >>> + if (avio_rl32(pb) != MKTAG('i','p','c','o')) >>> + return AVERROR_INVALIDDATA; >>> + size -= 8; >>> + while (size > 0) { >>> + int sub_size, sub_type; >>> + sub_size = avio_rb32(pb); >>> + sub_type = avio_rl32(pb); >>> + sub_size -= 8; >>> + size -= sub_size + 8; >>> + if (sub_type == MKTAG('h','v','c','C')) { >>> + c->hvcC_offset = avio_tell(pb); >>> + c->hvcC_size = sub_size; >>> + break; >>> + } >>> + avio_skip(pb, sub_size); >>> + } >>> + return atom.size; >>> +} >>> + >>> static const MOVParseTableEntry mov_default_parse_table[] = { >>> { MKTAG('A','C','L','R'), mov_read_aclr }, >>> { MKTAG('A','P','R','G'), mov_read_avid }, >>> @@ -7934,6 +7972,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { >>> { MKTAG('p','c','m','C'), mov_read_pcmc }, /* PCM configuration box */ >>> { MKTAG('p','i','t','m'), mov_read_pitm }, >>> { MKTAG('e','v','c','C'), mov_read_glbl }, >>> +{ MKTAG('i','p','r','p'), mov_read_iprp }, >>> { 0, NULL } >>> }; >>> >>> diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak >>> index 6cb493ceab..a2d3cc8013 100644 >>> --- a/tests/fate/mov.mak >>> +++ b/tests/fate/mov.mak >>> @@ -18,6 +18,8 @@ FATE_MOV = fate-mov-3elist \ >>> fate-mov-neg-firstpts-discard-frames \ >>> fate-mov-stream-shorter-than-movie \ >>> fate-mov-pcm-remux \ >>> + fate-mov-heic-demux-still-image-1-item \ >>> + fate-mov-heic-demux-still-image-multiple-items \ >>> # FIXME: Uncomment these two lines once the test files are uploaded to the fate >>> # server. >>> # fate-mov-avif-demux-still-image-1-item \ >>> @@ -152,6 +154,10 @@ fate-mov-mp4-ttml-dfxp: CMD = transcode srt $(TARGET_SAMPLES)/sub/SubRip_capabil >>> # parsed. >>> #fate-mov-avif-demux-still-image-multiple-items: CMD = framemd5 -i $(TARGET_SAMPLES)/avif/still_image_exif.avif -c:v copy >>> >>> +fate-mov-heic-demux-still-image-1-item: CMD = framemd5 -i $(TARGET_SAMPLES)/heif-conformance/C002.heic -c:v copy >>> + >>> +fate-mov-heic-demux-still-image-multiple-items: CMD = framemd5 -i $(TARGET_SAMPLES)/heif-conformance/C003.heic -c:v copy >>> + >>> # Resulting remux should have: >>> # 1. first audio stream with AV_DISPOSITION_HEARING_IMPAIRED >>> # 2. second audio stream with AV_DISPOSITION_VISUAL_IMPAIRED | DESCRIPTIONS >>> diff --git a/tests/ref/fate/mov-heic-demux-still-image-1-item b/tests/ref/fate/mov-heic-demux-still-image-1-item >>> new file mode 100644 >>> index 0000000000..c850c1ff9c >>> --- /dev/null >>> +++ b/tests/ref/fate/mov-heic-demux-still-image-1-item >>> @@ -0,0 +1,11 @@ >>> +#format: frame checksums >>> +#version: 2 >>> +#hash: MD5 >>> +#extradata 0, 100, 5444bf01e03182c73ae957179d560f4d >>> +#tb 0: 1/1 >>> +#media_type 0: video >>> +#codec_id 0: hevc >>> +#dimensions 0: 1280x720 >>> +#sar 0: 0/1 >>> +#stream#, dts, pts, duration, size, hash >>> +0, 0, 0, 1, 111554, 03ceabfab39afd2e2e796b9362111f32 >>> diff --git a/tests/ref/fate/mov-heic-demux-still-image-multiple-items b/tests/ref/fate/mov-heic-demux-still-image-multiple-items >>> new file mode 100644 >>> index 0000000000..c850c1ff9c >>> --- /dev/null >>> +++ b/tests/ref/fate/mov-heic-demux-still-image-multiple-items >>> @@ -0,0 +1,11 @@ >>> +#format: frame checksums >>> +#version: 2 >>> +#hash: MD5 >>> +#extradata 0, 100, 5444bf01e03182c73ae957179d560f4d >>> +#tb 0: 1/1 >>> +#media_type 0: video >>> +#codec_id 0: hevc >>> +#dimensions 0: 1280x720 >>> +#sar 0: 0/1 >>> +#stream#, dts, pts, duration, size, hash >>> +0, 0, 0, 1, 111554, 03ceabfab39afd2e2e796b9362111f32 >>> -- >> >> >> patch lgtm. I dont have access to fate, can you send the samples to https://ffmpeg.org/fate.html#Uploading-new-samples-to-the-fate-suite? >> As soon as they are up, I'll merge this. >> Thanks > > > Thank you. I have emailed the samples to samples-request@ffmpeg.org. I will ping this thread once they are uploaded. > Could somebody please help upload the sample files sent to samples-request@ffmpeg.org so that this patch can be merged? Thank you! >> >> -- >> Vittorio > > > > -- > 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3] avformat/mov: Add support for demuxing still HEIC images 2023-10-09 18:52 ` Vignesh Venkat via ffmpeg-devel @ 2023-10-27 16:52 ` Thilo Borgmann via ffmpeg-devel 0 siblings, 0 replies; 20+ messages in thread From: Thilo Borgmann via ffmpeg-devel @ 2023-10-27 16:52 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Thilo Borgmann >> Thank you. I have emailed the samples to samples-request@ffmpeg.org. I will ping this thread once they are uploaded. >> > > > Could somebody please help upload the sample files sent to > samples-request@ffmpeg.org so that this patch can be merged? Thank > you! Done, sorry for delay. Same for the avif samples. -Thilo _______________________________________________ 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3] avformat/mov: Add support for demuxing still HEIC images 2023-10-04 16:40 ` [FFmpeg-devel] [PATCH v3] " Vignesh Venkatasubramanian via ffmpeg-devel 2023-10-05 17:36 ` Vittorio Giovara @ 2024-01-09 12:39 ` James Almer 2024-01-10 21:05 ` Vignesh Venkat via ffmpeg-devel 1 sibling, 1 reply; 20+ messages in thread From: James Almer @ 2024-01-09 12:39 UTC (permalink / raw) To: ffmpeg-devel On 10/4/2023 1:40 PM, Vignesh Venkatasubramanian via ffmpeg-devel wrote: > They are similar to AVIF images (both use the HEIF container). > The only additional work needed is to parse the hvcC box and put > it in the extradata. > > With this patch applied, ffmpeg (when built with an HEVC decoder) > is able to decode the files in > https://github.com/nokiatech/heif/tree/gh-pages/content/images > > Also add a couple of fate tests with samples from > https://github.com/nokiatech/heif_conformance/tree/master/conformance_files > > Partially fixes trac ticket #6521. > > Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> > --- > libavformat/isom.h | 2 + > libavformat/mov.c | 41 ++++++++++++++++++- > tests/fate/mov.mak | 6 +++ > .../fate/mov-heic-demux-still-image-1-item | 11 +++++ > .../mov-heic-demux-still-image-multiple-items | 11 +++++ > 5 files changed, 70 insertions(+), 1 deletion(-) > create mode 100644 tests/ref/fate/mov-heic-demux-still-image-1-item > create mode 100644 tests/ref/fate/mov-heic-demux-still-image-multiple-items This seems to have been forgotten, so I'll apply it soon. _______________________________________________ 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3] avformat/mov: Add support for demuxing still HEIC images 2024-01-09 12:39 ` James Almer @ 2024-01-10 21:05 ` Vignesh Venkat via ffmpeg-devel 0 siblings, 0 replies; 20+ messages in thread From: Vignesh Venkat via ffmpeg-devel @ 2024-01-10 21:05 UTC (permalink / raw) To: FFmpeg development discussions and patches; +Cc: Vignesh Venkat On Tue, Jan 9, 2024 at 4:39 AM James Almer <jamrial@gmail.com> wrote: > > On 10/4/2023 1:40 PM, Vignesh Venkatasubramanian via ffmpeg-devel wrote: > > They are similar to AVIF images (both use the HEIF container). > > The only additional work needed is to parse the hvcC box and put > > it in the extradata. > > > > With this patch applied, ffmpeg (when built with an HEVC decoder) > > is able to decode the files in > > https://github.com/nokiatech/heif/tree/gh-pages/content/images > > > > Also add a couple of fate tests with samples from > > https://github.com/nokiatech/heif_conformance/tree/master/conformance_files > > > > Partially fixes trac ticket #6521. > > > > Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> > > --- > > libavformat/isom.h | 2 + > > libavformat/mov.c | 41 ++++++++++++++++++- > > tests/fate/mov.mak | 6 +++ > > .../fate/mov-heic-demux-still-image-1-item | 11 +++++ > > .../mov-heic-demux-still-image-multiple-items | 11 +++++ > > 5 files changed, 70 insertions(+), 1 deletion(-) > > create mode 100644 tests/ref/fate/mov-heic-demux-still-image-1-item > > create mode 100644 tests/ref/fate/mov-heic-demux-still-image-multiple-items > > This seems to have been forgotten, so I'll apply it soon. Sorry that was my bad. Thanks for applying. > _______________________________________________ > 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". -- 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mov: Add support for demuxing still HEIC images 2023-10-04 16:36 ` Vignesh Venkat via ffmpeg-devel 2023-10-04 16:40 ` [FFmpeg-devel] [PATCH v3] " Vignesh Venkatasubramanian via ffmpeg-devel @ 2023-10-05 17:59 ` Andreas Rheinhardt 2023-10-05 22:32 ` Vignesh Venkat via ffmpeg-devel 1 sibling, 1 reply; 20+ messages in thread From: Andreas Rheinhardt @ 2023-10-05 17:59 UTC (permalink / raw) To: ffmpeg-devel Vignesh Venkat via ffmpeg-devel: > On Tue, Oct 3, 2023 at 9:40 PM Vittorio Giovara > <vittorio.giovara@gmail.com> wrote: >> >> >> >> On Wed, Oct 4, 2023 at 12:02 AM Vignesh Venkat via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> wrote: >>> >>> On Tue, Oct 3, 2023 at 6:32 PM Vittorio Giovara >>> <vittorio.giovara@gmail.com> wrote: >>>> >>>> On Tue, Oct 3, 2023 at 8:30 PM Steven Liu <lingjiujianke@gmail.com> wrote: >>>> >>>>>>> 2.42.0.515.g380fc7ccd1-goog >>>>>>> >>>>>> >>>>>> Any comments/objections on merging this? >>>>> >>>>> >>>>> Can this patch support tiled hevc coded or sequence heif?= >>>>> >>>> >>>> I believe that will be possible only after AVStreamGroup is implemented. >>>> >>> >>> Yes, this patch only supports still HEIC images that don't have alpha >>> and grids (tiles). >>> >>> Tiles and Alpha support will be possible only after AVStreamGroup is >>> implemented. I will look into HEIC sequences in a follow-up. >>> >>>> Vignesh is there a sample available? Could we add a test? >>> >>> I tested it from the files in >>> https://github.com/nokiatech/heif/tree/gh-pages/content/images. I am >>> not sure about HEVC licensing and if we are allowed to copy some of >>> those files in the ffmpeg fate server. Would generating a random image >>> with ffmpeg and encoding it as HEIC be good enough? >> >> >> I would prefer a real world example and FATE has a bunch of conformance samples already. >> Adding the ones from https://github.com/nokiatech/heif_conformance shouldn't be a problem. >> Ideally the sample test should be added to this same patch. > > Great, i have added two samples. Can you please upload C002.heic and > C003.heic from the heif_conformance repository to the fate server > under the "heif-conformance" sub-directory. I have also attached those > two files in this email for reference. I will update the patch with > the fate tests. > Why are you intend to add so big files when the linked repo contains smaller files? All five multilayer files are below 20KB each; multilayer005.heic is even only 4.5KB. MIAF002.heic (8.6KB) and MIAF003.heic (13.5KB) are also quite small. C025.heic (19.4KB) and C053.heic (14.2KB) are also quite small and there are also other samples in the 50KB-60KB range (C017.heic, C018.heic, C019.heic, C020.heic, C041.heic). Besides taking up less diskspace, smaller files will likely be faster to decode (which is particularly advantageous for people like me who run FATE a lot). - Andreas _______________________________________________ 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mov: Add support for demuxing still HEIC images 2023-10-05 17:59 ` [FFmpeg-devel] [PATCH] " Andreas Rheinhardt @ 2023-10-05 22:32 ` Vignesh Venkat via ffmpeg-devel 0 siblings, 0 replies; 20+ messages in thread From: Vignesh Venkat via ffmpeg-devel @ 2023-10-05 22:32 UTC (permalink / raw) To: FFmpeg development discussions and patches; +Cc: Vignesh Venkat On Thu, Oct 5, 2023 at 10:58 AM Andreas Rheinhardt <andreas.rheinhardt@outlook.com> wrote: > > Vignesh Venkat via ffmpeg-devel: > > On Tue, Oct 3, 2023 at 9:40 PM Vittorio Giovara > > <vittorio.giovara@gmail.com> wrote: > >> > >> > >> > >> On Wed, Oct 4, 2023 at 12:02 AM Vignesh Venkat via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> wrote: > >>> > >>> On Tue, Oct 3, 2023 at 6:32 PM Vittorio Giovara > >>> <vittorio.giovara@gmail.com> wrote: > >>>> > >>>> On Tue, Oct 3, 2023 at 8:30 PM Steven Liu <lingjiujianke@gmail.com> wrote: > >>>> > >>>>>>> 2.42.0.515.g380fc7ccd1-goog > >>>>>>> > >>>>>> > >>>>>> Any comments/objections on merging this? > >>>>> > >>>>> > >>>>> Can this patch support tiled hevc coded or sequence heif?= > >>>>> > >>>> > >>>> I believe that will be possible only after AVStreamGroup is implemented. > >>>> > >>> > >>> Yes, this patch only supports still HEIC images that don't have alpha > >>> and grids (tiles). > >>> > >>> Tiles and Alpha support will be possible only after AVStreamGroup is > >>> implemented. I will look into HEIC sequences in a follow-up. > >>> > >>>> Vignesh is there a sample available? Could we add a test? > >>> > >>> I tested it from the files in > >>> https://github.com/nokiatech/heif/tree/gh-pages/content/images. I am > >>> not sure about HEVC licensing and if we are allowed to copy some of > >>> those files in the ffmpeg fate server. Would generating a random image > >>> with ffmpeg and encoding it as HEIC be good enough? > >> > >> > >> I would prefer a real world example and FATE has a bunch of conformance samples already. > >> Adding the ones from https://github.com/nokiatech/heif_conformance shouldn't be a problem. > >> Ideally the sample test should be added to this same patch. > > > > Great, i have added two samples. Can you please upload C002.heic and > > C003.heic from the heif_conformance repository to the fate server > > under the "heif-conformance" sub-directory. I have also attached those > > two files in this email for reference. I will update the patch with > > the fate tests. > > > > Why are you intend to add so big files when the linked repo contains > smaller files? All five multilayer files are below 20KB each; > multilayer005.heic is even only 4.5KB. MIAF002.heic (8.6KB) and > MIAF003.heic (13.5KB) are also quite small. C025.heic (19.4KB) and > C053.heic (14.2KB) are also quite small and there are also other samples > in the 50KB-60KB range (C017.heic, C018.heic, C019.heic, C020.heic, > C041.heic). Besides taking up less diskspace, smaller files will likely > be faster to decode (which is particularly advantageous for people like > me who run FATE a lot). > There is an excel sheet in the samples github repository that explains the features of each of those files. I picked the files with the simplest features (single item and multi-item) since those are the only two files that I know for certain the current ffmpeg parser can parse as-is. The multi-layer files that you mention may work, but i am not sure if we are handling those layers the right way. So adding something that I am not sure if it has the right behavior or not to a fate test didn't seem right. Also, the fate test only demuxes the files (using -c copy) and does not do any decoding since it tests the parser and not the hevc decoder. So decoding time is not a concern. I do understand the concern about disk-space though. I can probably make a random file that is smaller, but I also thought it was better to use files from an existing conformance repository. Please let me know if that is reasonable. > - Andreas > > _______________________________________________ > 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". -- 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mov: Add support for demuxing still HEIC images 2023-10-04 0:29 ` Steven Liu 2023-10-04 1:31 ` Vittorio Giovara @ 2023-10-04 4:28 ` Vignesh Venkat via ffmpeg-devel 1 sibling, 0 replies; 20+ messages in thread From: Vignesh Venkat via ffmpeg-devel @ 2023-10-04 4:28 UTC (permalink / raw) To: FFmpeg development discussions and patches; +Cc: Vignesh Venkat On Tue, Oct 3, 2023 at 5:30 PM Steven Liu <lingjiujianke@gmail.com> wrote: > > Vignesh Venkat via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>于2023年10月4日 > 周三06:57写道: > > > On Tue, Sep 26, 2023 at 10:37 AM Vignesh Venkatasubramanian > > <vigneshv@google.com> wrote: > > > > > > They are similar to AVIF images (both use the HEIF container). > > > The only additional work needed is to parse the hvcC box and put > > > it in the extradata. > > > > > > With this patch applied, ffmpeg (when built with an HEVC decoder) > > > is able to decode the files in > > > https://github.com/nokiatech/heif/tree/gh-pages/content/images > > > > > > Partially fixes trac ticket #6521. > > > > > > Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> > > > --- > > > libavformat/isom.h | 2 ++ > > > libavformat/mov.c | 38 +++++++++++++++++++++++++++++++++++++- > > > 2 files changed, 39 insertions(+), 1 deletion(-) > > > > > > diff --git a/libavformat/isom.h b/libavformat/isom.h > > > index 3d375d7a46..b30b9da65e 100644 > > > --- a/libavformat/isom.h > > > +++ b/libavformat/isom.h > > > @@ -327,6 +327,8 @@ typedef struct MOVContext { > > > int64_t extent_offset; > > > } *avif_info; > > > int avif_info_size; > > > + int64_t hvcC_offset; > > > + int hvcC_size; > > > int interleaved_read; > > > } MOVContext; > > > > > > diff --git a/libavformat/mov.c b/libavformat/mov.c > > > index 1996e0028c..cec9cb5fe1 100644 > > > --- a/libavformat/mov.c > > > +++ b/libavformat/mov.c > > > @@ -1218,7 +1218,8 @@ static int mov_read_ftyp(MOVContext *c, > > AVIOContext *pb, MOVAtom atom) > > > c->isom = 1; > > > av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: > > %.4s\n",(char *)&type); > > > av_dict_set(&c->fc->metadata, "major_brand", type, 0); > > > - c->is_still_picture_avif = !strncmp(type, "avif", 4); > > > + c->is_still_picture_avif = !strncmp(type, "avif", 4) || > > > + !strncmp(type, "mif1", 4); > > > minor_ver = avio_rb32(pb); /* minor version */ > > > av_dict_set_int(&c->fc->metadata, "minor_version", minor_ver, 0); > > > > > > @@ -4911,6 +4912,16 @@ static int avif_add_stream(MOVContext *c, int > > item_id) > > > st->priv_data = sc; > > > st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; > > > st->codecpar->codec_id = AV_CODEC_ID_AV1; > > > + if (c->hvcC_offset >= 0) { > > > + int ret; > > > + int64_t pos = avio_tell(c->fc->pb); > > > + st->codecpar->codec_id = AV_CODEC_ID_HEVC; > > > + avio_seek(c->fc->pb, c->hvcC_offset, SEEK_SET); > > > + ret = ff_get_extradata(c->fc, st->codecpar, c->fc->pb, > > c->hvcC_size); > > > + if (ret < 0) > > > + return ret; > > > + avio_seek(c->fc->pb, pos, SEEK_SET); > > > + } > > > sc->ffindex = st->index; > > > c->trak_index = st->index; > > > st->avg_frame_rate.num = st->avg_frame_rate.den = 1; > > > @@ -4953,6 +4964,8 @@ static int avif_add_stream(MOVContext *c, int > > item_id) > > > > > > static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom) > > > { > > > + c->hvcC_offset = -1; > > > + c->hvcC_size = 0; > > > while (atom.size > 8) { > > > uint32_t tag; > > > if (avio_feof(pb)) > > > @@ -7826,6 +7839,28 @@ static int mov_read_iloc(MOVContext *c, > > AVIOContext *pb, MOVAtom atom) > > > return atom.size; > > > } > > > > > > +static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) > > > +{ > > > + int size = avio_rb32(pb); > > > + if (avio_rl32(pb) != MKTAG('i','p','c','o')) > > > + return AVERROR_INVALIDDATA; > > > + size -= 8; > > > + while (size > 0) { > > > + int sub_size, sub_type; > > > + sub_size = avio_rb32(pb); > > > + sub_type = avio_rl32(pb); > > > + sub_size -= 8; > > > + size -= sub_size + 8; > > > + if (sub_type == MKTAG('h','v','c','C')) { > > > + c->hvcC_offset = avio_tell(pb); > > > + c->hvcC_size = sub_size; > > > + break; > > > + } > > > + avio_skip(pb, sub_size); > > > + } > > > + return atom.size; > > > +} > > > + > > > static const MOVParseTableEntry mov_default_parse_table[] = { > > > { MKTAG('A','C','L','R'), mov_read_aclr }, > > > { MKTAG('A','P','R','G'), mov_read_avid }, > > > @@ -7933,6 +7968,7 @@ static const MOVParseTableEntry > > mov_default_parse_table[] = { > > > { MKTAG('p','c','m','C'), mov_read_pcmc }, /* PCM configuration box */ > > > { MKTAG('p','i','t','m'), mov_read_pitm }, > > > { MKTAG('e','v','c','C'), mov_read_glbl }, > > > +{ MKTAG('i','p','r','p'), mov_read_iprp }, > > > { 0, NULL } > > > }; > > > > > > -- > > > 2.42.0.515.g380fc7ccd1-goog > > > > > > > Any comments/objections on merging this? > > > Can this patch support tiled hevc coded or sequence heif? > Actually, sequence HEIF is very similar to an HEVC video in a MP4 container and all the necessary data is in the 'moov' box. So it already works with the current tip-of-tree build of ffmpeg. I tried all the files in https://github.com/nokiatech/heif/tree/gh-pages/content/image_sequences and was able to decode all of them. So once this patch is applied, the only unsupported items would be Alpha and Grid (Tiles) for both AVIF and HEIC. > > > > > > -- > > 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". > > > _______________________________________________ > 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". -- 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mov: Add support for demuxing still HEIC images 2023-09-26 17:37 [FFmpeg-devel] [PATCH] avformat/mov: Add support for demuxing still HEIC images Vignesh Venkatasubramanian via ffmpeg-devel 2023-10-03 22:56 ` Vignesh Venkat via ffmpeg-devel @ 2023-10-04 2:35 ` Leo Izen 2023-10-04 4:19 ` Vignesh Venkat via ffmpeg-devel 1 sibling, 1 reply; 20+ messages in thread From: Leo Izen @ 2023-10-04 2:35 UTC (permalink / raw) To: ffmpeg-devel On 9/26/23 13:37, Vignesh Venkatasubramanian via ffmpeg-devel wrote: > They are similar to AVIF images (both use the HEIF container). > The only additional work needed is to parse the hvcC box and put > it in the extradata. > > With this patch applied, ffmpeg (when built with an HEVC decoder) > is able to decode the files in > https://github.com/nokiatech/heif/tree/gh-pages/content/images > > Partially fixes trac ticket #6521. > > Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> > --- > libavformat/isom.h | 2 ++ > libavformat/mov.c | 38 +++++++++++++++++++++++++++++++++++++- > 2 files changed, 39 insertions(+), 1 deletion(-) > > diff --git a/libavformat/isom.h b/libavformat/isom.h > index 3d375d7a46..b30b9da65e 100644 > --- a/libavformat/isom.h > +++ b/libavformat/isom.h > @@ -327,6 +327,8 @@ typedef struct MOVContext { > int64_t extent_offset; > } *avif_info; > int avif_info_size; > + int64_t hvcC_offset; > + int hvcC_size; > int interleaved_read; > } MOVContext; > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 1996e0028c..cec9cb5fe1 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -1218,7 +1218,8 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom) > c->isom = 1; > av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type); > av_dict_set(&c->fc->metadata, "major_brand", type, 0); > - c->is_still_picture_avif = !strncmp(type, "avif", 4); > + c->is_still_picture_avif = !strncmp(type, "avif", 4) || > + !strncmp(type, "mif1", 4); This appears to be an unrelated change. Is it? > minor_ver = avio_rb32(pb); /* minor version */ > av_dict_set_int(&c->fc->metadata, "minor_version", minor_ver, 0); > > @@ -4911,6 +4912,16 @@ static int avif_add_stream(MOVContext *c, int item_id) > st->priv_data = sc; > st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; > st->codecpar->codec_id = AV_CODEC_ID_AV1; > + if (c->hvcC_offset >= 0) { > + int ret; > + int64_t pos = avio_tell(c->fc->pb); > + st->codecpar->codec_id = AV_CODEC_ID_HEVC; > + avio_seek(c->fc->pb, c->hvcC_offset, SEEK_SET); > + ret = ff_get_extradata(c->fc, st->codecpar, c->fc->pb, c->hvcC_size); > + if (ret < 0) > + return ret; > + avio_seek(c->fc->pb, pos, SEEK_SET); > + } Will this fail on non-seekable input? If it does, do we care? > sc->ffindex = st->index; > c->trak_index = st->index; > st->avg_frame_rate.num = st->avg_frame_rate.den = 1; > @@ -4953,6 +4964,8 @@ static int avif_add_stream(MOVContext *c, int item_id) > > static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom) > { > + c->hvcC_offset = -1; > + c->hvcC_size = 0; > while (atom.size > 8) { > uint32_t tag; > if (avio_feof(pb)) > @@ -7826,6 +7839,28 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) > return atom.size; > } > > +static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) > +{ > + int size = avio_rb32(pb); > + if (avio_rl32(pb) != MKTAG('i','p','c','o')) > + return AVERROR_INVALIDDATA; Is there a reason you use ipco here instead of iprp? I'm not saying this is wrong, but I am confused while you're doing it this way. > + size -= 8; > + while (size > 0) { > + int sub_size, sub_type; > + sub_size = avio_rb32(pb); > + sub_type = avio_rl32(pb); > + sub_size -= 8; > + size -= sub_size + 8; > + if (sub_type == MKTAG('h','v','c','C')) { > + c->hvcC_offset = avio_tell(pb); > + c->hvcC_size = sub_size; > + break; > + } Are these permitted to use extended-size tags? i.e. size = 1, followed by a big-endian 64-bit size, then followed by the tag? > + avio_skip(pb, sub_size); > + } > + return atom.size; > +} > + > static const MOVParseTableEntry mov_default_parse_table[] = { > { MKTAG('A','C','L','R'), mov_read_aclr }, > { MKTAG('A','P','R','G'), mov_read_avid }, > @@ -7933,6 +7968,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { > { MKTAG('p','c','m','C'), mov_read_pcmc }, /* PCM configuration box */ > { MKTAG('p','i','t','m'), mov_read_pitm }, > { MKTAG('e','v','c','C'), mov_read_glbl }, > +{ MKTAG('i','p','r','p'), mov_read_iprp }, > { 0, NULL } > }; > - Leo Izen _______________________________________________ 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mov: Add support for demuxing still HEIC images 2023-10-04 2:35 ` Leo Izen @ 2023-10-04 4:19 ` Vignesh Venkat via ffmpeg-devel 2023-10-04 4:20 ` [FFmpeg-devel] [PATCH v2] " Vignesh Venkatasubramanian via ffmpeg-devel 0 siblings, 1 reply; 20+ messages in thread From: Vignesh Venkat via ffmpeg-devel @ 2023-10-04 4:19 UTC (permalink / raw) To: FFmpeg development discussions and patches; +Cc: Vignesh Venkat On Tue, Oct 3, 2023 at 7:35 PM Leo Izen <leo.izen@gmail.com> wrote: > > On 9/26/23 13:37, Vignesh Venkatasubramanian via ffmpeg-devel wrote: > > They are similar to AVIF images (both use the HEIF container). > > The only additional work needed is to parse the hvcC box and put > > it in the extradata. > > > > With this patch applied, ffmpeg (when built with an HEVC decoder) > > is able to decode the files in > > https://github.com/nokiatech/heif/tree/gh-pages/content/images > > > > Partially fixes trac ticket #6521. > > > > Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> > > --- > > libavformat/isom.h | 2 ++ > > libavformat/mov.c | 38 +++++++++++++++++++++++++++++++++++++- > > 2 files changed, 39 insertions(+), 1 deletion(-) > > > > diff --git a/libavformat/isom.h b/libavformat/isom.h > > index 3d375d7a46..b30b9da65e 100644 > > --- a/libavformat/isom.h > > +++ b/libavformat/isom.h > > @@ -327,6 +327,8 @@ typedef struct MOVContext { > > int64_t extent_offset; > > } *avif_info; > > int avif_info_size; > > + int64_t hvcC_offset; > > + int hvcC_size; > > int interleaved_read; > > } MOVContext; > > > > diff --git a/libavformat/mov.c b/libavformat/mov.c > > index 1996e0028c..cec9cb5fe1 100644 > > --- a/libavformat/mov.c > > +++ b/libavformat/mov.c > > @@ -1218,7 +1218,8 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom) > > c->isom = 1; > > av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type); > > av_dict_set(&c->fc->metadata, "major_brand", type, 0); > > - c->is_still_picture_avif = !strncmp(type, "avif", 4); > > + c->is_still_picture_avif = !strncmp(type, "avif", 4) || > > + !strncmp(type, "mif1", 4); > > This appears to be an unrelated change. Is it? > No, "mif1" is the major brand reported by HEIC files. So this is needed to detect HEIC files. > > minor_ver = avio_rb32(pb); /* minor version */ > > av_dict_set_int(&c->fc->metadata, "minor_version", minor_ver, 0); > > > > @@ -4911,6 +4912,16 @@ static int avif_add_stream(MOVContext *c, int item_id) > > st->priv_data = sc; > > st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; > > st->codecpar->codec_id = AV_CODEC_ID_AV1; > > + if (c->hvcC_offset >= 0) { > > + int ret; > > + int64_t pos = avio_tell(c->fc->pb); > > + st->codecpar->codec_id = AV_CODEC_ID_HEVC; > > + avio_seek(c->fc->pb, c->hvcC_offset, SEEK_SET); > > + ret = ff_get_extradata(c->fc, st->codecpar, c->fc->pb, c->hvcC_size); > > + if (ret < 0) > > + return ret; > > + avio_seek(c->fc->pb, pos, SEEK_SET); > > + } > > Will this fail on non-seekable input? If it does, do we care? > I tried this with a pipe as an input (cat file.heic | ffmpeg -i - ...) and it worked. I also see plenty of unconditional avio_seek calls in this file. So I am not sure how it works. Anyways, I added a check to fail here if the seek does not take us to the desired position. > > sc->ffindex = st->index; > > c->trak_index = st->index; > > st->avg_frame_rate.num = st->avg_frame_rate.den = 1; > > @@ -4953,6 +4964,8 @@ static int avif_add_stream(MOVContext *c, int item_id) > > > > static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom) > > { > > + c->hvcC_offset = -1; > > + c->hvcC_size = 0; > > while (atom.size > 8) { > > uint32_t tag; > > if (avio_feof(pb)) > > @@ -7826,6 +7839,28 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) > > return atom.size; > > } > > > > +static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) > > +{ > > + int size = avio_rb32(pb); > > + if (avio_rl32(pb) != MKTAG('i','p','c','o')) > > + return AVERROR_INVALIDDATA; > > Is there a reason you use ipco here instead of iprp? I'm not saying this > is wrong, but I am confused while you're doing it this way. > The control flow will jump into this function only when an "iprp" box has been seen (pb points to the start of the contents of the iprp box). "ipco" is a sub-box of the "iprp" box that we care about. We cannot register sub-boxes to mov_read_default without registering the containing box, as the containing box will be skipped if it is unknown. Some other sub-box reading is already implemented this way (mov_read_meta for example). > > + size -= 8; > > + while (size > 0) { > > + int sub_size, sub_type; > > + sub_size = avio_rb32(pb); > > + sub_type = avio_rl32(pb); > > + sub_size -= 8; > > + size -= sub_size + 8; > > + if (sub_type == MKTAG('h','v','c','C')) { > > + c->hvcC_offset = avio_tell(pb); > > + c->hvcC_size = sub_size; > > + break; > > + } > > Are these permitted to use extended-size tags? i.e. size = 1, followed > by a big-endian 64-bit size, then followed by the tag? > MP4 "type" fields are always 32-bits. So they cannot be of any other size. Thank you for the review! > > + avio_skip(pb, sub_size); > > + } > > + return atom.size; > > +} > > + > > static const MOVParseTableEntry mov_default_parse_table[] = { > > { MKTAG('A','C','L','R'), mov_read_aclr }, > > { MKTAG('A','P','R','G'), mov_read_avid }, > > @@ -7933,6 +7968,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { > > { MKTAG('p','c','m','C'), mov_read_pcmc }, /* PCM configuration box */ > > { MKTAG('p','i','t','m'), mov_read_pitm }, > > { MKTAG('e','v','c','C'), mov_read_glbl }, > > +{ MKTAG('i','p','r','p'), mov_read_iprp }, > > { 0, NULL } > > }; > > > > - Leo Izen > _______________________________________________ > 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". -- 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
* [FFmpeg-devel] [PATCH v2] avformat/mov: Add support for demuxing still HEIC images 2023-10-04 4:19 ` Vignesh Venkat via ffmpeg-devel @ 2023-10-04 4:20 ` Vignesh Venkatasubramanian via ffmpeg-devel 0 siblings, 0 replies; 20+ messages in thread From: Vignesh Venkatasubramanian via ffmpeg-devel @ 2023-10-04 4:20 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Vignesh Venkatasubramanian They are similar to AVIF images (both use the HEIF container). The only additional work needed is to parse the hvcC box and put it in the extradata. With this patch applied, ffmpeg (when built with an HEVC decoder) is able to decode the files in https://github.com/nokiatech/heif/tree/gh-pages/content/images Partially fixes trac ticket #6521. Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavformat/isom.h | 2 ++ libavformat/mov.c | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index 3d375d7a46..b30b9da65e 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -327,6 +327,8 @@ typedef struct MOVContext { int64_t extent_offset; } *avif_info; int avif_info_size; + int64_t hvcC_offset; + int hvcC_size; int interleaved_read; } MOVContext; diff --git a/libavformat/mov.c b/libavformat/mov.c index 1996e0028c..8ee93f321e 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1218,7 +1218,8 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom) c->isom = 1; av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type); av_dict_set(&c->fc->metadata, "major_brand", type, 0); - c->is_still_picture_avif = !strncmp(type, "avif", 4); + c->is_still_picture_avif = !strncmp(type, "avif", 4) || + !strncmp(type, "mif1", 4); minor_ver = avio_rb32(pb); /* minor version */ av_dict_set_int(&c->fc->metadata, "minor_version", minor_ver, 0); @@ -4911,6 +4912,19 @@ static int avif_add_stream(MOVContext *c, int item_id) st->priv_data = sc; st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; st->codecpar->codec_id = AV_CODEC_ID_AV1; + if (c->hvcC_offset >= 0) { + int ret; + int64_t pos = avio_tell(c->fc->pb); + st->codecpar->codec_id = AV_CODEC_ID_HEVC; + if (avio_seek(c->fc->pb, c->hvcC_offset, SEEK_SET) != c->hvcC_offset) { + av_log(c->fc, AV_LOG_ERROR, "Failed to seek to hvcC data.\n"); + return AVERROR_UNKNOWN; + } + ret = ff_get_extradata(c->fc, st->codecpar, c->fc->pb, c->hvcC_size); + if (ret < 0) + return ret; + avio_seek(c->fc->pb, pos, SEEK_SET); + } sc->ffindex = st->index; c->trak_index = st->index; st->avg_frame_rate.num = st->avg_frame_rate.den = 1; @@ -4953,6 +4967,8 @@ static int avif_add_stream(MOVContext *c, int item_id) static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom) { + c->hvcC_offset = -1; + c->hvcC_size = 0; while (atom.size > 8) { uint32_t tag; if (avio_feof(pb)) @@ -7826,6 +7842,28 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) return atom.size; } +static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + int size = avio_rb32(pb); + if (avio_rl32(pb) != MKTAG('i','p','c','o')) + return AVERROR_INVALIDDATA; + size -= 8; + while (size > 0) { + int sub_size, sub_type; + sub_size = avio_rb32(pb); + sub_type = avio_rl32(pb); + sub_size -= 8; + size -= sub_size + 8; + if (sub_type == MKTAG('h','v','c','C')) { + c->hvcC_offset = avio_tell(pb); + c->hvcC_size = sub_size; + break; + } + avio_skip(pb, sub_size); + } + return atom.size; +} + static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('A','C','L','R'), mov_read_aclr }, { MKTAG('A','P','R','G'), mov_read_avid }, @@ -7933,6 +7971,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('p','c','m','C'), mov_read_pcmc }, /* PCM configuration box */ { MKTAG('p','i','t','m'), mov_read_pitm }, { MKTAG('e','v','c','C'), mov_read_glbl }, +{ MKTAG('i','p','r','p'), mov_read_iprp }, { 0, NULL } }; -- 2.42.0.582.g8ccd20d70d-goog _______________________________________________ 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". ^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2024-01-10 21:05 UTC | newest] Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-09-26 17:37 [FFmpeg-devel] [PATCH] avformat/mov: Add support for demuxing still HEIC images Vignesh Venkatasubramanian via ffmpeg-devel 2023-10-03 22:56 ` Vignesh Venkat via ffmpeg-devel 2023-10-04 0:29 ` Steven Liu 2023-10-04 1:31 ` Vittorio Giovara 2023-10-04 4:01 ` Vignesh Venkat via ffmpeg-devel 2023-10-04 4:40 ` Vittorio Giovara 2023-10-04 16:36 ` Vignesh Venkat via ffmpeg-devel 2023-10-04 16:40 ` [FFmpeg-devel] [PATCH v3] " Vignesh Venkatasubramanian via ffmpeg-devel 2023-10-05 17:36 ` Vittorio Giovara 2023-10-05 22:40 ` Vignesh Venkat via ffmpeg-devel 2023-10-09 18:52 ` Vignesh Venkat via ffmpeg-devel 2023-10-27 16:52 ` Thilo Borgmann via ffmpeg-devel 2024-01-09 12:39 ` James Almer 2024-01-10 21:05 ` Vignesh Venkat via ffmpeg-devel 2023-10-05 17:59 ` [FFmpeg-devel] [PATCH] " Andreas Rheinhardt 2023-10-05 22:32 ` Vignesh Venkat via ffmpeg-devel 2023-10-04 4:28 ` Vignesh Venkat via ffmpeg-devel 2023-10-04 2:35 ` Leo Izen 2023-10-04 4:19 ` Vignesh Venkat via ffmpeg-devel 2023-10-04 4:20 ` [FFmpeg-devel] [PATCH v2] " Vignesh Venkatasubramanian via ffmpeg-devel
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