Package: src:opencv Version: 2.1.0-6 Severity: important Tags: patch Hi,
I've uploaded the attached patch to ubuntu that allows the opencv package to build against Libav 0.7. Libav 0.7 can be found currently in experimental, and is waiting for clearance to land in unstable since May 1 (#624807). The patch itself should also work with Libav 0.6 as currently found in unstable. If you experience problems, please let me know. Cheers, -- System Information: Debian Release: squeeze/sid APT prefers natty-updates APT policy: (500, 'natty-updates'), (500, 'natty-security'), (500, 'natty-proposed'), (500, 'natty') Architecture: amd64 (x86_64) Kernel: Linux 3.0.0-0300rc7-generic (SMP w/4 CPU cores) Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash
Author: Gal Shalif <g...@fourier-sys.com> Debian BTS: N/A Bug-Ubuntu: https://launchpad.net/bugs/756154 Description: Fix opencv-2.1.0 compilation errors when copiled with libav-0.7 (a.k.a. ffmpeg 0.7) - as applicable for Ubuntu 11.10 Oneiric Note: Ubuntu 11.04 Natty use libav-0.6.2 with: #define LIBAVCODEC_VERSION_MAJOR 52 #define LIBAVUTIL_VERSION_MAJOR 50 #define LIBAVFORMAT_BUILD (52<<16 | 64<<8 | 2) Note: Ubuntu 11.10 Oneiric use libav-0.7 with: #define LIBAVCODEC_VERSION_MAJOR 53 #define LIBAVUTIL_VERSION_MAJOR 51 #define LIBAVFORMAT_BUILD (53<<16 | 2<<8 | 0) --- a/src/highgui/cvcap_ffmpeg.cpp 2011-07-06 12:44:09.585566733 +0300 +++ b/src/highgui/cvcap_ffmpeg.cpp 2011-07-06 13:09:43.261010471 +0300 @@ -464,7 +464,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) @@ -514,6 +514,24 @@ } +#if LIBAVFORMAT_BUILD >= (53<<16 | 0<<8 | 0) /* As defined when compiled against libav-0.7 from Ubuntu 11.10 Oneiric */ +/* Gal Shalif: temporary add a backward compatible function - till OpenCV is properly ported to compile against ffmpeg 0.7 */ +/* Gal Shalif: code is copy from Ubuntu 11.04 Natty libav-0.6.2/libavcodec/utils.c */ +int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, + int *got_picture_ptr, + uint8_t *buf, int buf_size) +{ + AVPacket avpkt; + av_init_packet(&avpkt); + avpkt.data = buf; + avpkt.size = buf_size; + // HACK for CorePNG to decode as normal PNG by default + avpkt.flags = AV_PKT_FLAG_KEY; + + return avcodec_decode_video2(avctx, picture, got_picture_ptr, &avpkt); +} +#endif /* LIBAVFORMAT_BUILD >= (53<<16 | 0<<8 | 0) */ + bool CvCapture_FFMPEG::grabFrame() { bool valid = false; @@ -795,6 +813,17 @@ #endif }; +#if LIBAVFORMAT_BUILD >= (53<<16 | 0<<8 | 0) /* As defined when compiled against libav-0.7 from Ubuntu 11.10 Oneiric */ +/* Gal Shalif: temporary add a backward compatible define - till OpenCV is properly ported to compile against ffmpeg 0.7 */ + +/* Gal Shalif: code is copy from Ubuntu 11.04 Natty libav-0.6.2/libavutil/error.h and is enclosed within LIBAVUTIL_VERSION_MAJOR < 51 ... #endif */ +#define AVERROR_NUMEXPECTED AVERROR(EDOM) ///< Number syntax expected in filename +#define AVERROR_NOFMT AVERROR(EILSEQ) ///< Unknown format +#define AVERROR_IO AVERROR(EIO) ///< I/O error +#define AVERROR_NOMEM AVERROR(ENOMEM) ///< Not enough memory + +#endif /* LIBAVFORMAT_BUILD >= (53<<16 | 2<<8 | 0) */ + static const char * icvFFMPEGErrStr(int err) { switch(err) { @@ -891,7 +920,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 @@ -903,7 +932,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; @@ -990,7 +1019,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); @@ -1010,7 +1039,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; @@ -1210,7 +1239,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; @@ -1233,7 +1262,7 @@ #endif // alloc memory for context - oc = av_alloc_format_context(); + oc = avformat_alloc_context(); assert (oc); /* set file name */