Skip to content

Commit

Permalink
avformat: Always return ref-counted AVPacket
Browse files Browse the repository at this point in the history
And drop the av_dup_packet from the input_thread.
  • Loading branch information
lu-zero committed Oct 26, 2015
1 parent f0ca6ff commit a5d4204
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion avconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2130,7 +2130,6 @@ static void *input_thread(void *arg)
while (!av_fifo_space(f->fifo))
pthread_cond_wait(&f->fifo_cond, &f->fifo_lock);

av_dup_packet(&pkt);
av_fifo_generic_write(f->fifo, &pkt, sizeof(pkt), NULL);

pthread_mutex_unlock(&f->fifo_lock);
Expand Down
4 changes: 0 additions & 4 deletions avplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,6 @@ static int packet_queue_put(PacketQueue *q, AVPacket *pkt)
{
AVPacketList *pkt1;

/* duplicate the packet */
if (pkt != &flush_pkt && av_dup_packet(pkt) < 0)
return -1;

pkt1 = av_malloc(sizeof(AVPacketList));
if (!pkt1)
return -1;
Expand Down
8 changes: 8 additions & 0 deletions libavformat/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,14 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
continue;
}

if (!pkt->buf) {
AVPacket tmp = { 0 };
ret = av_packet_ref(&tmp, pkt);
if (ret < 0)
return ret;
*pkt = tmp;
}

if ((s->flags & AVFMT_FLAG_DISCARD_CORRUPT) &&
(pkt->flags & AV_PKT_FLAG_CORRUPT)) {
av_log(s, AV_LOG_WARNING,
Expand Down

0 comments on commit a5d4204

Please sign in to comment.