@@ -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 {
@@ -277,6 +277,7 @@ typedef struct HEIFItem {
int64_t extent_offset;
int width;
int height;
+ int rotation;
int type;
int is_idat_relative;
} HEIFItem;
@@ -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);
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(+)