From ed358224e863f43060f7532dfcbb8bc4a28039c9 Mon Sep 17 00:00:00 2001 From: Jakub Bogusz Date: Wed, 29 Jun 2011 16:59:52 +0000 Subject: [PATCH] - added gcc patch (fixes build with gcc 4.6) - added ffmpeg-0.8 patch (ffmpeg API updates) - disable all v4l support by default for now (V4L2 code heavily depends on V4L1 being enabled) Changed files: opencv-ffmpeg-0.8.patch -> 1.1 opencv-gcc.patch -> 1.1 opencv.spec -> 1.28 --- opencv-ffmpeg-0.8.patch | 104 ++++++++++++++++++++++++++++++++++++++++ opencv-gcc.patch | 10 ++++ opencv.spec | 8 +++- 3 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 opencv-ffmpeg-0.8.patch create mode 100644 opencv-gcc.patch diff --git a/opencv-ffmpeg-0.8.patch b/opencv-ffmpeg-0.8.patch new file mode 100644 index 0000000..f849dd2 --- /dev/null +++ b/opencv-ffmpeg-0.8.patch @@ -0,0 +1,104 @@ +--- OpenCV-2.2.0/modules/highgui/src/cap_ffmpeg.cpp.orig 2010-12-05 04:35:25.000000000 +0100 ++++ OpenCV-2.2.0/modules/highgui/src/cap_ffmpeg.cpp 2011-06-29 16:24:22.527412497 +0200 +@@ -466,7 +466,7 @@ + AVCodecContext *enc = &ic->streams[i]->codec; + #endif + +- if( CODEC_TYPE_VIDEO == enc->codec_type && video_stream < 0) { ++ if( AVMEDIA_TYPE_VIDEO == enc->codec_type && video_stream < 0) { + AVCodec *codec = avcodec_find_decoder(enc->codec_id); + if (!codec || + avcodec_open(enc, codec) < 0) +@@ -551,9 +551,16 @@ + } + + #if LIBAVFORMAT_BUILD > 4628 +- avcodec_decode_video(video_st->codec, ++ { ++ AVPacket avpkt; ++ av_init_packet(&avpkt); ++ avpkt.data = packet.data; ++ avpkt.size = packet.size; ++ avpkt.flags = AV_PKT_FLAG_KEY; ++ avcodec_decode_video2(video_st->codec, + picture, &got_picture, +- packet.data, packet.size); ++ &avpkt); ++ } + #else + avcodec_decode_video(&video_st->codec, + picture, &got_picture, +@@ -806,15 +813,15 @@ + static const char * icvFFMPEGErrStr(int err) + { + switch(err) { +- case AVERROR_NUMEXPECTED: ++ case AVERROR(EINVAL): + return "Incorrect filename syntax"; + case AVERROR_INVALIDDATA: + return "Invalid data in header"; +- case AVERROR_NOFMT: ++ case AVERROR(EILSEQ): + return "Unknown format"; +- case AVERROR_IO: ++ case AVERROR(EIO): + return "I/O error occurred"; +- case AVERROR_NOMEM: ++ case AVERROR(ENOMEM): + return "Memory allocation error"; + default: + break; +@@ -899,7 +906,7 @@ + #endif + + #if LIBAVFORMAT_BUILD > 4621 +- c->codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, CODEC_TYPE_VIDEO); ++ c->codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_VIDEO); + #else + c->codec_id = oc->oformat->video_codec; + #endif +@@ -911,7 +918,7 @@ + //if(codec_tag) c->codec_tag=codec_tag; + codec = avcodec_find_encoder(c->codec_id); + +- c->codec_type = CODEC_TYPE_VIDEO; ++ c->codec_type = AVMEDIA_TYPE_VIDEO; + + /* put sample parameters */ + c->bit_rate = bitrate; +@@ -998,7 +1005,7 @@ + AVPacket pkt; + av_init_packet(&pkt); + +- pkt.flags |= PKT_FLAG_KEY; ++ pkt.flags |= AV_PKT_FLAG_KEY; + pkt.stream_index= video_st->index; + pkt.data= (uint8_t *)picture; + pkt.size= sizeof(AVPicture); +@@ -1018,7 +1025,7 @@ + pkt.pts = c->coded_frame->pts; + #endif + if(c->coded_frame->key_frame) +- pkt.flags |= PKT_FLAG_KEY; ++ pkt.flags |= AV_PKT_FLAG_KEY; + pkt.stream_index= video_st->index; + pkt.data= outbuf; + pkt.size= out_size; +@@ -1215,7 +1222,7 @@ + av_register_all (); + + /* auto detect the output format from the name and fourcc code. */ +- fmt = guess_format(NULL, filename, NULL); ++ fmt = av_guess_format(NULL, filename, NULL); + if (!fmt) + return false; + +@@ -1238,7 +1245,7 @@ + #endif + + // alloc memory for context +- oc = av_alloc_format_context(); ++ oc = avformat_alloc_context(); + assert (oc); + + /* set file name */ diff --git a/opencv-gcc.patch b/opencv-gcc.patch new file mode 100644 index 0000000..eb8a7f0 --- /dev/null +++ b/opencv-gcc.patch @@ -0,0 +1,10 @@ +--- OpenCV-2.2.0/modules/core/include/opencv2/core/core.hpp.orig 2010-12-05 04:35:24.000000000 +0100 ++++ OpenCV-2.2.0/modules/core/include/opencv2/core/core.hpp 2011-06-28 21:14:32.258435783 +0200 +@@ -56,6 +56,7 @@ + #include + #include + #include ++#include + #include + #include + #include diff --git a/opencv.spec b/opencv.spec index 6e19ea4..237bcba 100644 --- a/opencv.spec +++ b/opencv.spec @@ -6,6 +6,7 @@ %bcond_with qt # Qt backend instead of GTK+ %bcond_with tbb # Threading Building Blocks support %bcond_with unicap # Unicap support (GPL) +%bcond_with v4l # Video4Linux (even V4L2 support currently relies on V4L1 API) %bcond_with xine # XINE support (GPL) # Summary: A library of programming functions mainly aimed at real time computer vision @@ -27,13 +28,15 @@ Patch1: %{name}-cflags.patch Patch2: %{name}-link.patch Patch3: %{name}-unicap-c++.patch Patch4: %{name}-c.patch +Patch5: %{name}-gcc.patch +Patch6: %{name}-ffmpeg-0.8.patch URL: http://opencv.willowgarage.com/ %{?with_pvapi:BuildRequires: AVT_GigE_SDK-devel} BuildRequires: OpenEXR-devel BuildRequires: cmake >= 2.4 BuildRequires: doxygen BuildRequires: eigen >= 2 -BuildRequires: ffmpeg-devel +BuildRequires: ffmpeg-devel >= 0.6 %if %{with gstreamer} BuildRequires: gstreamer-devel >= 0.10 BuildRequires: gstreamer-plugins-base-devel >= 0.10 @@ -140,6 +143,8 @@ Wiązania Pythona do OpenCV. %patch2 -p1 %patch3 -p1 %patch4 -p1 +%patch5 -p1 +%patch6 -p1 %build install -d build @@ -161,6 +166,7 @@ cd build %{?with_qt:-DWITH_QT=ON -DWITH_QT_OPENGL=ON -DQT_QMAKE_EXECUTABLE=/usr/bin/qmake-qt4} \ %{?with_tbb:-DWITH_TBB=ON} \ %{?with_unicap:-DWITH_UNICAP=ON} \ + %{!?with_v4l:-DWITH_V4L=OFF} \ %{?with_xine:-DWITH_XINE=ON} %{__make} -- 2.43.0