diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2019-09-20 22:39:16 +0200 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2019-09-28 18:32:44 -0300 |
commit | 9fdc2c7bc45b062457f3d58578e3a02dd945c9c4 (patch) | |
tree | d2b325d3bc24e55503a707698745e887426c521c /libavformat/utils.c | |
parent | 5c95af6b7c8ea7fa700f91e9ab55ef2713b6f02f (diff) | |
download | ffmpeg-9fdc2c7bc45b062457f3d58578e3a02dd945c9c4.tar.gz |
avformat/utils: Remove unnecessary initializations
Up until now, read_frame_internal always initialized the packet it
received. But since the recent changes to ff_read_packet, this is no
longer needed: If the parsing queue is initially empty upon entering
read_frame_internal, the packet will now either contain content upon
success or be blank upon failure of ff_read_packet. If the parsing
queue is initially not empty, the packet will be overwritten with the
oldest one from the parsing queue.
Similarly, it is unnecessary to initialize ret in read_frame_internal.
In parse_packet, it is easily possible to only initialize the packet
used as temporary storage for the output if said packet is used at all;
furthermore, this packet doesn't need to be zero-initialized, because
av_init_packet will initialize every field except size and data and
those fields will be set by av_parser_parse2.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 64c58baf5f..7545d75d5b 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1447,15 +1447,15 @@ void ff_packet_list_free(AVPacketList **pkt_buf, AVPacketList **pkt_buf_end) static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index, int flush) { - AVPacket out_pkt = { 0 }; + AVPacket out_pkt; AVStream *st = s->streams[stream_index]; uint8_t *data = pkt->data; int size = pkt->size; int ret = 0, got_output = flush; - av_init_packet(&out_pkt); - - if (!size && !flush && st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) { + if (size || flush) { + av_init_packet(&out_pkt); + } else if (st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) { // preserve 0-size sync packets compute_pkt_fields(s, st, st->parser, pkt, AV_NOPTS_VALUE, AV_NOPTS_VALUE); } @@ -1576,11 +1576,9 @@ static int64_t ts_to_samples(AVStream *st, int64_t ts) static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) { - int ret = 0, i, got_packet = 0; + int ret, i, got_packet = 0; AVDictionary *metadata = NULL; - av_init_packet(pkt); - while (!got_packet && !s->internal->parse_queue) { AVStream *st; |