mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge pull request #3817 from SpecLad:forward-ports
This commit is contained in:
@@ -2651,7 +2651,6 @@ CV_IMPL CvFileStorage*
|
||||
cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, const char* encoding )
|
||||
{
|
||||
CvFileStorage* fs = 0;
|
||||
char* xml_buf = 0;
|
||||
int default_block_size = 1 << 18;
|
||||
bool append = (flags & 3) == CV_STORAGE_APPEND;
|
||||
bool mem = (flags & CV_STORAGE_MEMORY) != 0;
|
||||
@@ -2692,7 +2691,10 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co
|
||||
(dot_pos[3] == '\0' || (cv_isdigit(dot_pos[3]) && dot_pos[4] == '\0')) )
|
||||
{
|
||||
if( append )
|
||||
{
|
||||
cvReleaseFileStorage( &fs );
|
||||
CV_Error(CV_StsNotImplemented, "Appending data to compressed file is not implemented" );
|
||||
}
|
||||
isGZ = true;
|
||||
compression = dot_pos[3];
|
||||
if( compression )
|
||||
@@ -2713,6 +2715,7 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co
|
||||
if( !fs->gzfile )
|
||||
goto _exit_;
|
||||
#else
|
||||
cvReleaseFileStorage( &fs );
|
||||
CV_Error(CV_StsNotImplemented, "There is no compressed file storage support in this configuration");
|
||||
#endif
|
||||
}
|
||||
@@ -2765,7 +2768,10 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co
|
||||
if( strcmp( encoding, "UTF-16" ) == 0 ||
|
||||
strcmp( encoding, "utf-16" ) == 0 ||
|
||||
strcmp( encoding, "Utf-16" ) == 0 )
|
||||
{
|
||||
cvReleaseFileStorage( &fs );
|
||||
CV_Error( CV_StsBadArg, "UTF-16 XML encoding is not supported! Use 8-bit encoding\n");
|
||||
}
|
||||
|
||||
CV_Assert( strlen(encoding) < 1000 );
|
||||
char buf[1100];
|
||||
@@ -2783,7 +2789,7 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co
|
||||
int last_occurence = -1;
|
||||
xml_buf_size = MIN(xml_buf_size, int(file_size));
|
||||
fseek( fs->file, -xml_buf_size, SEEK_END );
|
||||
xml_buf = (char*)cvAlloc( xml_buf_size+2 );
|
||||
char* xml_buf = (char*)cvAlloc( xml_buf_size+2 );
|
||||
// find the last occurence of </opencv_storage>
|
||||
for(;;)
|
||||
{
|
||||
@@ -2801,8 +2807,12 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co
|
||||
ptr += strlen(substr);
|
||||
}
|
||||
}
|
||||
cvFree( &xml_buf );
|
||||
if( last_occurence < 0 )
|
||||
{
|
||||
cvReleaseFileStorage( &fs );
|
||||
CV_Error( CV_StsError, "Could not find </opencv_storage> in the end of file.\n" );
|
||||
}
|
||||
icvCloseFile( fs );
|
||||
fs->file = fopen( fs->filename, "r+t" );
|
||||
fseek( fs->file, last_occurence, SEEK_SET );
|
||||
@@ -2876,10 +2886,18 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co
|
||||
|
||||
//mode = cvGetErrMode();
|
||||
//cvSetErrMode( CV_ErrModeSilent );
|
||||
if( fs->fmt == CV_STORAGE_FORMAT_XML )
|
||||
icvXMLParse( fs );
|
||||
else
|
||||
icvYMLParse( fs );
|
||||
try
|
||||
{
|
||||
if( fs->fmt == CV_STORAGE_FORMAT_XML )
|
||||
icvXMLParse( fs );
|
||||
else
|
||||
icvYMLParse( fs );
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
cvReleaseFileStorage( &fs );
|
||||
throw;
|
||||
}
|
||||
//cvSetErrMode( mode );
|
||||
|
||||
// release resources that we do not need anymore
|
||||
@@ -2904,7 +2922,6 @@ _exit_:
|
||||
}
|
||||
}
|
||||
|
||||
cvFree( &xml_buf );
|
||||
return fs;
|
||||
}
|
||||
|
||||
|
||||
@@ -302,7 +302,15 @@ void CvCapture_FFMPEG::close()
|
||||
}
|
||||
|
||||
if( picture )
|
||||
{
|
||||
// FFmpeg and Libav added avcodec_free_frame in different versions.
|
||||
#if LIBAVCODEC_BUILD >= (LIBAVCODEC_VERSION_MICRO >= 100 \
|
||||
? CALC_FFMPEG_VERSION(54, 59, 100) : CALC_FFMPEG_VERSION(54, 28, 0))
|
||||
avcodec_free_frame(&picture);
|
||||
#else
|
||||
av_free(picture);
|
||||
#endif
|
||||
}
|
||||
|
||||
if( video_st )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user