Gentoo Archives: gentoo-commits

From: Tomas Chvatal <scarabeus@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/kde:master commit in: media-libs/opencv/files/, media-libs/opencv/
Date: Sat, 30 Apr 2011 10:28:47
Message-Id: acff45fa76fe64db12cd15ab502080cb5c54b954.scarabeus@gentoo
1 commit: acff45fa76fe64db12cd15ab502080cb5c54b954
2 Author: Tomas Chvatal <scarabeus <AT> gentoo <DOT> org>
3 AuthorDate: Sat Apr 30 10:28:07 2011 +0000
4 Commit: Tomas Chvatal <scarabeus <AT> gentoo <DOT> org>
5 CommitDate: Sat Apr 30 10:28:07 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/kde.git;a=commit;h=acff45fa
7
8 [media-libs/opencv] Fix building with latest ffmpegs and make tests do something.
9
10 ---
11 media-libs/opencv/files/2.2.0-ffmpeg01.patch | 104 ++++++++++++++++++++++++++
12 media-libs/opencv/files/2.2.0-ffmpeg02.patch | 57 ++++++++++++++
13 media-libs/opencv/opencv-2.2.0.ebuild | 13 +++-
14 3 files changed, 171 insertions(+), 3 deletions(-)
15
16 diff --git a/media-libs/opencv/files/2.2.0-ffmpeg01.patch b/media-libs/opencv/files/2.2.0-ffmpeg01.patch
17 new file mode 100644
18 index 0000000..4a5392f
19 --- /dev/null
20 +++ b/media-libs/opencv/files/2.2.0-ffmpeg01.patch
21 @@ -0,0 +1,104 @@
22 +Index: D:/WaterWATCH/dev/opencv/modules/highgui/src/cap_ffmpeg.cpp
23 +===================================================================
24 +--- D:/WaterWATCH/dev/opencv/modules/highgui/src/cap_ffmpeg.cpp (revision 2112)
25 ++++ D:/WaterWATCH/dev/opencv/modules/highgui/src/cap_ffmpeg.cpp (revision 2113)
26 +@@ -466,7 +466,7 @@
27 + AVCodecContext *enc = &ic->streams[i]->codec;
28 + #endif
29 +
30 +- if( CODEC_TYPE_VIDEO == enc->codec_type && video_stream < 0) {
31 ++ if( AVMEDIA_TYPE_VIDEO == enc->codec_type && video_stream < 0) {
32 + AVCodec *codec = avcodec_find_decoder(enc->codec_id);
33 + if (!codec ||
34 + avcodec_open(enc, codec) < 0)
35 +@@ -550,15 +550,27 @@
36 + continue;
37 + }
38 +
39 +-#if LIBAVFORMAT_BUILD > 4628
40 +- avcodec_decode_video(video_st->codec,
41 +- picture, &got_picture,
42 +- packet.data, packet.size);
43 +-#else
44 +- avcodec_decode_video(&video_st->codec,
45 +- picture, &got_picture,
46 +- packet.data, packet.size);
47 +-#endif
48 ++
49 ++ AVPacket avpkt;
50 ++ av_init_packet(&avpkt);
51 ++ avpkt.data = packet.data;
52 ++ avpkt.size = packet.size;
53 ++ //
54 ++ // HACK for CorePNG to decode as normal PNG by default
55 ++ // same method used by ffmpeg
56 ++ avpkt.flags = AV_PKT_FLAG_KEY;
57 ++ avcodec_decode_video2(video_st->codec,
58 ++ picture, &got_picture, &avpkt);
59 ++//Functions Removed from ffmpeg on 4/19/11
60 ++//#if LIBAVFORMAT_BUILD > 4628
61 ++// avcodec_decode_video(video_st->codec,
62 ++// picture, &got_picture,
63 ++// packet.data, packet.size);
64 ++//#else
65 ++// avcodec_decode_video(&video_st->codec,
66 ++// picture, &got_picture,
67 ++// packet.data, packet.size);
68 ++//#endif
69 +
70 + if (got_picture) {
71 + // we have a new picture, so memorize it
72 +@@ -899,7 +911,7 @@
73 + #endif
74 +
75 + #if LIBAVFORMAT_BUILD > 4621
76 +- c->codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, CODEC_TYPE_VIDEO);
77 ++ c->codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_VIDEO);
78 + #else
79 + c->codec_id = oc->oformat->video_codec;
80 + #endif
81 +@@ -911,7 +923,7 @@
82 + //if(codec_tag) c->codec_tag=codec_tag;
83 + codec = avcodec_find_encoder(c->codec_id);
84 +
85 +- c->codec_type = CODEC_TYPE_VIDEO;
86 ++ c->codec_type = AVMEDIA_TYPE_VIDEO;
87 +
88 + /* put sample parameters */
89 + c->bit_rate = bitrate;
90 +@@ -998,7 +1010,7 @@
91 + AVPacket pkt;
92 + av_init_packet(&pkt);
93 +
94 +- pkt.flags |= PKT_FLAG_KEY;
95 ++ pkt.flags |= AV_PKT_FLAG_KEY;
96 + pkt.stream_index= video_st->index;
97 + pkt.data= (uint8_t *)picture;
98 + pkt.size= sizeof(AVPicture);
99 +@@ -1018,7 +1030,7 @@
100 + pkt.pts = c->coded_frame->pts;
101 + #endif
102 + if(c->coded_frame->key_frame)
103 +- pkt.flags |= PKT_FLAG_KEY;
104 ++ pkt.flags |= AV_PKT_FLAG_KEY;
105 + pkt.stream_index= video_st->index;
106 + pkt.data= outbuf;
107 + pkt.size= out_size;
108 +@@ -1215,7 +1227,7 @@
109 + av_register_all ();
110 +
111 + /* auto detect the output format from the name and fourcc code. */
112 +- fmt = guess_format(NULL, filename, NULL);
113 ++ fmt = av_guess_format(NULL, filename, NULL);
114 + if (!fmt)
115 + return false;
116 +
117 +@@ -1238,7 +1250,7 @@
118 + #endif
119 +
120 + // alloc memory for context
121 +- oc = av_alloc_format_context();
122 ++ oc = avformat_alloc_context();
123 + assert (oc);
124 +
125 + /* set file name */
126
127 diff --git a/media-libs/opencv/files/2.2.0-ffmpeg02.patch b/media-libs/opencv/files/2.2.0-ffmpeg02.patch
128 new file mode 100644
129 index 0000000..a0c5787
130 --- /dev/null
131 +++ b/media-libs/opencv/files/2.2.0-ffmpeg02.patch
132 @@ -0,0 +1,57 @@
133 +Index: D:/WaterWATCH/dev/opencv/modules/highgui/src/cap_ffmpeg.cpp
134 +===================================================================
135 +--- D:/WaterWATCH/dev/opencv/modules/highgui/src/cap_ffmpeg.cpp (revision 2121)
136 ++++ D:/WaterWATCH/dev/opencv/modules/highgui/src/cap_ffmpeg.cpp (revision 2122)
137 +@@ -815,24 +815,25 @@
138 + #endif
139 + };
140 +
141 +-static const char * icvFFMPEGErrStr(int err)
142 +-{
143 +- switch(err) {
144 +- case AVERROR_NUMEXPECTED:
145 +- return "Incorrect filename syntax";
146 +- case AVERROR_INVALIDDATA:
147 +- return "Invalid data in header";
148 +- case AVERROR_NOFMT:
149 +- return "Unknown format";
150 +- case AVERROR_IO:
151 +- return "I/O error occurred";
152 +- case AVERROR_NOMEM:
153 +- return "Memory allocation error";
154 +- default:
155 +- break;
156 +- }
157 +- return "Unspecified error";
158 +-}
159 ++//Deprecated Errors, should be using AVERROR(EINVAL) to return error strings
160 ++//static const char * icvFFMPEGErrStr(int err)
161 ++//{
162 ++// switch(err) {
163 ++// case AVERROR_NUMEXPECTED:
164 ++// return "Incorrect filename syntax";
165 ++// case AVERROR_INVALIDDATA:
166 ++// return "Invalid data in header";
167 ++// case AVERROR_NOFMT:
168 ++// return "Unknown format";
169 ++// case AVERROR_IO:
170 ++// return "I/O error occurred";
171 ++// case AVERROR_NOMEM:
172 ++// return "Memory allocation error";
173 ++// default:
174 ++// break;
175 ++// }
176 ++// return "Unspecified error";
177 ++//}
178 +
179 + /* function internal to FFMPEG (libavformat/riff.c) to lookup codec id by fourcc tag*/
180 + extern "C" {
181 +@@ -1322,7 +1323,7 @@
182 + /* open the codec */
183 + if ( (err=avcodec_open(c, codec)) < 0) {
184 + char errtext[256];
185 +- sprintf(errtext, "Could not open codec '%s': %s", codec->name, icvFFMPEGErrStr(err));
186 ++ sprintf(errtext, "Could not open codec '%s': %s", codec->name, AVERROR(EINVAL));
187 + CV_Error(CV_StsBadArg, errtext);
188 + }
189 +
190
191 diff --git a/media-libs/opencv/opencv-2.2.0.ebuild b/media-libs/opencv/opencv-2.2.0.ebuild
192 index 0b4465f..f2890d4 100644
193 --- a/media-libs/opencv/opencv-2.2.0.ebuild
194 +++ b/media-libs/opencv/opencv-2.2.0.ebuild
195 @@ -61,12 +61,14 @@ DEPEND="${RDEPEND}
196
197 PATCHES=(
198 "${FILESDIR}/${PV}-convert_sets_to_options.patch"
199 + "${FILESDIR}/${PV}-ffmpeg01.patch"
200 + "${FILESDIR}/${PV}-ffmpeg02.patch"
201 "${FILESDIR}/${PV}-gcc46.patch"
202 - "${FILESDIR}/${PV}-ptrcvcapture.patch"
203 - "${FILESDIR}/${PV}-v4l_2.6.38.patch"
204 - "${FILESDIR}/${PV}-use_system_libs.patch"
205 "${FILESDIR}/${PV}-libpng1.5.patch"
206 "${FILESDIR}/${PV}-numpy.patch"
207 + "${FILESDIR}/${PV}-ptrcvcapture.patch"
208 + "${FILESDIR}/${PV}-use_system_libs.patch"
209 + "${FILESDIR}/${PV}-v4l_2.6.38.patch"
210 )
211
212 S=${WORKDIR}/${MY_P}
213 @@ -151,3 +153,8 @@ src_configure() {
214
215 cmake-utils_src_configure
216 }
217 +
218 +src_test() {
219 + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${CMAKE_BUILD_DIR}/lib"
220 + cmake-utils_src_test
221 +}