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