From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH, v2] avformat/mov: get heif image rotation from irot box Date: Mon, 1 Jul 2024 12:37:50 -0300 Message-ID: <1dd736dd-caed-43d8-a919-7e7ec0115f33@gmail.com> (raw) In-Reply-To: <1c939e57-2c6e-412e-b453-25f88ae29057@freebxo.fr> On 5/27/2024 12:22 PM, Hacene Bouaroua wrote: > parse irot box to get the transformative heif item rotation angle. > > Signed-off-by: Hacene Bouaroua <hbouaroua@freebox.fr> > --- > libavformat/avformat.h | 5 +++++ > libavformat/isom.h | 1 + > libavformat/mov.c | 25 +++++++++++++++++++++++++ > 3 files changed, 31 insertions(+) > > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > index 8afdcd9fd0..615650ddcb 100644 > --- a/libavformat/avformat.h > +++ b/libavformat/avformat.h > @@ -1077,6 +1077,11 @@ typedef struct AVStreamGroupTileGrid { > * final image before presentation. > */ > int height; > + /** > + * the angle which the reconstructed image is initially rotated > + * (in anti-clockwise direction) in units of degrees. > + */ > + int rotation; This should probably be an AVRational (With range [-180.0, 180.0]), so you can easily pass av_q2d(rotation) to av_display_rotation_set(). > } AVStreamGroupTileGrid; > > enum AVStreamGroupParamsType { > diff --git a/libavformat/isom.h b/libavformat/isom.h > index c0a5788e08..757e3f8738 100644 > --- a/libavformat/isom.h > +++ b/libavformat/isom.h > @@ -277,6 +277,7 @@ typedef struct HEIFItem { > int64_t extent_offset; > int width; > int height; > + int rotation; > int type; > int is_idat_relative; > } HEIFItem; > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 45eca74d1d..5f04e68f88 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -8398,6 +8398,27 @@ static int mov_read_ispe(MOVContext *c, AVIOContext *pb, MOVAtom atom) > return 0; > } > > +static int mov_read_irot(MOVContext *c, AVIOContext *pb, MOVAtom atom) > +{ > + uint32_t angle; > + > + angle = avio_r8(pb); avio_r8(pb) & 0x3. The upper bits are reserved. > + > + av_log(c->fc, AV_LOG_TRACE, "irot: item_id %d, angle %u\n", > + c->cur_item_id, angle); > + > + for (int i = 0; i < c->nb_heif_item; i++) { > + if (c->heif_item[i].item_id == c->cur_item_id) { > + // angle * 90 specifies the angle (in anti-clockwise direction) > + // in units of degrees. > + c->heif_item[i].rotation = angle * 90; > + break; > + } > + } > + > + return 0; > +} > + > static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) > { > typedef struct MOVAtoms { > @@ -8615,6 +8636,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { > { MKTAG('i','d','a','t'), mov_read_idat }, > { MKTAG('i','r','e','f'), mov_read_iref }, > { MKTAG('i','s','p','e'), mov_read_ispe }, > +{ MKTAG('i','r','o','t'), mov_read_irot }, > { MKTAG('i','p','r','p'), mov_read_iprp }, > { MKTAG('i','i','n','f'), mov_read_iinf }, > { MKTAG('a','m','v','e'), mov_read_amve }, /* ambient viewing environment box */ > @@ -9315,6 +9337,9 @@ static int read_image_grid(AVFormatContext *s, const HEIFGrid *grid, > tile_grid->width = (flags & 1) ? avio_rb32(s->pb) : avio_rb16(s->pb); > tile_grid->height = (flags & 1) ? avio_rb32(s->pb) : avio_rb16(s->pb); > > + /* rotation */ > + tile_grid->rotation = item->rotation; > + > av_log(c->fc, AV_LOG_TRACE, "grid: grid_rows %d grid_cols %d output_width %d output_height %d\n", > tile_rows, tile_cols, tile_grid->width, tile_grid->height); > _______________________________________________ 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".
prev parent reply other threads:[~2024-07-01 15:37 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-05-27 15:22 Hacene Bouaroua 2024-07-01 15:37 ` James Almer [this message]
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=1dd736dd-caed-43d8-a919-7e7ec0115f33@gmail.com \ --to=jamrial@gmail.com \ --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