Unified · Split
| @@ -189,6 +189,24 @@ static int mov_read_mac_string(MOVContext *c, AVIOContext *pb, int len, · 188 unmodified lines | |||
| 189 | return p - dst; | 189 | return p - dst; |
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | /** | ||
| 193 | * Get the current item in the parsing process. | ||
| 194 | */ | ||
| 195 | static HEIFItem *heif_cur_item(MOVContext *c) | ||
| 196 | { | ||
| 197 | HEIFItem *item = NULL; | ||
| 198 | |||
| 199 | for (int i = 0; i < c->nb_heif_item; i++) { | ||
| 200 | if (c->heif_item[i].item_id != c->cur_item_id) | ||
| 201 | continue; | ||
| 202 | |||
| 203 | item = &c->heif_item[i]; | ||
| 204 | break; | ||
| 205 | } | ||
| 206 | |||
| 207 | return item; | ||
| 208 | } | ||
| 209 | |||
| 192 | /** | 210 | /** |
| 193 | * Get the current stream in the parsing process. This can either be the | 211 | * Get the current stream in the parsing process. This can either be the |
| 194 | * latest stream added to the context, or the stream referenced by an item. | 212 | * latest stream added to the context, or the stream referenced by an item. |
| @@ -196,23 +214,17 @@ static int mov_read_mac_string(MOVContext *c, AVIOContext *pb, int len, · 1 unmodified line | |||
| 196 | static AVStream *get_curr_st(MOVContext *c) | 214 | static AVStream *get_curr_st(MOVContext *c) |
| 197 | { | 215 | { |
| 198 | AVStream *st = NULL; | 216 | AVStream *st = NULL; |
| 217 | HEIFItem *item; | ||
| 199 | 218 | ||
| 200 | if (c->fc->nb_streams < 1) | 219 | if (c->fc->nb_streams < 1) |
| 201 | return NULL; | 220 | return NULL; |
| 202 | 221 | ||
| 203 | for (int i = 0; i < c->nb_heif_item; i++) { | 222 | if (c->cur_item_id == -1) |
| 204 | HEIFItem *item = &c->heif_item[i]; | 223 | return c->fc->streams[c->fc->nb_streams-1]; |
| 205 | |||
| 206 | if (!item->st) | ||
| 207 | continue; | ||
| 208 | if (item->st->id != c->cur_item_id) | ||
| 209 | continue; | ||
| 210 | 224 | ||
| 225 | item = heif_cur_item(c); | ||
| 226 | if (item) | ||
| 211 | st = item->st; | 227 | st = item->st; |
| 212 | break; | ||
| 213 | } | ||
| 214 | if (!st && c->cur_item_id == -1) | ||
| 215 | st = c->fc->streams[c->fc->nb_streams-1]; | ||
| 216 | 228 | ||
| 217 | return st; | 229 | return st; |
| 218 | } | 230 | } |
| @@ -8913,6 +8925,7 @@ static int mov_read_iref(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 8694 unmodified lines | |||
| 8913 | 8925 | ||
| 8914 | static int mov_read_ispe(MOVContext *c, AVIOContext *pb, MOVAtom atom) | 8926 | static int mov_read_ispe(MOVContext *c, AVIOContext *pb, MOVAtom atom) |
| 8915 | { | 8927 | { |
| 8928 | HEIFItem *item; | ||
| 8916 | uint32_t width, height; | 8929 | uint32_t width, height; |
| 8917 | 8930 | ||
| 8918 | avio_r8(pb); /* version */ | 8931 | avio_r8(pb); /* version */ |
| @@ -8923,12 +8936,10 @@ static int mov_read_ispe(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 4 unmodified lines | |||
| 8923 | av_log(c->fc, AV_LOG_TRACE, "ispe: item_id %d, width %u, height %u\n", | 8936 | av_log(c->fc, AV_LOG_TRACE, "ispe: item_id %d, width %u, height %u\n", |
| 8924 | c->cur_item_id, width, height); | 8937 | c->cur_item_id, width, height); |
| 8925 | 8938 | ||
| 8926 | for (int i = 0; i < c->nb_heif_item; i++) { | 8939 | item = heif_cur_item(c); |
| 8927 | if (c->heif_item[i].item_id == c->cur_item_id) { | 8940 | if (item) { |
| 8928 | c->heif_item[i].width = width; | 8941 | item->width = width; |
| 8929 | c->heif_item[i].height = height; | 8942 | item->height = height; |
| 8930 | break; | ||
| 8931 | } | ||
| 8932 | } | 8943 | } |
| 8933 | 8944 | ||
| 8934 | return 0; | 8945 | return 0; |
| @@ -8936,6 +8947,7 @@ static int mov_read_ispe(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 1 unmodified line | |||
| 8936 | 8947 | ||
| 8937 | static int mov_read_irot(MOVContext *c, AVIOContext *pb, MOVAtom atom) | 8948 | static int mov_read_irot(MOVContext *c, AVIOContext *pb, MOVAtom atom) |
| 8938 | { | 8949 | { |
| 8950 | HEIFItem *item; | ||
| 8939 | int angle; | 8951 | int angle; |
| 8940 | 8952 | ||
| 8941 | angle = avio_r8(pb) & 0x3; | 8953 | angle = avio_r8(pb) & 0x3; |
| @@ -8943,13 +8955,11 @@ static int mov_read_irot(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 1 unmodified line | |||
| 8943 | av_log(c->fc, AV_LOG_TRACE, "irot: item_id %d, angle %u\n", | 8955 | av_log(c->fc, AV_LOG_TRACE, "irot: item_id %d, angle %u\n", |
| 8944 | c->cur_item_id, angle); | 8956 | c->cur_item_id, angle); |
| 8945 | 8957 | ||
| 8946 | for (int i = 0; i < c->nb_heif_item; i++) { | 8958 | item = heif_cur_item(c); |
| 8947 | if (c->heif_item[i].item_id == c->cur_item_id) { | 8959 | if (item) { |
| 8948 | // angle * 90 specifies the angle (in anti-clockwise direction) | 8960 | // angle * 90 specifies the angle (in anti-clockwise direction) |
| 8949 | // in units of degrees. | 8961 | // in units of degrees. |
| 8950 | c->heif_item[i].rotation = angle * 90; | 8962 | item->rotation = angle * 90; |
| 8951 | break; | ||
| 8952 | } | ||
| 8953 | } | 8963 | } |
| 8954 | 8964 | ||
| 8955 | return 0; | 8965 | return 0; |