History

avformat/mov: make MOVStreamContext refcounted

This will be useful in the next commit.

James Almer committed 2 years ago

Commit 9ba327e1 parent ce7b5192 files · +7 −1Browse files

Unified · Split

2 files
  1. libavformat/isom.h +1 −0
  2. libavformat/mov.c +6 −1
libavformat/isom.h+1−0
@@ -166,6 +166,7 @@ typedef struct MOVIndexRange { · 165 unmodified lines
166166
167167 typedef struct MOVStreamContext {
168168 AVIOContext *pb;
169+ int refcount;
169170 int pb_is_copied;
170171 int ffindex; ///< AVStream index
171172 int next_chunk;
libavformat/mov.c+6−1
@@ -212,6 +212,7 @@ static int mov_read_covr(MOVContext *c, AVIOContext *pb, int type, int len) · 211 unmodified lines
212212 }
213213 st = c->fc->streams[c->fc->nb_streams - 1];
214214 st->priv_data = sc;
215+ sc->refcount = 1;
215216
216217 if (st->attached_pic.size >= 8 && id != AV_CODEC_ID_BMP) {
217218 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
46224623 st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
46234624 sc->ffindex = st->index;
46244625 c->trak_index = st->index;
4626+ sc->refcount = 1;
46254627
46264628 if ((ret = mov_read_default(c, pb, atom)) < 0)
46274629 return ret;
@@ -4909,6 +4911,7 @@ static int heif_add_stream(MOVContext *c, HEIFItem *item) · 281 unmodified lines
49094911 sc = st->priv_data;
49104912 sc->pb = c->fc->pb;
49114913 sc->pb_is_copied = 1;
4914+ sc->refcount = 1;
49124915
49134916 // Populate the necessary fields used by mov_build_index.
49144917 sc->stsc_count = 1;
@@ -8610,8 +8613,10 @@ static void mov_free_stream_context(AVFormatContext *s, AVStream *st) · 3695 unmodified lines
86108613 {
86118614 MOVStreamContext *sc = st->priv_data;
86128615
8613− if (!sc)
8616+ if (!sc || --sc->refcount) {
8617+ st->priv_data = NULL;
86148618 return;
8619+ }
86158620
86168621 av_freep(&sc->ctts_data);
86178622 for (int i = 0; i < sc->drefs_count; i++) {

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