Commit 9fdc2c7b authored by Andreas Rheinhardt's avatar Andreas Rheinhardt Committed by James Almer

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: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
parent 5c95af6b
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment