Complements 76eb3e5ff3a35eff01dd71aca82efcda50c4441f.
Showing the changes to libavformat (2 of 2 files). Show all
Unified · Split
| @@ -284,6 +284,8 @@ typedef struct HEIFItem { · 283 unmodified lines | ||
| 284 | 284 | int width; |
| 285 | 285 | int height; |
| 286 | 286 | int rotation; |
| 287 | + int hflip; | |
| 288 | + int vflip; | |
| 287 | 289 | int type; |
| 288 | 290 | int is_idat_relative; |
| 289 | 291 | uint8_t *icc_profile; |
| @@ -8994,6 +8994,25 @@ static int mov_read_irot(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 8993 unmodified lines | ||
| 8994 | 8994 | return 0; |
| 8995 | 8995 | } |
| 8996 | 8996 | |
| 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 | + | |
| 8997 | 9016 | static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) |
| 8998 | 9017 | { |
| 8999 | 9018 | typedef struct MOVAtoms { |
| @@ -9218,6 +9237,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { · 218 unmodified lines | ||
| 9218 | 9237 | { MKTAG('p','i','t','m'), mov_read_pitm }, |
| 9219 | 9238 | { MKTAG('e','v','c','C'), mov_read_glbl }, |
| 9220 | 9239 | { MKTAG('i','d','a','t'), mov_read_idat }, |
| 9240 | +{ MKTAG('i','m','i','r'), mov_read_imir }, | |
| 9221 | 9241 | { MKTAG('i','r','e','f'), mov_read_iref }, |
| 9222 | 9242 | { MKTAG('i','s','p','e'), mov_read_ispe }, |
| 9223 | 9243 | { 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 | ||
| 9922 | 9942 | * av_display_rotation_set() expects its argument to be |
| 9923 | 9943 | * oriented clockwise, so we need to negate it. */ |
| 9924 | 9944 | av_display_rotation_set(matrix, -item->rotation); |
| 9945 | + av_display_matrix_flip(matrix, item->hflip, item->vflip); | |
| 9925 | 9946 | |
| 9926 | 9947 | return 0; |
| 9927 | 9948 | } |
| @@ -9967,7 +9988,7 @@ static int read_image_grid(AVFormatContext *s, const HEIFGrid *grid, · 39 unmodified lines | ||
| 9967 | 9988 | return ret; |
| 9968 | 9989 | } |
| 9969 | 9990 | /* rotation */ |
| 9970 | − if (item->rotation) { | |
| 9991 | + if (item->rotation || item->hflip || item->vflip) { | |
| 9971 | 9992 | int ret = set_display_matrix_from_item(&tile_grid->coded_side_data, |
| 9972 | 9993 | &tile_grid->nb_coded_side_data, item); |
| 9973 | 9994 | if (ret < 0) |
| @@ -10066,7 +10087,7 @@ static int read_image_iovl(AVFormatContext *s, const HEIFGrid *grid, · 92 unmodified lines | ||
| 10066 | 10087 | tile_grid->coded_height = (flags & 1) ? avio_rb32(s->pb) : avio_rb16(s->pb); |
| 10067 | 10088 | |
| 10068 | 10089 | /* rotation */ |
| 10069 | − if (item->rotation) { | |
| 10090 | + if (item->rotation || item->hflip || item->vflip) { | |
| 10070 | 10091 | int ret = set_display_matrix_from_item(&tile_grid->coded_side_data, |
| 10071 | 10092 | &tile_grid->nb_coded_side_data, item); |
| 10072 | 10093 | if (ret < 0) |
| @@ -10283,7 +10304,7 @@ static int mov_read_header(AVFormatContext *s) · 210 unmodified lines | ||
| 10283 | 10304 | if (item->item_id == mov->primary_item_id) |
| 10284 | 10305 | st->disposition |= AV_DISPOSITION_DEFAULT; |
| 10285 | 10306 | |
| 10286 | − if (item->rotation) { | |
| 10307 | + if (item->rotation || item->hflip || item->vflip) { | |
| 10287 | 10308 | int ret = set_display_matrix_from_item(&st->codecpar->coded_side_data, |
| 10288 | 10309 | &st->codecpar->nb_coded_side_data, item); |
| 10289 | 10310 | if (ret < 0) |