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