History

avformat/mov: get heif image mirroring from imir box

Complements 76eb3e5ff3a35eff01dd71aca82efcda50c4441f.

James Almer committed 2 years ago

Commit 7573f021 parent f225e6f2 files · +26 −3Browse files

Showing the changes to libavformat (2 of 2 files). Show all

Unified · Split

2 files
  1. libavformat/isom.h +2 −0
  2. libavformat/mov.c +24 −3
libavformat/isom.h+2−0
@@ -284,6 +284,8 @@ typedef struct HEIFItem { · 283 unmodified lines
284284 int width;
285285 int height;
286286 int rotation;
287+ int hflip;
288+ int vflip;
287289 int type;
288290 int is_idat_relative;
289291 uint8_t *icc_profile;
libavformat/mov.c+24−3
@@ -8994,6 +8994,25 @@ static int mov_read_irot(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 8993 unmodified lines
89948994 return 0;
89958995 }
89968996
8997+static int mov_read_imir(MOVContext *c, AVIOContext *pb, MOVAtom atom)
8998+{
8999+ HEIFItem *item;
9000+ int axis;
9001+
9002+ axis = avio_r8(pb) & 0x1;
9003+
9004+ av_log(c->fc, AV_LOG_TRACE, "imir: item_id %d, axis %u\n",
9005+ c->cur_item_id, axis);
9006+
9007+ item = heif_cur_item(c);
9008+ if (item) {
9009+ item->hflip = axis;
9010+ item->vflip = !axis;
9011+ }
9012+
9013+ return 0;
9014+}
9015+
89979016 static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
89989017 {
89999018 typedef struct MOVAtoms {
@@ -9218,6 +9237,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { · 218 unmodified lines
92189237 { MKTAG('p','i','t','m'), mov_read_pitm },
92199238 { MKTAG('e','v','c','C'), mov_read_glbl },
92209239 { MKTAG('i','d','a','t'), mov_read_idat },
9240+{ MKTAG('i','m','i','r'), mov_read_imir },
92219241 { MKTAG('i','r','e','f'), mov_read_iref },
92229242 { MKTAG('i','s','p','e'), mov_read_ispe },
92239243 { MKTAG('i','r','o','t'), mov_read_irot },
@@ -9922,6 +9942,7 @@ static int set_display_matrix_from_item(AVPacketSideData **coded_side_data, int · 698 unmodified lines
99229942 * av_display_rotation_set() expects its argument to be
99239943 * oriented clockwise, so we need to negate it. */
99249944 av_display_rotation_set(matrix, -item->rotation);
9945+ av_display_matrix_flip(matrix, item->hflip, item->vflip);
99259946
99269947 return 0;
99279948 }
@@ -9967,7 +9988,7 @@ static int read_image_grid(AVFormatContext *s, const HEIFGrid *grid, · 39 unmodified lines
99679988 return ret;
99689989 }
99699990 /* rotation */
9970− if (item->rotation) {
9991+ if (item->rotation || item->hflip || item->vflip) {
99719992 int ret = set_display_matrix_from_item(&tile_grid->coded_side_data,
99729993 &tile_grid->nb_coded_side_data, item);
99739994 if (ret < 0)
@@ -10066,7 +10087,7 @@ static int read_image_iovl(AVFormatContext *s, const HEIFGrid *grid, · 92 unmodified lines
1006610087 tile_grid->coded_height = (flags & 1) ? avio_rb32(s->pb) : avio_rb16(s->pb);
1006710088
1006810089 /* rotation */
10069− if (item->rotation) {
10090+ if (item->rotation || item->hflip || item->vflip) {
1007010091 int ret = set_display_matrix_from_item(&tile_grid->coded_side_data,
1007110092 &tile_grid->nb_coded_side_data, item);
1007210093 if (ret < 0)
@@ -10283,7 +10304,7 @@ static int mov_read_header(AVFormatContext *s) · 210 unmodified lines
1028310304 if (item->item_id == mov->primary_item_id)
1028410305 st->disposition |= AV_DISPOSITION_DEFAULT;
1028510306
10286− if (item->rotation) {
10307+ if (item->rotation || item->hflip || item->vflip) {
1028710308 int ret = set_display_matrix_from_item(&st->codecpar->coded_side_data,
1028810309 &st->codecpar->nb_coded_side_data, item);
1028910310 if (ret < 0)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t