[Libav-user] Pb use av_new_packet

Jérôme SALAYET jerome.salayet at hymatom.fr
Thu Feb 14 11:50:34 CET 2013


Hello, I use av_init_packet in my code to decompress H264 streaming.

 

http://pastebin.com/sNpcpHjf <http://pastebin.com/sNpcpHjf> 

 

But it seems better for me to use av_new_packet because I don't have to use my lpFFMPEGBuffer. But When I try to replace in my code:

 

av_init_packet(&m_lpPacket);

if (m_lpFFMPEGBuffer == NULL)

{ m_lpFFMPEGBuffer = new BYTE[MAX_MPEG4VIDEO_FRAMESIZE+FF_INPUT_BUFFER_PADDING_SIZE];

}

 

if (m_lpFFMPEGBuffer !=NULL)

{ ZeroMemory( m_lpFFMPEGBuffer, MAX_MPEG4VIDEO_FRAMESIZE+FF_INPUT_BUFFER_PADDING_SIZE);

 

 CopyMemory( m_lpFFMPEGBuffer, lpImageData, dwImageSize);

 // Set the buffer to packet data

 m_lpPacket.data = m_lpFFMPEGBuffer;

 // Set the size to packet size

 m_lpPacket.size = dwImageSize;

}

 

By 

 

av_new_packet(&m_lpPacket, dwFrameSize)

CopyMemory( m_lpPacket.data , lpImageData, dwImageSize);

m_lpPacket.size = dwImageSize;

 

I have a crash when calling av_free_packet(&m_lpPacket). It seem the crash is in the av_destruct_packet.

If I don't call the avcodec_decode_video2 function, I don't have the crash. 

But if I use avcodec_decode_video2 and don't use the av_free_packet, I have a memory leak.

 

If someone can explain me,

Regards,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130214/047651ac/attachment.html>


More information about the Libav-user mailing list