Message ID | 20190621133656.21006-1-derek.buitenhuis@gmail.com |
---|---|
State | Superseded |
Headers | show |
On 6/21/2019 10:36 AM, Derek Buitenhuis wrote: > This packet was not necessarily unreferenced. > > Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> > --- > fftools/ffprobe.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c > index 3becb6330e..52f24e7dfd 100644 > --- a/fftools/ffprobe.c > +++ b/fftools/ffprobe.c > @@ -2351,6 +2351,7 @@ static int read_interval_packets(WriterContext *w, InputFile *ifile, > int ret = 0, i = 0, frame_count = 0; > int64_t start = -INT64_MAX, end = interval->end; > int has_start = 0, has_end = interval->has_end && !interval->end_is_offset; > + int needs_unref = 0; > > av_init_packet(&pkt); > > @@ -2410,9 +2411,12 @@ static int read_interval_packets(WriterContext *w, InputFile *ifile, > } > > if (interval->end_is_offset && interval->duration_frames) { > - if (frame_count >= interval->end) > + if (frame_count >= interval->end) { > + needs_unref = 1; > break; > + } > } else if (has_end && *cur_ts != AV_NOPTS_VALUE && *cur_ts >= end) { > + needs_unref = 1; > break; > } > > @@ -2429,6 +2433,10 @@ static int read_interval_packets(WriterContext *w, InputFile *ifile, > } > av_packet_unref(&pkt); > } > + > + if (needs_unref) > + av_packet_unref(&pkt); Why not just call this unconditionally instead of the init() + zero below? > + > av_init_packet(&pkt); > pkt.data = NULL; > pkt.size = 0; >
On 21/06/2019 14:46, James Almer wrote:
> Why not just call this unconditionally instead of the init() + zero below?
I wasn't sure from a quick skim if these packets were
referenced elsewhere (and thus unrefercing twice would
be problematic).
If it's safe to do so, I will.
- Derel
On 6/21/2019 11:13 AM, Derek Buitenhuis wrote: > On 21/06/2019 14:46, James Almer wrote: >> Why not just call this unconditionally instead of the init() + zero below? > > I wasn't sure from a quick skim if these packets were > referenced elsewhere (and thus unrefercing twice would > be problematic). Unreferencing a packet cleans the struct, so calling unref() on it again is basically a no-op. > > If it's safe to do so, I will. > > - Derel > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". >
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 3becb6330e..52f24e7dfd 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -2351,6 +2351,7 @@ static int read_interval_packets(WriterContext *w, InputFile *ifile, int ret = 0, i = 0, frame_count = 0; int64_t start = -INT64_MAX, end = interval->end; int has_start = 0, has_end = interval->has_end && !interval->end_is_offset; + int needs_unref = 0; av_init_packet(&pkt); @@ -2410,9 +2411,12 @@ static int read_interval_packets(WriterContext *w, InputFile *ifile, } if (interval->end_is_offset && interval->duration_frames) { - if (frame_count >= interval->end) + if (frame_count >= interval->end) { + needs_unref = 1; break; + } } else if (has_end && *cur_ts != AV_NOPTS_VALUE && *cur_ts >= end) { + needs_unref = 1; break; } @@ -2429,6 +2433,10 @@ static int read_interval_packets(WriterContext *w, InputFile *ifile, } av_packet_unref(&pkt); } + + if (needs_unref) + av_packet_unref(&pkt); + av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0;
This packet was not necessarily unreferenced. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> --- fftools/ffprobe.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)