packet needs to be both unref'd and freed when we use av_malloc to allocate a packet
parent
32d145cf2e
commit
984394f920
|
@ -566,6 +566,7 @@ int FfmpegCamera::CaptureAndRecord( Image &image, bool recording, char* event_fi
|
|||
// We are now allocating dynamically because we need to queue these and may go out of scope.
|
||||
AVPacket *packet = (AVPacket *)av_malloc(sizeof(AVPacket));
|
||||
av_init_packet( packet );
|
||||
|
||||
Debug(5, "Before av_read_frame");
|
||||
ret = av_read_frame( mFormatContext, packet );
|
||||
Debug(5, "After av_read_frame (%d)", ret );
|
||||
|
@ -649,6 +650,7 @@ Debug(5, "After av_read_frame (%d)", ret );
|
|||
//Less than zero and we skipped a frame
|
||||
}
|
||||
zm_av_unref_packet( queued_packet );
|
||||
av_free( queued_packet );
|
||||
} // end while packets in the packetqueue
|
||||
Debug(2, "Wrote %d queued packets", packet_count );
|
||||
} // end if ! wasRecording
|
||||
|
@ -748,8 +750,10 @@ Debug(5, "After av_read_frame (%d)", ret );
|
|||
Debug( 3, "Some other stream index %d", packet->stream_index );
|
||||
#endif
|
||||
}
|
||||
if ( videoStore )
|
||||
zm_av_unref_packet( packet );
|
||||
if ( videoStore ) {
|
||||
zm_av_unref_packet( packet );
|
||||
av_free( packet );
|
||||
}
|
||||
} // end while ! frameComplete
|
||||
return (frameCount);
|
||||
}
|
||||
|
|
|
@ -37,11 +37,13 @@ bool zm_packetqueue::queuePacket( AVPacket* packet ) {
|
|||
|
||||
//AVPacket *input_ref = (AVPacket *)av_malloc(sizeof(AVPacket));
|
||||
//if ( av_packet_ref( input_ref, packet ) < 0 ) {
|
||||
if ( 0 ) {
|
||||
if ( av_packet_ref( packet, packet ) < 0 ) {
|
||||
Error("error refing packet");
|
||||
//av_free_packet(input_ref);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
pktQueue.push( packet );
|
||||
//pktQueue.push( input_ref );
|
||||
|
@ -68,6 +70,7 @@ void zm_packetqueue::clearQueue() {
|
|||
pktQueue.pop();
|
||||
// If we clear it, then no freeing gets done, whereas when we pop off, we assume that the packet was freed somewhere else.
|
||||
zm_av_unref_packet( packet );
|
||||
av_free( packet );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue