thanks for testing it adrian!
I'd like to push in the svn the swscale ffmpeg code you did.
well, no one gave any feedback, so I think the patch is ok.
btw, I'm attaching it again for review.

bye,
rafael diniz

Em Tuesday 01 April 2008, Adrian Prantl escreveu:
> Am 31.03.2008 um 05:46 schrieb rafael2k:
> > I just (re)made a svn diff for the current svn release - 1055, of
> > the darwin
> > patch (macos x support):
> > http://juba.tvlivre.org/patch-leo.diff
>
> good job!
>
> > ps: I have no way to test it, because I could not set up my darwin
> > environment
> > yet.
>
> I tried it out on my machine (Intel/OS 10.5.2), and it seems to build
> just fine.




-- 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Ciência da Computação @  Unicamp
Rádio Muda, radiolivre.org, TV Piolho, tvlivre.org, www.midiaindependente.org
Chave PGP: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x2FF86098
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

Index: configure.in
===================================================================
--- configure.in	(revision 1055)
+++ configure.in	(working copy)
@@ -345,9 +345,30 @@
 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])
+     PKG_CHECK_MODULES([FFMPEG_TEMP], [libavcodec libpostproc])
      FFMPEG_FOLDER=""
      FFMPEG_EXTERNALTEXT="External ffmpeg"
+		   
+     dnl --------------------------------------------------------------
+     dnl check if libavcodec contains img_convert
+     dnl if not, that means that libswscale is compiled in
+     
+     AC_MSG_CHECKING(for ffmpeg swscale support)
+     saved_LIBS="$LIBS"
+     LIBS="$saved_LIBS $FFMPEG_TEMP_LIBS"
+     AC_TRY_LINK([#include <libavcodec/avcodec.h>],
+		 [img_convert(0, 0, 0,0,0,0)],
+		 enable_ffmpeg_swscale=no,enable_ffmpeg_swscale=yes)
+     LIBS="$saved_LIBS"
+     AC_MSG_RESULT($enable_ffmpeg_swscale)
+     if test x"$enable_ffmpeg_swscale" == xyes; then
+	     dnl AC_DEFINE(HAVE_SWSCALER)
+	     PKG_CHECK_MODULES([FFMPEG], [libavcodec libpostproc libswscale])
+	     FFMPEG_CFLAGS="$FFMPEG_CFLAGS -I/usr/include/libavcodec -I/usr/include/libswscale -DHAVE_SWSCALER"
+     else
+	     PKG_CHECK_MODULES([FFMPEG], [libavcodec libpostproc])
+     fi
+     FFMPEG_EXTERNALTEXT="External ffmpeg"
 else
      FFMPEG_FOLDER=ffmpeg
      FFMPEG_CFLAGS="-I\$(top_srcdir)/quicktime/ffmpeg/libavcodec"
Index: cinelerra/ffmpeg.C
===================================================================
--- cinelerra/ffmpeg.C	(revision 1055)
+++ cinelerra/ffmpeg.C	(working copy)
@@ -5,6 +5,7 @@
 #include "ffmpeg.h"
 #include "guicast.h"
 
+
 FFMPEG::FFMPEG(Asset *asset) {
 	this->asset = asset;
 	codec = 0;
@@ -139,23 +140,49 @@
 		color_model_to_pix_fmt(frame_in->get_color_model());
 	PixelFormat pix_fmt_out = 
 		color_model_to_pix_fmt(frame_out->get_color_model());
-
+#ifdef HAVE_SWSCALER
+	// We need a context for swscale
+	struct SwsContext *convert_ctx;
+#endif
 	// do conversion within libavcodec if possible
 	if (pix_fmt_in != PIX_FMT_NB && pix_fmt_out != PIX_FMT_NB) {
 		// set up a temporary pictures from frame_in and frame_out
 		AVPicture picture_in, picture_out;
 		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());
+		int result;
+#ifndef HAVE_SWSCALER
+		result = img_convert(&picture_out,
+				     pix_fmt_out,
+				     &picture_in,
+				     pix_fmt_in,
+				     frame_in->get_w(),
+				     frame_out->get_h());
 		if (result) {
 			printf("FFMPEG::convert_cmodel img_convert() failed\n");
 		}
+#else
+		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(convert_ctx == NULL){
+			printf("FFMPEG::convert_cmodel : swscale context initialization failed\n");
+			return 1;
+		}
+
+		result = sws_scale(convert_ctx, 
+				picture_in.data, picture_in.linesize,
+				frame_in->get_w(), frame_in->get_h(),
+				picture_out.data, picture_out.linesize);
+
+	
+		sws_freeContext(convert_ctx);
+
+		if(result){
+			printf("FFMPEG::convert_cmodel sws_scale() failed\n");
+		}
+#endif
 		return result;
 	}
 
@@ -207,20 +234,48 @@
 	int cmodel_out = frame_out->get_color_model();
 	PixelFormat pix_fmt_out = color_model_to_pix_fmt(cmodel_out);
 
+#ifdef HAVE_SWSCALER
+	// We need a context for swscale
+	struct SwsContext *convert_ctx;
+#endif
+	int result;
+#ifndef HAVE_SWSCALER
 	// 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);
+		result = img_convert(&picture_out,
+				     pix_fmt_out,
+				     picture_in,
+				     pix_fmt_in,
+				     width_in,
+				     height_in);
 		if (result) {
 			printf("FFMPEG::convert_cmodel img_convert() failed\n");
 		}
 		return result;
 	}
+#else
+	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(convert_ctx == NULL){
+	  printf("FFMPEG::convert_cmodel : swscale context initialization failed\n");
+	  return 1;
+	}
+
+	result = sws_scale(convert_ctx, 
+			   picture_in->data, picture_in->linesize,
+			   width_in, height_in,
+			   picture_out.data, picture_out.linesize);
+
 	
+		sws_freeContext(convert_ctx);
+
+		if(result){
+			printf("FFMPEG::convert_cmodel sws_scale() failed\n");
+		}
+#endif
+	
 	// make an intermediate temp frame only if necessary
 	int cmodel_in = pix_fmt_to_color_model(pix_fmt_in);
 	if (cmodel_in == BC_TRANSPARENCY) {
Index: cinelerra/ffmpeg.h
===================================================================
--- cinelerra/ffmpeg.h	(revision 1055)
+++ cinelerra/ffmpeg.h	(working copy)
@@ -3,8 +3,14 @@
 
 extern "C" {
 #include <avcodec.h>
-};
+}
 
+#ifdef HAVE_SWSCALER
+extern "C" {
+#include <swscale.h>
+}
+#endif
+
 #include "asset.h"
 #include "guicast.h"
 

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to