[FFmpeg-devel] [PATCH] initialize pkt->data and pkt->size to NULL and zero

Thierry Foucu tfoucu
Fri Apr 30 18:57:07 CEST 2010


Here is the issue I found when debugging a AVI file:
The line number are based on SVN 22976

in av_find_stream_info (ic=0xf358020) at libavformat/utils.c:2210
   We are calling av_read_frame_internal with pkt1 which is a variable on
the stack (not initialize)

in av_read_frame_internal (s=0xf358020, pkt=0xffffcb64) at
libavformat/utils.c:1070
  When we enter av_read_frame_internal, we call  av_init_packet, which does
does set the pkt->data and pkt->size to zero
  Then we call av_read_packet with the same AVpacket.

in av_read_packet (s=0xf358020, pkt=0xffffc654) at libavformat/utils.c:638
  we are calling avi_read_packet with the same AVPacket pointer, which still
does not have the data and size set to

in avi_read_packet (s=0xf358020, pkt=0xffffc654) at libavformat/avidec.c:890
  Here we are adding to ast->frame_offset the pkt->size, which in this case,
it was not initialize. The pkt->data is NULL
  This will cause the ast->frame_offset for a audio packet to be wrong and
because we are using it for setting the DTS, we can get some first PTS value
to be 100% garbage.

By applying the patch, the ast->frame_offset will not be incremented by some
garbage value.

But not sure if this will be the right fix for this problem.

Index: libavcodec/avpacket.c
===================================================================
--- libavcodec/avpacket.c (revision 22976)
+++ libavcodec/avpacket.c (working copy)
@@ -43,6 +43,8 @@
     pkt->flags = 0;
     pkt->stream_index = 0;
     pkt->destruct= NULL;
+    pkt->data = NULL;
+    pkt->size = 0;
 }
-------------- next part --------------
Index: libavcodec/avpacket.c
===================================================================
--- libavcodec/avpacket.c	(revision 22976)
+++ libavcodec/avpacket.c	(working copy)
@@ -43,6 +43,8 @@
     pkt->flags = 0;
     pkt->stream_index = 0;
     pkt->destruct= NULL;
+    pkt->data = NULL;
+    pkt->size = 0;
 }
 
 int av_new_packet(AVPacket *pkt, int size)



More information about the ffmpeg-devel mailing list