* [FFmpeg-devel] [PATCH] avformat/mov: get heif image rotation from irot box
@ 2024-05-27 13:33 Hacene Bouaroua
2024-05-27 16:55 ` Michael Niedermayer
0 siblings, 1 reply; 2+ messages in thread
From: Hacene Bouaroua @ 2024-05-27 13:33 UTC (permalink / raw)
To: ffmpeg-devel
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;
} 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);
+
+ 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);
-- 2.34.1
_______________________________________________
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] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mov: get heif image rotation from irot box
2024-05-27 13:33 [FFmpeg-devel] [PATCH] avformat/mov: get heif image rotation from irot box Hacene Bouaroua
@ 2024-05-27 16:55 ` Michael Niedermayer
0 siblings, 0 replies; 2+ messages in thread
From: Michael Niedermayer @ 2024-05-27 16:55 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 820 bytes --]
On Mon, May 27, 2024 at 03:33:28PM +0200, 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(+)
Applying: avformat/mov: get heif image rotation from irot box
error: corrupt patch at line 22
error: could not build fake ancestor
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: 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] 2+ messages in thread
end of thread, other threads:[~2024-05-27 16:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-27 13:33 [FFmpeg-devel] [PATCH] avformat/mov: get heif image rotation from irot box Hacene Bouaroua
2024-05-27 16:55 ` Michael Niedermayer
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