Fixed compilation error under Ubuntu 11.10; added #if-#else-#endif code for some deprecated functions

pull/13383/head
Alexander Reshetnikov 13 years ago
parent c648de0e08
commit ab0fc84781
  1. 25
      modules/highgui/src/cap_ffmpeg_impl_v2.hpp

@ -351,7 +351,11 @@ bool CvCapture_FFMPEG::reopen()
// reopen video // reopen video
avformat_open_input(&ic, filename, NULL, NULL); avformat_open_input(&ic, filename, NULL, NULL);
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 6, 0)
avformat_find_stream_info(ic);
#else
av_find_stream_info(ic); av_find_stream_info(ic);
#endif
#if LIBAVFORMAT_BUILD > 4628 #if LIBAVFORMAT_BUILD > 4628
AVCodecContext *enc = ic->streams[video_stream]->codec; AVCodecContext *enc = ic->streams[video_stream]->codec;
#else #else
@ -407,7 +411,12 @@ bool CvCapture_FFMPEG::open( const char* _filename )
CV_WARN("Error opening file"); CV_WARN("Error opening file");
goto exit_func; goto exit_func;
} }
err = av_find_stream_info(ic); err =
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 6, 0)
avformat_find_stream_info(ic);
#else
av_find_stream_info(ic);
#endif
if (err < 0) { if (err < 0) {
CV_WARN("Could not find codec parameters"); CV_WARN("Could not find codec parameters");
goto exit_func; goto exit_func;
@ -960,8 +969,12 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc,
int frame_rate, frame_rate_base; int frame_rate, frame_rate_base;
AVCodec *codec; AVCodec *codec;
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 10, 0)
st = avformat_new_stream(oc, 0); st = avformat_new_stream(oc, 0);
#else
st = av_new_stream(oc, 0);
#endif
if (!st) { if (!st) {
CV_WARN("Could not allocate stream"); CV_WARN("Could not allocate stream");
return NULL; return NULL;
@ -1427,7 +1440,13 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
c->bit_rate_tolerance = c->bit_rate; c->bit_rate_tolerance = c->bit_rate;
/* open the codec */ /* open the codec */
if ( (err=avcodec_open(c, codec)) < 0) { if ((err=
#if LIBAVCODEC_VERSION_INT >= ((53<<16)+(8<<8)+0)
avcodec_open2(c, codec, NULL)
#else
avcodec_open(c, codec)
#endif
) < 0) {
char errtext[256]; char errtext[256];
sprintf(errtext, "Could not open codec '%s': %s", codec->name, icvFFMPEGErrStr(err)); sprintf(errtext, "Could not open codec '%s': %s", codec->name, icvFFMPEGErrStr(err));
return false; return false;

Loading…
Cancel
Save