From 0ced1dd5dbd127aa9a7b9d623886d71c1c567c3a Mon Sep 17 00:00:00 2001 From: Max Krummenacher Date: Tue, 31 Mar 2015 19:06:31 +0200 Subject: opencv: update patches for libav 10.x API --- ...-drop-support-for-very-old-libav-versions.patch | 87 +++++++++++----------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/recipes-support/opencv/opencv/0001-cap_ffmpeg-drop-support-for-very-old-libav-versions.patch b/recipes-support/opencv/opencv/0001-cap_ffmpeg-drop-support-for-very-old-libav-versions.patch index 622d39c..ab3bdb5 100644 --- a/recipes-support/opencv/opencv/0001-cap_ffmpeg-drop-support-for-very-old-libav-versions.patch +++ b/recipes-support/opencv/opencv/0001-cap_ffmpeg-drop-support-for-very-old-libav-versions.patch @@ -1,4 +1,4 @@ -From db36d3abccf02242459419919619bad2fdb5ea24 Mon Sep 17 00:00:00 2001 +From cec2fadb85c35f1e9405c7f118b482f8ed2b8c07 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 6 Feb 2014 09:28:07 +0100 Subject: [PATCH 1/5] cap_ffmpeg: drop support for very old libav* versions @@ -15,7 +15,7 @@ Conflicts: 1 file changed, 27 insertions(+), 267 deletions(-) diff --git a/modules/highgui/src/cap_ffmpeg_impl.hpp b/modules/highgui/src/cap_ffmpeg_impl.hpp -index 2b18559..c0a4882 100644 +index e7a48d5..90fe428 100644 --- a/modules/highgui/src/cap_ffmpeg_impl.hpp +++ b/modules/highgui/src/cap_ffmpeg_impl.hpp @@ -61,6 +61,8 @@ extern "C" { @@ -49,7 +49,7 @@ index 2b18559..c0a4882 100644 SYSTEM_INFO sysinfo; GetSystemInfo( &sysinfo ); -@@ -296,25 +292,13 @@ void CvCapture_FFMPEG::close() +@@ -312,25 +308,13 @@ void CvCapture_FFMPEG::close() if( video_st ) { @@ -75,7 +75,7 @@ index 2b18559..c0a4882 100644 } if( rgb_picture.data[0] ) -@@ -501,9 +485,7 @@ public: +@@ -523,9 +507,7 @@ public: _mutex.lock(); if (!_initialized) { @@ -85,19 +85,20 @@ index 2b18559..c0a4882 100644 /* register all codecs, demux and protocols */ av_register_all(); -@@ -534,11 +516,7 @@ bool CvCapture_FFMPEG::open( const char* _filename ) +@@ -556,12 +538,8 @@ bool CvCapture_FFMPEG::open( const char* _filename ) close(); -#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(52, 111, 0) - int err = avformat_open_input(&ic, _filename, NULL, NULL); + av_dict_set(&dict, "rtsp_transport", "tcp", 0); + int err = avformat_open_input(&ic, _filename, NULL, &dict); -#else - int err = av_open_input_file(&ic, _filename, NULL, 0, NULL); -#endif if (err < 0) { -@@ -546,11 +524,7 @@ bool CvCapture_FFMPEG::open( const char* _filename ) +@@ -569,11 +547,7 @@ bool CvCapture_FFMPEG::open( const char* _filename ) goto exit_func; } err = @@ -109,7 +110,7 @@ index 2b18559..c0a4882 100644 if (err < 0) { CV_WARN("Could not find codec parameters"); -@@ -558,11 +532,7 @@ bool CvCapture_FFMPEG::open( const char* _filename ) +@@ -581,11 +555,7 @@ bool CvCapture_FFMPEG::open( const char* _filename ) } for(i = 0; i < ic->nb_streams; i++) { @@ -121,7 +122,7 @@ index 2b18559..c0a4882 100644 //#ifdef FF_API_THREAD_INIT // avcodec_thread_init(enc, get_number_of_cpus()); -@@ -570,10 +540,6 @@ bool CvCapture_FFMPEG::open( const char* _filename ) +@@ -593,10 +563,6 @@ bool CvCapture_FFMPEG::open( const char* _filename ) enc->thread_count = get_number_of_cpus(); //#endif @@ -132,7 +133,7 @@ index 2b18559..c0a4882 100644 if( AVMEDIA_TYPE_VIDEO == enc->codec_type && video_stream < 0) { // backup encoder' width/height -@@ -581,13 +547,7 @@ bool CvCapture_FFMPEG::open( const char* _filename ) +@@ -604,13 +570,7 @@ bool CvCapture_FFMPEG::open( const char* _filename ) int enc_height = enc->height; AVCodec *codec = avcodec_find_decoder(enc->codec_id); @@ -147,7 +148,7 @@ index 2b18559..c0a4882 100644 goto exit_func; // checking width/height (since decoder can sometimes alter it, eg. vp6f) -@@ -660,17 +620,7 @@ bool CvCapture_FFMPEG::grabFrame() +@@ -683,17 +643,7 @@ bool CvCapture_FFMPEG::grabFrame() } // Decode video frame @@ -165,7 +166,7 @@ index 2b18559..c0a4882 100644 // Did we get a video frame? if(got_picture) -@@ -769,18 +719,9 @@ double CvCapture_FFMPEG::getProperty( int property_id ) +@@ -792,18 +742,9 @@ double CvCapture_FFMPEG::getProperty( int property_id ) case CV_FFMPEG_CAP_PROP_FRAME_HEIGHT: return (double)frame.height; case CV_FFMPEG_CAP_PROP_FPS: @@ -184,7 +185,7 @@ index 2b18559..c0a4882 100644 default: break; } -@@ -819,12 +760,10 @@ double CvCapture_FFMPEG::get_fps() +@@ -842,12 +783,10 @@ double CvCapture_FFMPEG::get_fps() { double fps = r2d(ic->streams[video_stream]->r_frame_rate); @@ -197,7 +198,7 @@ index 2b18559..c0a4882 100644 if (fps < eps_zero) { -@@ -984,7 +923,6 @@ struct CvVideoWriter_FFMPEG +@@ -1007,7 +946,6 @@ struct CvVideoWriter_FFMPEG static const char * icvFFMPEGErrStr(int err) { @@ -205,7 +206,7 @@ index 2b18559..c0a4882 100644 switch(err) { case AVERROR_BSF_NOT_FOUND: return "Bitstream filter not found"; -@@ -1015,22 +953,6 @@ static const char * icvFFMPEGErrStr(int err) +@@ -1038,22 +976,6 @@ static const char * icvFFMPEGErrStr(int err) default: break; } @@ -228,7 +229,7 @@ index 2b18559..c0a4882 100644 return "Unspecified error"; } -@@ -1098,28 +1020,16 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc, +@@ -1121,28 +1043,16 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc, int frame_rate, frame_rate_base; AVCodec *codec; @@ -257,7 +258,7 @@ index 2b18559..c0a4882 100644 if(codec_id != CV_CODEC(CODEC_ID_NONE)){ c->codec_id = codec_id; -@@ -1154,7 +1064,6 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc, +@@ -1177,7 +1087,6 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc, frame_rate_base*=10; frame_rate=(int)(fps*frame_rate_base + 0.5); } @@ -265,7 +266,7 @@ index 2b18559..c0a4882 100644 c->time_base.den = frame_rate; c->time_base.num = frame_rate_base; /* adjust time base for supported framerates */ -@@ -1174,10 +1083,6 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc, +@@ -1197,10 +1106,6 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc, c->time_base.den= best->num; c->time_base.num= best->den; } @@ -276,7 +277,7 @@ index 2b18559..c0a4882 100644 c->gop_size = 12; /* emit one intra frame every twelve frames at most */ c->pix_fmt = (PixelFormat) pixel_format; -@@ -1192,13 +1097,25 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc, +@@ -1215,13 +1120,25 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc, /* avoid FFMPEG warning 'clipping 1 dct coefficients...' */ c->mb_decision=2; } @@ -304,7 +305,7 @@ index 2b18559..c0a4882 100644 return st; } -@@ -1207,11 +1124,7 @@ static const int OPENCV_NO_FRAMES_WRITTEN_CODE = 1000; +@@ -1230,11 +1147,7 @@ static const int OPENCV_NO_FRAMES_WRITTEN_CODE = 1000; static int icv_av_write_frame_FFMPEG( AVFormatContext * oc, AVStream * video_st, uint8_t * outbuf, uint32_t outbuf_size, AVFrame * picture ) { @@ -316,7 +317,7 @@ index 2b18559..c0a4882 100644 int out_size; int ret = 0; -@@ -1239,12 +1152,8 @@ static int icv_av_write_frame_FFMPEG( AVFormatContext * oc, AVStream * video_st, +@@ -1262,12 +1175,8 @@ static int icv_av_write_frame_FFMPEG( AVFormatContext * oc, AVStream * video_st, AVPacket pkt; av_init_packet(&pkt); @@ -329,7 +330,7 @@ index 2b18559..c0a4882 100644 if(c->coded_frame->key_frame) pkt.flags |= PKT_FLAG_KEY; pkt.stream_index= video_st->index; -@@ -1271,30 +1180,8 @@ bool CvVideoWriter_FFMPEG::writeFrame( const unsigned char* data, int step, int +@@ -1294,30 +1203,8 @@ bool CvVideoWriter_FFMPEG::writeFrame( const unsigned char* data, int step, int height = frame_height; // typecast from opaque data type to implemented struct @@ -360,7 +361,7 @@ index 2b18559..c0a4882 100644 if( width*cn != step ) { if( !temp_image.data ) -@@ -1314,7 +1201,6 @@ bool CvVideoWriter_FFMPEG::writeFrame( const unsigned char* data, int step, int +@@ -1337,7 +1224,6 @@ bool CvVideoWriter_FFMPEG::writeFrame( const unsigned char* data, int step, int data = temp_image.data; step = temp_image.step; } @@ -368,7 +369,7 @@ index 2b18559..c0a4882 100644 // check parameters if (input_pix_fmt == PIX_FMT_BGR24) { -@@ -1401,11 +1287,7 @@ void CvVideoWriter_FFMPEG::close() +@@ -1424,11 +1310,7 @@ void CvVideoWriter_FFMPEG::close() } // free pictures @@ -380,7 +381,7 @@ index 2b18559..c0a4882 100644 { if(picture->data[0]) free(picture->data[0]); -@@ -1417,11 +1299,7 @@ void CvVideoWriter_FFMPEG::close() +@@ -1440,11 +1322,7 @@ void CvVideoWriter_FFMPEG::close() av_free(input_picture); /* close codec */ @@ -392,7 +393,7 @@ index 2b18559..c0a4882 100644 av_free(outbuf); -@@ -1429,15 +1307,7 @@ void CvVideoWriter_FFMPEG::close() +@@ -1452,15 +1330,7 @@ void CvVideoWriter_FFMPEG::close() { /* close the output file */ @@ -408,7 +409,7 @@ index 2b18559..c0a4882 100644 } -@@ -1479,11 +1349,7 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, +@@ -1502,11 +1372,7 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, /* auto detect the output format from the name and fourcc code. */ @@ -420,7 +421,7 @@ index 2b18559..c0a4882 100644 if (!fmt) return false; -@@ -1497,21 +1363,12 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, +@@ -1520,21 +1386,12 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, } /* Lookup codec_id for given fourcc */ @@ -442,7 +443,7 @@ index 2b18559..c0a4882 100644 assert (oc); /* set file name */ -@@ -1523,12 +1380,10 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, +@@ -1546,12 +1403,10 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, // set a few optimal pixel formats for lossless codecs of interest.. switch (codec_id) { @@ -455,7 +456,7 @@ index 2b18559..c0a4882 100644 case CV_CODEC(CODEC_ID_HUFFYUV): codec_pix_fmt = PIX_FMT_YUV422P; break; -@@ -1555,14 +1410,6 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, +@@ -1578,14 +1433,6 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, width, height, (int)(bitrate + 0.5), fps, codec_pix_fmt); @@ -470,7 +471,7 @@ index 2b18559..c0a4882 100644 #if 0 #if FF_API_DUMP_FORMAT dump_format(oc, 0, filename, 1); -@@ -1580,23 +1427,14 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, +@@ -1603,23 +1450,14 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, AVCodec *codec; AVCodecContext *c; @@ -495,7 +496,7 @@ index 2b18559..c0a4882 100644 return false; } -@@ -1607,13 +1445,7 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, +@@ -1630,13 +1468,7 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, c->bit_rate = (int)lbit_rate; /* open the codec */ @@ -510,7 +511,7 @@ index 2b18559..c0a4882 100644 fprintf(stderr, "Could not open codec '%s': %s", codec->name, icvFFMPEGErrStr(err)); return false; } -@@ -1649,22 +1481,14 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, +@@ -1672,22 +1504,14 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc, /* open the output file, if needed */ if (!(fmt->flags & AVFMT_NOFILE)) { @@ -533,7 +534,7 @@ index 2b18559..c0a4882 100644 if(err < 0) { -@@ -1799,15 +1623,7 @@ void OutputMediaStream_FFMPEG::close() +@@ -1822,15 +1646,7 @@ void OutputMediaStream_FFMPEG::close() { // close the output file @@ -550,7 +551,7 @@ index 2b18559..c0a4882 100644 } // free the stream -@@ -1817,19 +1633,11 @@ void OutputMediaStream_FFMPEG::close() +@@ -1840,19 +1656,11 @@ void OutputMediaStream_FFMPEG::close() AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC_ID codec_id, int w, int h, int bitrate, double fps, PixelFormat pixel_format) { @@ -570,7 +571,7 @@ index 2b18559..c0a4882 100644 c->codec_id = codec_id; c->codec_type = AVMEDIA_TYPE_VIDEO; -@@ -1865,7 +1673,6 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC +@@ -1888,7 +1696,6 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC c->time_base.den = frame_rate; c->time_base.num = frame_rate_base; @@ -578,7 +579,7 @@ index 2b18559..c0a4882 100644 // adjust time base for supported framerates if (codec && codec->supported_framerates) { -@@ -1890,7 +1697,6 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC +@@ -1913,7 +1720,6 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC c->time_base.den= best->num; c->time_base.num= best->den; } @@ -586,7 +587,7 @@ index 2b18559..c0a4882 100644 c->gop_size = 12; // emit one intra frame every twelve frames at most c->pix_fmt = pixel_format; -@@ -1909,13 +1715,11 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC +@@ -1932,13 +1738,11 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC c->mb_decision = 2; } @@ -600,7 +601,7 @@ index 2b18559..c0a4882 100644 return st; } -@@ -1927,22 +1731,14 @@ bool OutputMediaStream_FFMPEG::open(const char* fileName, int width, int height, +@@ -1950,22 +1754,14 @@ bool OutputMediaStream_FFMPEG::open(const char* fileName, int width, int height, video_st_ = 0; // auto detect the output format from the name and fourcc code @@ -623,7 +624,7 @@ index 2b18559..c0a4882 100644 if (!oc_) return false; -@@ -1961,20 +1757,10 @@ bool OutputMediaStream_FFMPEG::open(const char* fileName, int width, int height, +@@ -1984,20 +1780,10 @@ bool OutputMediaStream_FFMPEG::open(const char* fileName, int width, int height, if (!video_st_) return false; @@ -644,7 +645,7 @@ index 2b18559..c0a4882 100644 c->codec_tag = MKTAG('H', '2', '6', '4'); c->bit_rate_tolerance = c->bit_rate; -@@ -1982,22 +1768,14 @@ bool OutputMediaStream_FFMPEG::open(const char* fileName, int width, int height, +@@ -2005,22 +1791,14 @@ bool OutputMediaStream_FFMPEG::open(const char* fileName, int width, int height, // open the output file, if needed if (!(fmt_->flags & AVFMT_NOFILE)) { @@ -669,7 +670,7 @@ index 2b18559..c0a4882 100644 return true; } -@@ -2102,33 +1880,19 @@ bool InputMediaStream_FFMPEG::open(const char* fileName, int* codec, int* chroma +@@ -2125,33 +1903,19 @@ bool InputMediaStream_FFMPEG::open(const char* fileName, int* codec, int* chroma video_stream_id_ = -1; memset(&pkt_, 0, sizeof(AVPacket)); @@ -706,7 +707,7 @@ index 2b18559..c0a4882 100644 if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { -@@ -2197,11 +1961,7 @@ void InputMediaStream_FFMPEG::close() +@@ -2220,11 +1984,7 @@ void InputMediaStream_FFMPEG::close() { if (ctx_) { -- cgit v1.2.3