This will be useful in the next commit.
Showing the changes to libavformat (2 of 2 files). Show all
Unified · Split
| @@ -166,6 +166,7 @@ typedef struct MOVIndexRange { · 165 unmodified lines | |||
| 166 | 166 | ||
| 167 | typedef struct MOVStreamContext { | 167 | typedef struct MOVStreamContext { |
| 168 | AVIOContext *pb; | 168 | AVIOContext *pb; |
| 169 | int refcount; | ||
| 169 | int pb_is_copied; | 170 | int pb_is_copied; |
| 170 | int ffindex; ///< AVStream index | 171 | int ffindex; ///< AVStream index |
| 171 | int next_chunk; | 172 | int next_chunk; |
| @@ -212,6 +212,7 @@ static int mov_read_covr(MOVContext *c, AVIOContext *pb, int type, int len) · 211 unmodified lines | |||
| 212 | } | 212 | } |
| 213 | st = c->fc->streams[c->fc->nb_streams - 1]; | 213 | st = c->fc->streams[c->fc->nb_streams - 1]; |
| 214 | st->priv_data = sc; | 214 | st->priv_data = sc; |
| 215 | sc->refcount = 1; | ||
| 215 | 216 | ||
| 216 | if (st->attached_pic.size >= 8 && id != AV_CODEC_ID_BMP) { | 217 | if (st->attached_pic.size >= 8 && id != AV_CODEC_ID_BMP) { |
| 217 | if (AV_RB64(st->attached_pic.data) == 0x89504e470d0a1a0a) { | 218 | if (AV_RB64(st->attached_pic.data) == 0x89504e470d0a1a0a) { |
| @@ -4622,6 +4623,7 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 4404 unmodified lines | |||
| 4622 | st->codecpar->codec_type = AVMEDIA_TYPE_DATA; | 4623 | st->codecpar->codec_type = AVMEDIA_TYPE_DATA; |
| 4623 | sc->ffindex = st->index; | 4624 | sc->ffindex = st->index; |
| 4624 | c->trak_index = st->index; | 4625 | c->trak_index = st->index; |
| 4626 | sc->refcount = 1; | ||
| 4625 | 4627 | ||
| 4626 | if ((ret = mov_read_default(c, pb, atom)) < 0) | 4628 | if ((ret = mov_read_default(c, pb, atom)) < 0) |
| 4627 | return ret; | 4629 | return ret; |
| @@ -4909,6 +4911,7 @@ static int heif_add_stream(MOVContext *c, HEIFItem *item) · 281 unmodified lines | |||
| 4909 | sc = st->priv_data; | 4911 | sc = st->priv_data; |
| 4910 | sc->pb = c->fc->pb; | 4912 | sc->pb = c->fc->pb; |
| 4911 | sc->pb_is_copied = 1; | 4913 | sc->pb_is_copied = 1; |
| 4914 | sc->refcount = 1; | ||
| 4912 | 4915 | ||
| 4913 | // Populate the necessary fields used by mov_build_index. | 4916 | // Populate the necessary fields used by mov_build_index. |
| 4914 | sc->stsc_count = 1; | 4917 | sc->stsc_count = 1; |
| @@ -8610,8 +8613,10 @@ static void mov_free_stream_context(AVFormatContext *s, AVStream *st) · 3695 unmodified lines | |||
| 8610 | { | 8613 | { |
| 8611 | MOVStreamContext *sc = st->priv_data; | 8614 | MOVStreamContext *sc = st->priv_data; |
| 8612 | 8615 | ||
| 8613 | if (!sc) | 8616 | if (!sc || --sc->refcount) { |
| 8617 | st->priv_data = NULL; | ||
| 8614 | return; | 8618 | return; |
| 8619 | } | ||
| 8615 | 8620 | ||
| 8616 | av_freep(&sc->ctts_data); | 8621 | av_freep(&sc->ctts_data); |
| 8617 | for (int i = 0; i < sc->drefs_count; i++) { | 8622 | for (int i = 0; i < sc->drefs_count; i++) { |