Hi, Dag,

On Fri, 2009-07-10 at 17:46 +0200, Dag Wieers wrote:

> The other bad news is that both k3b-extras and cinelerra for RHEL5 are now 
> broken. They both fail to build against the newer ffmpeg and I can't find 
> a proper fix for both. For k3b-extras I could disable ffmpeg, with loss of 
> functionality of course :-/ I prefer a fix.

Please have a look at the attached patchset for Cinelerra. The problems
are mainly due to ffmpeg interface changes:

(1) img_convert deprecated in favor of swscale 
(2) avcodec_decode_audio -> avcodec_decode_audio2
(3) extern "C" for C++ modules
(4) libavcodec has its own subdir now

I've spent half-day cooking as I prefer to stick to the bare minimum of
changes required to make it work and my machines are terribly slow at
compiling :-(

Be warned that it DOES break build against internal ffmpeg. As for the
mysterious includes issue, my guess is that it used to work while the
interface of the internal ffmpeg was identical to the external one you
ship, so it used a bit of both, but when they broke the compatibility
the problems arose.

Please report if it works for you and whether you are going to commit it
or not.
 
-- 
Sincerely yours,
Yury V. Zaytsev
diff -Naupr cinelerra-2.1-orig/cinelerra/ffmpeg.C cinelerra-2.1-new/cinelerra/ffmpeg.C
--- cinelerra-2.1-orig/cinelerra/ffmpeg.C	2004-12-19 09:33:25.000000000 +0300
+++ cinelerra-2.1-new/cinelerra/ffmpeg.C	2009-07-11 15:01:56.000000000 +0400
@@ -5,6 +5,12 @@
 #include "ffmpeg.h"
 #include "guicast.h"
 
+// ZYV
+extern "C" {
+    #include <libswscale/swscale.h>
+};
+
+
 FFMPEG::FFMPEG(Asset *asset) {
 	this->asset = asset;
 	codec = 0;
@@ -147,12 +153,26 @@ int FFMPEG::convert_cmodel(VFrame *frame
 		init_picture_from_frame(&picture_in, frame_in);
 		init_picture_from_frame(&picture_out, frame_out);
 
-		int result = img_convert(&picture_out,
-					 pix_fmt_out,
-					 &picture_in,
-					 pix_fmt_in,
-					 frame_in->get_w(),
-					 frame_out->get_h());
+		// ZYV
+		struct SwsContext *img_convert_ctx;
+
+		img_convert_ctx = sws_getContext(
+					frame_in->get_w(), frame_in->get_h(), pix_fmt_in,
+					frame_out->get_w(), frame_out->get_h(), pix_fmt_out,
+					SWS_BICUBIC, NULL, NULL, NULL);
+
+		if (img_convert_ctx == NULL) {
+			printf("FFMPEG::convert_cmodel sws_getContext() failed\n");
+			return 1;
+		}
+
+		int result = sws_scale(img_convert_ctx,
+						picture_in.data, picture_in.linesize,
+						frame_in->get_w(), frame_in->get_h(),
+						picture_out.data, picture_out.linesize);
+
+		sws_freeContext(img_convert_ctx);
+
 		if (result) {
 			printf("FFMPEG::convert_cmodel img_convert() failed\n");
 		}
@@ -209,12 +229,27 @@ int FFMPEG::convert_cmodel(AVPicture *pi
 
 	// do conversion within libavcodec if possible
 	if (pix_fmt_out != PIX_FMT_NB) {
-		int result = img_convert(&picture_out,
-					 pix_fmt_out,
-					 picture_in,
-					 pix_fmt_in,
-					 width_in,
-					 height_in);
+
+		// ZYV
+		struct SwsContext *img_convert_ctx;
+
+		img_convert_ctx = sws_getContext(
+					width_in, height_in, pix_fmt_in,
+					frame_out->get_w(), frame_out->get_h(), pix_fmt_out,
+					SWS_BICUBIC, NULL, NULL, NULL);
+
+		if (img_convert_ctx == NULL) {
+			printf("FFMPEG::convert_cmodel sws_getContext() failed\n");
+			return 1;
+		}
+
+		int result = sws_scale(img_convert_ctx,
+						picture_in->data, picture_in->linesize,
+						width_in, height_in,
+						picture_out.data, picture_out.linesize);
+
+		sws_freeContext(img_convert_ctx);
+
 		if (result) {
 			printf("FFMPEG::convert_cmodel img_convert() failed\n");
 		}
diff -Naupr cinelerra-2.1-orig/cinelerra/ffmpeg.h cinelerra-2.1-new/cinelerra/ffmpeg.h
--- cinelerra-2.1-orig/cinelerra/ffmpeg.h	2006-03-30 01:02:53.000000000 +0400
+++ cinelerra-2.1-new/cinelerra/ffmpeg.h	2009-07-11 15:02:00.000000000 +0400
@@ -1,11 +1,14 @@
 #ifndef FFMPEG_H
 #define FFMPEG_H
 
-#include "ffmpeg/libavcodec/avcodec.h"
-
 #include "asset.h"
 #include "guicast.h"
 
+// ZYV
+extern "C" {
+    #include <libavcodec/avcodec.h>
+};
+
 #define FFMPEG_LATENCY -9
 
 class FFMPEG
diff -Naupr cinelerra-2.1-orig/cinelerra/fileac3.h cinelerra-2.1-new/cinelerra/fileac3.h
--- cinelerra-2.1-orig/cinelerra/fileac3.h	2006-03-30 01:02:53.000000000 +0400
+++ cinelerra-2.1-new/cinelerra/fileac3.h	2009-07-11 15:00:46.000000000 +0400
@@ -2,7 +2,11 @@
 #define FILEAC3_H
 
 
-#include "ffmpeg/libavcodec/avcodec.h"
+// ZYV
+extern "C" {
+    #include <libavcodec/avcodec.h>
+};
+
 #include "filebase.h"
 #include <stdio.h>
 
diff -Naupr cinelerra-2.1-orig/cinelerra/filedv.h cinelerra-2.1-new/cinelerra/filedv.h
--- cinelerra-2.1-orig/cinelerra/filedv.h	2006-03-30 01:02:53.000000000 +0400
+++ cinelerra-2.1-new/cinelerra/filedv.h	2009-07-11 15:00:30.000000000 +0400
@@ -6,7 +6,10 @@
 #include "file.inc"
 
 #ifdef DV_USE_FFMPEG
-#include "ffmpeg/libavcodec/avcodec.h"
+// ZYV
+extern "C" {
+    #include <libavcodec/avcodec.h>
+};
 #endif
 
 #include <libdv/dv.h>
diff -Naupr cinelerra-2.1-orig/cinelerra/Makefile.am cinelerra-2.1-new/cinelerra/Makefile.am
--- cinelerra-2.1-orig/cinelerra/Makefile.am	2006-10-29 02:54:57.000000000 +0400
+++ cinelerra-2.1-new/cinelerra/Makefile.am	2009-07-11 16:29:05.000000000 +0400
@@ -342,8 +342,10 @@ AM_CXXFLAGS = \
 	$(XIPH_CFLAGS) \
 	$(MJPEG_CFLAGS) \
 	$(OPENEXR_CFLAGS) \
+	$(FFMPEG_CFLAGS) \
 	$(LIBDV_CFLAGS) \
 	-DPLUGIN_DIR=\"$(plugindir)\"
+# ZYV
 
 AM_LDFLAGS = -export-dynamic
 
@@ -674,7 +676,10 @@ cinelerra_LDADD = \
 	$(SOUND_LDFLAGS) \
 	$(FIREWIRE_LDFLAGS) \
 	$(LIBDV_LIBS) \
+	$(FFMPEG_LIBS) \
 	-luuid \
 	$(MJPEG_LIBS)
 
+# ZYV
+
 EXTRA_DIST = gen-feather-h
diff -Naupr cinelerra-2.1-orig/configure.in cinelerra-2.1-new/configure.in
--- cinelerra-2.1-orig/configure.in	2006-12-30 20:37:50.000000000 +0300
+++ cinelerra-2.1-new/configure.in	2009-07-11 15:06:52.000000000 +0400
@@ -297,7 +297,9 @@ AC_ARG_ENABLE(altivec, 
 AC_ARG_WITH([external-ffmpeg], AC_HELP_STRING([--with-external-ffmpeg], [use external ffmpeg library]))
 
 if test "x$with_external_ffmpeg" = "xyes"; then
-     PKG_CHECK_MODULES([FFMPEG], [libavcodec libpostproc])
+# ZYV
+#     PKG_CHECK_MODULES([FFMPEG], [libavcodec libpostproc])
+     PKG_CHECK_MODULES([FFMPEG], [libavcodec libswscale libpostproc])
      FFMPEG_FOLDER=""
      FFMPEG_EXTERNALTEXT="External ffmpeg"
 else
diff -Naupr cinelerra-2.1-orig/quicktime/mpeg4.c cinelerra-2.1-new/quicktime/mpeg4.c
--- cinelerra-2.1-orig/quicktime/mpeg4.c	2006-10-29 02:54:57.000000000 +0400
+++ cinelerra-2.1-new/quicktime/mpeg4.c	2009-07-11 15:28:37.000000000 +0400
@@ -7,7 +7,9 @@
 
 
 
-#include "avcodec.h"
+// ZYV
+#include <libavcodec/avcodec.h>
+
 #include "colormodels.h"
 #include "funcprotos.h"
 #include "qtffmpeg.h"
@@ -671,7 +673,9 @@ static int encode(quicktime_t *file, uns
 
         	context->b_quant_factor = 1.25;
         	context->b_quant_offset = 1.25;
-			context->error_resilience = FF_ER_CAREFUL;
+// ZYV
+			context->error_recognition = FF_ER_CAREFUL;
+//			context->error_resilience = FF_ER_CAREFUL;
 			context->error_concealment = 3;
 			context->frame_skip_cmp = FF_CMP_DCTMAX;
 			context->ildct_cmp = FF_CMP_VSAD;
diff -Naupr cinelerra-2.1-orig/quicktime/qtffmpeg.h cinelerra-2.1-new/quicktime/qtffmpeg.h
--- cinelerra-2.1-orig/quicktime/qtffmpeg.h	2005-09-28 23:11:18.000000000 +0400
+++ cinelerra-2.1-new/quicktime/qtffmpeg.h	2009-07-11 15:14:31.000000000 +0400
@@ -16,8 +16,8 @@
 // Heroine Virtual.
 
 
-
-#include "avcodec.h"
+// ZYV
+#include <libavcodec/avcodec.h>
 #include "qtprivate.h"
 
 
diff -Naupr cinelerra-2.1-orig/quicktime/qth264.c cinelerra-2.1-new/quicktime/qth264.c
--- cinelerra-2.1-orig/quicktime/qth264.c	2006-09-12 06:10:57.000000000 +0400
+++ cinelerra-2.1-new/quicktime/qth264.c	2009-07-11 15:15:04.000000000 +0400
@@ -1,4 +1,6 @@
-#include "avcodec.h"
+// ZYV
+#include <libavcodec/avcodec.h>
+
 #include "colormodels.h"
 #include "funcprotos.h"
 #include <pthread.h>
diff -Naupr cinelerra-2.1-orig/quicktime/wma.c cinelerra-2.1-new/quicktime/wma.c
--- cinelerra-2.1-orig/quicktime/wma.c	2006-09-01 00:25:39.000000000 +0400
+++ cinelerra-2.1-new/quicktime/wma.c	2009-07-11 16:16:24.000000000 +0400
@@ -1,4 +1,6 @@
-#include "avcodec.h"
+// ZYV
+#include <libavcodec/avcodec.h>
+
 #include "funcprotos.h"
 #include "quicktime.h"
 #include <string.h>
@@ -187,11 +189,22 @@ printf("decode 2 %x %llx %llx\n", chunk_
 
 // Decode chunk into work buffer.
 		pthread_mutex_lock(&ffmpeg_lock);
+
+// ZYV
+		bytes_decoded = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+		result = avcodec_decode_audio2(codec->decoder_context,
+				(int16_t*)(codec->work_buffer + codec->output_size * sample_size),
+				&bytes_decoded,
+				codec->packet_buffer,
+				chunk_size);
+
+/*
 		result = avcodec_decode_audio(codec->decoder_context, 
 			(int16_t*)(codec->work_buffer + codec->output_size * sample_size), 
             &bytes_decoded,
             codec->packet_buffer, 
 			chunk_size);
+*/
 		pthread_mutex_unlock(&ffmpeg_lock);
 		if(bytes_decoded <= 0)
 		{
--- cinelerra.spec.orig	2007-06-05 14:47:57.000000000 +0400
+++ cinelerra.spec	2009-07-11 17:26:06.000000000 +0400
@@ -30,6 +30,7 @@
 Source0: cinelerra-%{version}%{?prever:-svn%{prever}}.tar.gz
 Source1: cinelerra-64x64.png
 Patch0: cinelerra-2.1-faad2.patch
+Patch1: cinelerra-2.1-zyv.patch
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
 %{?_with_modxorg:BuildRequires: libXt-devel, libXv-devel, libXxf86vm-devel, libXext-devel}
 %{!?_with_modxorg:BuildRequires: xorg-x11-devel}
@@ -71,6 +72,8 @@
 %prep
 %setup
 %patch0 -p1 -b .faad2
+%patch1 -p1
+
 # Add category "AudioVideo", as it ends up in "Others" otherwise
 # Replace the ugly small xpm icon with a nicer png one
 %{__perl} -pi -e 's|^(Categories=.*)|$1AudioVideo;|g;
@@ -129,6 +132,9 @@
 
 
 %changelog
+* Sat Jul 11 2009 Yury V. Zaytsev <[email protected]>
+- Patches around latest FFMPEG interface changes
+
 * Sun Jun 03 2007 Dag Wieers <[email protected]> - 2.0-0.13.20070108 - 5461+/thias
 - Rebuild against x264-0.4.20070529 because I missed it.
 
_______________________________________________
users mailing list
[email protected]
http://lists.rpmforge.net/mailman/listinfo/users

Reply via email to