fixed crashes in videocapture and videowriter on Ubuntu 11.10
This commit is contained in:
parent
4e51c38fa3
commit
8521f8a5ec
@ -146,7 +146,6 @@ void Core_EigenTest_Scalar_32::run(int)
|
||||
float value = cv::randu<float>();
|
||||
cv::Mat src(1, 1, CV_32FC1, Scalar::all((float)value));
|
||||
test_values(src);
|
||||
src.~Mat();
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,7 +157,6 @@ void Core_EigenTest_Scalar_64::run(int)
|
||||
float value = cv::randu<float>();
|
||||
cv::Mat src(1, 1, CV_64FC1, Scalar::all((double)value));
|
||||
test_values(src);
|
||||
src.~Mat();
|
||||
}
|
||||
}
|
||||
|
||||
@ -401,8 +399,6 @@ bool Core_EigenTest::check_full(int type)
|
||||
else src.at<double>(k, j) = src.at<double>(j, k) = cv::randu<double>();
|
||||
|
||||
if (!test_values(src)) return false;
|
||||
|
||||
src.~Mat();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -313,7 +313,7 @@ void CvCapture_FFMPEG::close()
|
||||
*/
|
||||
bool CvCapture_FFMPEG::reopen()
|
||||
{
|
||||
if ( filename==NULL ) return false;
|
||||
/*if ( filename==NULL ) return false;
|
||||
|
||||
#if LIBAVFORMAT_BUILD > 4628
|
||||
avcodec_close( video_st->codec );
|
||||
@ -322,12 +322,12 @@ bool CvCapture_FFMPEG::reopen()
|
||||
#endif
|
||||
#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(53, 24, 2)
|
||||
av_close_input_file(ic);
|
||||
av_open_input_file(&ic, filename, )
|
||||
#else
|
||||
avformat_close_input(&ic);
|
||||
avformat_open_input(&ic, filename, NULL, NULL);
|
||||
#endif
|
||||
|
||||
// reopen video
|
||||
avformat_open_input(&ic, filename, NULL, NULL);
|
||||
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 6, 0)
|
||||
#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(53, 24, 2)
|
||||
avformat_find_stream_info(ic);
|
||||
@ -357,7 +357,7 @@ bool CvCapture_FFMPEG::reopen()
|
||||
|
||||
// reset framenumber to zero
|
||||
frame_number = 0;
|
||||
picture_pts=0;
|
||||
picture_pts=0;*/
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -454,7 +454,7 @@ bool CvCapture_FFMPEG::open( const char* _filename )
|
||||
if(video_stream >= 0) valid = true;
|
||||
|
||||
// perform check if source is seekable via ffmpeg's seek function av_seek_frame(...)
|
||||
err = av_seek_frame(ic, video_stream, 10, 0);
|
||||
/*err = av_seek_frame(ic, video_stream, 10, 0);
|
||||
if (err < 0)
|
||||
{
|
||||
filename=(char*)malloc(strlen(_filename)+1);
|
||||
@ -470,7 +470,7 @@ bool CvCapture_FFMPEG::open( const char* _filename )
|
||||
int64_t ts = video_st->first_dts;
|
||||
int flags = AVSEEK_FLAG_FRAME | AVSEEK_FLAG_BACKWARD;
|
||||
av_seek_frame(ic, video_stream, ts, flags);
|
||||
}
|
||||
}*/
|
||||
exit_func:
|
||||
|
||||
if( !valid )
|
||||
@ -611,8 +611,8 @@ double CvCapture_FFMPEG::getProperty( int property_id )
|
||||
if( !video_st ) return 0;
|
||||
|
||||
// double frameScale = av_q2d (video_st->time_base) * av_q2d (video_st->r_frame_rate);
|
||||
int64_t timestamp;
|
||||
timestamp = picture_pts;
|
||||
//int64_t timestamp;
|
||||
//timestamp = picture_pts;
|
||||
|
||||
switch( property_id )
|
||||
{
|
||||
@ -829,6 +829,7 @@ struct CvVideoWriter_FFMPEG
|
||||
AVStream * video_st;
|
||||
int input_pix_fmt;
|
||||
Image_FFMPEG temp_image;
|
||||
bool ok;
|
||||
#if defined(HAVE_FFMPEG_SWSCALE)
|
||||
struct SwsContext *img_convert_ctx;
|
||||
#endif
|
||||
@ -908,6 +909,7 @@ void CvVideoWriter_FFMPEG::init()
|
||||
#if defined(HAVE_FFMPEG_SWSCALE)
|
||||
img_convert_ctx = 0;
|
||||
#endif
|
||||
ok = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1228,7 +1230,8 @@ void CvVideoWriter_FFMPEG::close()
|
||||
// TODO -- do we need to account for latency here?
|
||||
|
||||
/* write the trailer, if any */
|
||||
av_write_trailer(oc);
|
||||
if(ok && oc)
|
||||
av_write_trailer(oc);
|
||||
|
||||
// free pictures
|
||||
#if LIBAVFORMAT_BUILD > 4628
|
||||
@ -1477,8 +1480,14 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
|
||||
}
|
||||
|
||||
/* write the stream header, if any */
|
||||
avformat_write_header(oc, NULL);
|
||||
|
||||
err=avformat_write_header(oc, NULL);
|
||||
if(err < 0)
|
||||
{
|
||||
close();
|
||||
remove(filename);
|
||||
return false;
|
||||
}
|
||||
ok = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -433,8 +433,6 @@ void CV_HighGuiTest::SpecificVideoFileTest(const string& dir, const char codecch
|
||||
writer << img;
|
||||
}
|
||||
|
||||
writer.~VideoWriter();
|
||||
|
||||
cv::VideoCapture cap(video_file);
|
||||
|
||||
size_t FRAME_COUNT = (size_t)cap.get(CV_CAP_PROP_FRAME_COUNT);
|
||||
@ -492,8 +490,6 @@ void CV_HighGuiTest::SpecificVideoFileTest(const string& dir, const char codecch
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cap.~VideoCapture();
|
||||
}
|
||||
}
|
||||
|
||||
@ -556,9 +552,6 @@ void CV_HighGuiTest::SpecificVideoCameraTest(const string& dir, const char codec
|
||||
if (framecount == IMAGE_COUNT) break;
|
||||
}
|
||||
|
||||
frame.~Mat();
|
||||
writer.~VideoWriter();
|
||||
|
||||
cv::VideoCapture vcap(dir+"video_"+string(&codecchars[0], 4)+"."+ext[i]);
|
||||
|
||||
if (!vcap.isOpened())
|
||||
@ -613,12 +606,7 @@ void CV_HighGuiTest::SpecificVideoCameraTest(const string& dir, const char codec
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
img.~Mat();
|
||||
vcap.~VideoCapture();
|
||||
}
|
||||
|
||||
cap.~VideoCapture();
|
||||
}
|
||||
|
||||
void CV_ImageTest::run(int)
|
||||
|
@ -61,6 +61,9 @@ void CV_PositioningTest::CreateTestVideo(const string& format, int codec, int fr
|
||||
{
|
||||
stringstream s; s << codec;
|
||||
|
||||
if( format == "mov" && codec == CV_FOURCC('M', 'P', 'G', '2'))
|
||||
putchar('$');
|
||||
|
||||
cv::VideoWriter writer("test_video_"+s.str()+"."+format, codec, 25, cv::Size(640, 480), false);
|
||||
|
||||
for (int i = 0; i < framecount; ++i)
|
||||
@ -95,8 +98,6 @@ void CV_PositioningTest::CreateTestVideo(const string& format, int codec, int fr
|
||||
|
||||
writer << mat;
|
||||
}
|
||||
|
||||
writer.~VideoWriter();
|
||||
}
|
||||
|
||||
void CV_PositioningTest::run(int)
|
||||
|
Loading…
x
Reference in New Issue
Block a user