ffplay, avcodec, avformat: Don't initialize before av_packet_ref()

It already initializes the packet.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2019-12-01 10:04:02 +01:00
parent c52ec0367d
commit 3362330741
6 changed files with 7 additions and 9 deletions

View File

@ -2977,7 +2977,7 @@ static int read_thread(void *arg)
} }
if (is->queue_attachments_req) { if (is->queue_attachments_req) {
if (is->video_st && is->video_st->disposition & AV_DISPOSITION_ATTACHED_PIC) { if (is->video_st && is->video_st->disposition & AV_DISPOSITION_ATTACHED_PIC) {
AVPacket copy = { 0 }; AVPacket copy;
if ((ret = av_packet_ref(&copy, &is->video_st->attached_pic)) < 0) if ((ret = av_packet_ref(&copy, &is->video_st->attached_pic)) < 0)
goto fail; goto fail;
packet_queue_put(&is->videoq, &copy); packet_queue_put(&is->videoq, &copy);

View File

@ -125,7 +125,7 @@ static int qsv_decode_frame(AVCodecContext *avctx, void *data,
/* buffer the input packet */ /* buffer the input packet */
if (avpkt->size) { if (avpkt->size) {
AVPacket input_ref = { 0 }; AVPacket input_ref;
if (av_fifo_space(s->packet_fifo) < sizeof(input_ref)) { if (av_fifo_space(s->packet_fifo) < sizeof(input_ref)) {
ret = av_fifo_realloc2(s->packet_fifo, ret = av_fifo_realloc2(s->packet_fifo,

View File

@ -123,7 +123,7 @@ static int qsv_decode_frame(AVCodecContext *avctx, void *data,
/* buffer the input packet */ /* buffer the input packet */
if (avpkt->size) { if (avpkt->size) {
AVPacket input_ref = { 0 }; AVPacket input_ref;
if (av_fifo_space(s->packet_fifo) < sizeof(input_ref)) { if (av_fifo_space(s->packet_fifo) < sizeof(input_ref)) {
ret = av_fifo_realloc2(s->packet_fifo, ret = av_fifo_realloc2(s->packet_fifo,

View File

@ -536,7 +536,6 @@ static int fifo_write_packet(AVFormatContext *avf, AVPacket *pkt)
int ret; int ret;
if (pkt) { if (pkt) {
av_init_packet(&msg.pkt);
ret = av_packet_ref(&msg.pkt,pkt); ret = av_packet_ref(&msg.pkt,pkt);
if (ret < 0) if (ret < 0)
return ret; return ret;

View File

@ -78,7 +78,7 @@ static int write_muxed_file(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
VideoMuxData *img = s->priv_data; VideoMuxData *img = s->priv_data;
AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar; AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
AVStream *st; AVStream *st;
AVPacket pkt2 = {0}; AVPacket pkt2;
AVFormatContext *fmt = NULL; AVFormatContext *fmt = NULL;
int ret; int ret;
@ -88,8 +88,8 @@ static int write_muxed_file(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
return ret; return ret;
st = avformat_new_stream(fmt, NULL); st = avformat_new_stream(fmt, NULL);
if (!st) { if (!st) {
avformat_free_context(fmt); ret = AVERROR(ENOMEM);
return AVERROR(ENOMEM); goto out;
} }
st->id = pkt->stream_index; st->id = pkt->stream_index;
@ -105,8 +105,8 @@ static int write_muxed_file(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
(ret = av_interleaved_write_frame(fmt, &pkt2)) < 0 || (ret = av_interleaved_write_frame(fmt, &pkt2)) < 0 ||
(ret = av_write_trailer(fmt))) {} (ret = av_write_trailer(fmt))) {}
out:
av_packet_unref(&pkt2); av_packet_unref(&pkt2);
out:
avformat_free_context(fmt); avformat_free_context(fmt);
return ret; return ret;
} }

View File

@ -564,7 +564,6 @@ static int tee_write_packet(AVFormatContext *avf, AVPacket *pkt)
if (s2 < 0) if (s2 < 0)
continue; continue;
memset(&pkt2, 0, sizeof(AVPacket));
if ((ret = av_packet_ref(&pkt2, pkt)) < 0) if ((ret = av_packet_ref(&pkt2, pkt)) < 0)
if (!ret_all) { if (!ret_all) {
ret_all = ret; ret_all = ret;