mirror of https://git.ffmpeg.org/ffmpeg.git
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>
This commit is contained in:
parent
5c95af6b7c
commit
9fdc2c7bc4
|
@ -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;
|
||||
|
||||
if (size || flush) {
|
||||
av_init_packet(&out_pkt);
|
||||
|
||||
if (!size && !flush && st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) {
|
||||
} 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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue