fix segfault
This commit is contained in:
parent
82b30ef9d0
commit
028aa9f161
|
@ -859,7 +859,6 @@ int VideoStore::writePacket( ZMPacket *ipkt ) {
|
|||
}
|
||||
|
||||
int VideoStore::writeVideoFramePacket( ZMPacket * zm_packet ) {
|
||||
av_init_packet(&opkt);
|
||||
frame_count += 1;
|
||||
|
||||
// if we have to transcode
|
||||
|
@ -867,6 +866,7 @@ int VideoStore::writeVideoFramePacket( ZMPacket * zm_packet ) {
|
|||
Debug(3, "Have encoding video frame count (%d)", frame_count);
|
||||
|
||||
if ( ! zm_packet->frame ) {
|
||||
Debug(3, "Have no out frame");
|
||||
AVFrame *out_frame = zm_packet->frame = zm_av_frame_alloc();
|
||||
if ( ! out_frame ) {
|
||||
Error("Unable to allocate a frame");
|
||||
|
@ -906,15 +906,17 @@ int VideoStore::writeVideoFramePacket( ZMPacket * zm_packet ) {
|
|||
out_frame->format = video_out_ctx->pix_fmt;
|
||||
|
||||
if ( ! zm_packet->in_frame ) {
|
||||
Debug(2,"Have no in_frame");
|
||||
if ( zm_packet->packet.size ) {
|
||||
Debug(2,"Decoding");
|
||||
if ( ! zm_packet->decode( video_in_ctx ) ) {
|
||||
Debug(2, "unable to decode yet.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//Go straight to out frame
|
||||
swscale.Convert( zm_packet->in_frame, out_frame );
|
||||
} else if ( zm_packet->image ) {
|
||||
Debug(2,"Have an image, convert it");
|
||||
//Go straight to out frame
|
||||
swscale.Convert(zm_packet->image,
|
||||
zm_packet->buffer,
|
||||
|
@ -925,7 +927,11 @@ int VideoStore::writeVideoFramePacket( ZMPacket * zm_packet ) {
|
|||
video_out_ctx->height
|
||||
);
|
||||
|
||||
} else {
|
||||
Error("Have neither in_frame or image!");
|
||||
return 0;
|
||||
} // end if has packet or image
|
||||
} // end if no in_Frmae
|
||||
} // end if no frame
|
||||
|
||||
if ( ! video_last_pts ) {
|
||||
|
@ -940,9 +946,10 @@ int VideoStore::writeVideoFramePacket( ZMPacket * zm_packet ) {
|
|||
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
||||
if ( (ret = avcodec_send_frame(video_out_ctx, zm_packet->frame)) < 0 ) {
|
||||
Error("Could not send frame (error '%s')", av_make_error_string(ret).c_str());
|
||||
zm_av_packet_unref(&opkt); // NOT SURE THIS IS NECCESSARY
|
||||
return -1;
|
||||
}
|
||||
|
||||
av_init_packet(&opkt);
|
||||
if ( (ret = avcodec_receive_packet(video_out_ctx, &opkt)) < 0 ) {
|
||||
zm_av_packet_unref(&opkt);
|
||||
if ( AVERROR(EAGAIN) == ret ) {
|
||||
|
|
Loading…
Reference in New Issue