ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinha...@gmail.com> | Fri Sep 20 22:39:11 2019 +0200| [47a4528abc9702da02b2115c4ad235e70138648a] | committer: James Almer
avformat/utils: Don't initialize in loops Since the recent changes to ff_packet_list_put, the source packet will be automatically reset when the reference is moved to the packet list, so that it is unnecessary to reinitialize the packet in the loops in parse_packet and ff_read_packet; initializing once at the beginning is enough. This also fixes a potential, but currently unexisting problem: If the raw packet buffer was initially not empty and probe_codec() failed, then the packet returned would not be initialized. But given that probe_codec() currently can't fail (always returns 0) this was not an acute danger. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@gmail.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=47a4528abc9702da02b2115c4ad235e70138648a --- libavformat/utils.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 9f8a5bfb63..3d42243805 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -835,6 +835,10 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt) int ret, i, err; AVStream *st; + pkt->data = NULL; + pkt->size = 0; + av_init_packet(pkt); + for (;;) { AVPacketList *pktl = s->internal->raw_packet_buffer; const AVPacket *pkt1; @@ -852,9 +856,6 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt) } } - pkt->data = NULL; - pkt->size = 0; - av_init_packet(pkt); ret = s->iformat->read_packet(s, pkt); if (ret < 0) { av_packet_unref(pkt); @@ -1450,6 +1451,8 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index) int size = pkt ? pkt->size : 0; int ret = 0, got_output = 0; + av_init_packet(&out_pkt); + if (!pkt) { av_init_packet(&flush_pkt); pkt = &flush_pkt; @@ -1464,7 +1467,6 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index) int64_t next_pts = pkt->pts; int64_t next_dts = pkt->dts; - av_init_packet(&out_pkt); len = av_parser_parse2(st->parser, st->internal->avctx, &out_pkt.data, &out_pkt.size, data, size, pkt->pts, pkt->dts, pkt->pos); _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".