ports/137805: [patch] graphics/opencv - fix build against multimedia/ffmpeg-devel
Alberto Villa
villa.alberto at gmail.com
Sat Aug 15 21:30:07 UTC 2009
>Number: 137805
>Category: ports
>Synopsis: [patch] graphics/opencv - fix build against multimedia/ffmpeg-devel
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: update
>Submitter-Id: current-users
>Arrival-Date: Sat Aug 15 21:30:07 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator: Alberto Villa
>Release: FreeBSD 8-STABLE
>Organization:
>Environment:
FreeBSD echo.hoth 8.0-BETA2 FreeBSD 8.0-BETA2 #11: Sat Aug 15 17:55:03 CEST 2009 root at echo.hoth:/usr/obj/usr/src/sys/TPR60 i386
>Description:
graphics/opencv fails to build against multimedia/ffmpeg-devel due to API changes
>How-To-Repeat:
- install multimedia/ffmpeg-devel in place of multimedia/ffmpeg
- try to install graphics/opencv
>Fix:
here's the recursive patch (PORTREVISION not bumped as written in the handbook)
deleted files:
- files/patch-otherlibs-highgui.cpp (merged with files/patch-otherlibs-highgui-cvcap_ffmpeg.cpp: they were patching the same file!)
Patch attached with submission follows:
diff -ruN opencv/files/patch-otherlibs-highgui-cvcap_ffmpeg.cpp /usr/ports/graphics/opencv/files/patch-otherlibs-highgui-cvcap_ffmpeg.cpp
--- opencv/files/patch-otherlibs-highgui-cvcap_ffmpeg.cpp 2009-08-15 22:36:37.944465751 +0200
+++ /usr/ports/graphics/opencv/files/patch-otherlibs-highgui-cvcap_ffmpeg.cpp 2009-08-15 23:05:47.824247549 +0200
@@ -1,6 +1,113 @@
---- otherlibs/highgui/cvcap_ffmpeg.cpp.bak 2009-07-25 15:45:10.000000000 +0200
-+++ otherlibs/highgui/cvcap_ffmpeg.cpp 2009-07-25 15:48:41.000000000 +0200
-@@ -801,7 +801,11 @@
+--- otherlibs/highgui/cvcap_ffmpeg.cpp.orig 2006-07-25 00:27:39.000000000 +0200
++++ otherlibs/highgui/cvcap_ffmpeg.cpp 2009-08-15 23:05:18.343750709 +0200
+@@ -41,9 +41,14 @@
+
+ #include "_highgui.h"
+
++#define __STDC_CONSTANT_MACROS
+
+ extern "C" {
+ #include <ffmpeg/avformat.h>
++#include <ffmpeg/avcodec.h>
++#include <ffmpeg/swscale.h>
++#include <sys/types.h> /* size_t */
++#include <sys/errno.h>
+ }
+
+ #ifdef NDEBUG
+@@ -52,6 +57,8 @@
+ #define CV_WARN(message) fprintf(stderr, "warning: %s (%s:%d)\n", message, __FILE__, __LINE__)
+ #endif
+
++static struct SwsContext *img_convert_ctx;
++
+ typedef struct CvCaptureAVI_FFMPEG
+ {
+ CvCaptureVTable * vtable;
+@@ -214,19 +221,21 @@
+ {
+ if( !capture || !capture->video_st || !capture->picture->data[0] )
+ return 0;
+-#if LIBAVFORMAT_BUILD > 4628
+- img_convert( (AVPicture*)&capture->rgb_picture, PIX_FMT_BGR24,
+- (AVPicture*)capture->picture,
+- capture->video_st->codec->pix_fmt,
+- capture->video_st->codec->width,
+- capture->video_st->codec->height );
+-#else
+- img_convert( (AVPicture*)&capture->rgb_picture, PIX_FMT_BGR24,
+- (AVPicture*)capture->picture,
+- capture->video_st->codec.pix_fmt,
+- capture->video_st->codec.width,
+- capture->video_st->codec.height );
+-#endif
++
++ img_convert_ctx = sws_getContext(capture->video_st->codec->width,
++ capture->video_st->codec->height,
++ capture->video_st->codec->pix_fmt,
++ capture->video_st->codec->width,
++ capture->video_st->codec->height,
++ PIX_FMT_BGR24,
++ SWS_BICUBIC,
++ NULL, NULL, NULL);
++
++ sws_scale(img_convert_ctx, capture->picture->data,
++ capture->picture->linesize, 0,
++ capture->video_st->codec->height,
++ capture->rgb_picture.data, capture->rgb_picture.linesize);
++
+ return &capture->frame;
+ }
+
+@@ -389,7 +398,11 @@
+ picture = avcodec_alloc_frame();
+ if (!picture)
+ return NULL;
++#if LIBAVCODEC_BUILD < 3416064
+ size = avpicture_get_size(pix_fmt, width, height);
++#else
++ size = avpicture_get_size((PixelFormat)pix_fmt, width, height);
++#endif
+ if(alloc){
+ picture_buf = (uint8_t *) cvAlloc(size);
+ if (!picture_buf)
+@@ -398,7 +411,11 @@
+ return NULL;
+ }
+ avpicture_fill((AVPicture *)picture, picture_buf,
++#if LIBAVCODEC_BUILD < 3416064
+ pix_fmt, width, height);
++#else
++ (PixelFormat)pix_fmt, width, height);
++#endif
+ }
+ else {
+ }
+@@ -713,9 +730,20 @@
+ PIX_FMT_BGR24, image->width, image->height);
+
+ // convert to the color format needed by the codec
+- if( img_convert((AVPicture *)mywriter->picture, c->pix_fmt,
+- (AVPicture *)mywriter->rgb_picture, PIX_FMT_BGR24,
+- image->width, image->height) < 0){
++ img_convert_ctx = sws_getContext(image->width,
++ image->height,
++ PIX_FMT_BGR24,
++ c->width,
++ c->height,
++ c->pix_fmt,
++ SWS_BICUBIC,
++ NULL, NULL, NULL);
++
++ if ( sws_scale(img_convert_ctx, mywriter->rgb_picture->data,
++ mywriter->rgb_picture->linesize, 0,
++ image->height,
++ mywriter->picture->data, mywriter->picture->linesize) < 0 )
++ {
+ CV_ERROR(CV_StsUnsupportedFormat, "FFMPEG::img_convert pixel format conversion from BGR24 not handled");
+ }
+ }
+@@ -781,7 +809,11 @@
if (!(mywriter->fmt->flags & AVFMT_NOFILE)) {
/* close the output file */
diff -ruN opencv/files/patch-otherlibs-highgui.cpp /usr/ports/graphics/opencv/files/patch-otherlibs-highgui.cpp
--- opencv/files/patch-otherlibs-highgui.cpp 2009-08-15 22:36:37.944465751 +0200
+++ /usr/ports/graphics/opencv/files/patch-otherlibs-highgui.cpp 1970-01-01 01:00:00.000000000 +0100
@@ -1,85 +0,0 @@
---- otherlibs/highgui/cvcap_ffmpeg.cpp.orgi 2008-04-28 20:29:51.000000000 +0200
-+++ otherlibs/highgui/cvcap_ffmpeg.cpp 2008-04-28 20:32:58.000000000 +0200
-@@ -41,9 +41,14 @@
-
- #include "_highgui.h"
-
-+#define __STDC_CONSTANT_MACROS
-
- extern "C" {
- #include <ffmpeg/avformat.h>
-+#include <ffmpeg/avcodec.h>
-+#include <ffmpeg/swscale.h>
-+#include <sys/types.h> /* size_t */
-+#include <sys/errno.h>
- }
-
- #ifdef NDEBUG
-@@ -52,6 +57,8 @@
- #define CV_WARN(message) fprintf(stderr, "warning: %s (%s:%d)\n", message, __FILE__, __LINE__)
- #endif
-
-+static struct SwsContext *img_convert_ctx;
-+
- typedef struct CvCaptureAVI_FFMPEG
- {
- CvCaptureVTable * vtable;
-@@ -214,19 +221,21 @@
- {
- if( !capture || !capture->video_st || !capture->picture->data[0] )
- return 0;
--#if LIBAVFORMAT_BUILD > 4628
-- img_convert( (AVPicture*)&capture->rgb_picture, PIX_FMT_BGR24,
-- (AVPicture*)capture->picture,
-- capture->video_st->codec->pix_fmt,
-- capture->video_st->codec->width,
-- capture->video_st->codec->height );
--#else
-- img_convert( (AVPicture*)&capture->rgb_picture, PIX_FMT_BGR24,
-- (AVPicture*)capture->picture,
-- capture->video_st->codec.pix_fmt,
-- capture->video_st->codec.width,
-- capture->video_st->codec.height );
--#endif
-+
-+ img_convert_ctx = sws_getContext(capture->video_st->codec->width,
-+ capture->video_st->codec->height,
-+ capture->video_st->codec->pix_fmt,
-+ capture->video_st->codec->width,
-+ capture->video_st->codec->height,
-+ PIX_FMT_BGR24,
-+ SWS_BICUBIC,
-+ NULL, NULL, NULL);
-+
-+ sws_scale(img_convert_ctx, capture->picture->data,
-+ capture->picture->linesize, 0,
-+ capture->video_st->codec->height,
-+ capture->rgb_picture.data, capture->rgb_picture.linesize);
-+
- return &capture->frame;
- }
-
-@@ -713,9 +722,20 @@
- PIX_FMT_BGR24, image->width, image->height);
-
- // convert to the color format needed by the codec
-- if( img_convert((AVPicture *)mywriter->picture, c->pix_fmt,
-- (AVPicture *)mywriter->rgb_picture, PIX_FMT_BGR24,
-- image->width, image->height) < 0){
-+ img_convert_ctx = sws_getContext(image->width,
-+ image->height,
-+ PIX_FMT_BGR24,
-+ c->width,
-+ c->height,
-+ c->pix_fmt,
-+ SWS_BICUBIC,
-+ NULL, NULL, NULL);
-+
-+ if ( sws_scale(img_convert_ctx, mywriter->rgb_picture->data,
-+ mywriter->rgb_picture->linesize, 0,
-+ image->height,
-+ mywriter->picture->data, mywriter->picture->linesize) < 0 )
-+ {
- CV_ERROR(CV_StsUnsupportedFormat, "FFMPEG::img_convert pixel format conversion from BGR24 not handled");
- }
- }
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list