diff -U 3 -H -d -r -N -- video-1.0.1/src/AVHandler.cc video-1.0.1.new/src/AVHandler.cc --- video-1.0.1/src/AVHandler.cc 2008-12-04 12:02:25.000000000 +0100 +++ video-1.0.1.new/src/AVHandler.cc 2008-12-04 12:04:30.000000000 +0100 @@ -26,6 +26,16 @@ #include +extern "C" { +#if defined (HAVE_FFMPEG_AVFORMAT_H) +#include +#elif defined(HAVE_LIBAVFORMAT_AVFORMAT_H) +#include +#else +#error "Missing ffmpeg headers" +#endif +} + #ifdef _MSC_VER #define snprintf _snprintf #endif @@ -224,14 +234,13 @@ lock_parameters = true; AVCodecContext *c = vstream->codec; - + if (frame && rgbframe) { - if (img_convert((AVPicture *)frame, c->pix_fmt, - (AVPicture *)rgbframe, PIX_FMT_RGB24, - c->width, c->height) < 0) { - (*out) << "AVHandler: error converting RGB image to output format" << std::endl; - return -1; - } + SwsContext *sc = sws_getContext(c->width, c->height, PIX_FMT_BGR24, + c->width, c->height, c->pix_fmt, + SWS_BICUBIC, 0, 0, 0); + sws_scale(sc, rgbframe->data, rgbframe->linesize, 0, + c->height, frame->data, frame->linesize); } int out_size = avcodec_encode_video(c, video_outbuf, @@ -334,9 +343,11 @@ } cc->hurry_up = 0; - img_convert((AVPicture *)rgbframe, PIX_FMT_RGB24, - (AVPicture *)frame, cc->pix_fmt, - cc->width, cc->height); + SwsContext *sc = sws_getContext(cc->width, cc->height, cc->pix_fmt, + cc->width, cc->height, PIX_FMT_BGR24, + SWS_BICUBIC, 0, 0, 0); + sws_scale(sc, frame->data, frame->linesize, 0, + cc->height, rgbframe->data, rgbframe->linesize); av_free_packet(&packet); av_free(frame); frame = NULL; @@ -362,7 +373,7 @@ av_register_all(); AVCodec *codec; - for (codec = first_avcodec; codec != NULL; codec = codec->next) { + for (codec = av_codec_next(0); codec != NULL; codec = av_codec_next(codec)) { if ((codec->type == CODEC_TYPE_VIDEO) && (codec->encode)) { (*out) << codec->name << " "; diff -U 3 -H -d -r -N -- video-1.0.1/src/aviread.cc video-1.0.1.new/src/aviread.cc --- video-1.0.1/src/aviread.cc 2008-12-04 12:02:25.000000000 +0100 +++ video-1.0.1.new/src/aviread.cc 2008-12-04 12:04:30.000000000 +0100 @@ -71,9 +71,9 @@ NDArray image = NDArray(d, 0); for (unsigned int y = 0; y < av.get_height(); y++) { for (unsigned int x = 0; x < av.get_width(); x++) { - for (short rgb = 0; rgb < 3; rgb++) { - image(y, x, rgb) = (double)frame->data[0][y * frame->linesize[0] + 3*x + rgb]/255; - } + image(y, x, 0) = (double)frame->data[0][y * frame->linesize[0] + 3*x + 2]/255; + image(y, x, 1) = (double)frame->data[0][y * frame->linesize[0] + 3*x + 1]/255; + image(y, x, 2) = (double)frame->data[0][y * frame->linesize[0] + 3*x + 0]/255; } } diff -U 3 -H -d -r -N -- video-1.0.1/src/configure video-1.0.1.new/src/configure --- video-1.0.1/src/configure 2008-12-04 12:15:10.000000000 +0100 +++ video-1.0.1.new/src/configure 2008-12-04 12:15:23.000000000 +0100 @@ -3228,7 +3228,8 @@ FFMPEG_FLAGS="-lavcodec -lavutil -lm" echo $FFMPEG_FLAGS else - FFMPEG_FLAGS=`pkg-config libavformat --libs --cflags` + FFMPEG_FLAGS=`pkg-config libavformat libavcodec libavutil libswscale --libs --cflags` + echo $FFMPEG_FLAGS fi @@ -3383,6 +3384,83 @@ fi +{ echo "$as_me:$LINENO: checking for sws_scale in -lswscale" >&5 +echo $ECHO_N "checking for sws_scale in -lswscale... $ECHO_C" >&6; } +if test "${ac_cv_lib_swscale_sws_scale+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lswscale $FFMPEG_FLAGS $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sws_scale (); +int +main () +{ +return sws_scale (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_swscale_sws_scale=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_swscale_sws_scale=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_swscale_sws_scale" >&5 +echo "${ECHO_T}$ac_cv_lib_swscale_sws_scale" >&6; } +if test $ac_cv_lib_swscale_sws_scale = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSWSCALE 1 +_ACEOF + + LIBS="-lswscale $LIBS" + +else + { { echo "$as_me:$LINENO: error: need libswscale from FFMpeg" >&5 +echo "$as_me: error: need libswscale from FFMpeg" >&2;} + { (exit 1); exit 1; }; } +fi + + +OLD_CPPFLAGS=$CPPFLAGS +CPPFLAGS="$CPPFLAGS $FFMPEG_FLAGS" FFMPEG_DEFS= ac_ext=c @@ -4659,6 +4737,7 @@ { (exit 1); exit 1; }; } fi +CPPFLAGS=$OLD_CPPFLAGS ac_config_files="$ac_config_files Makefile" diff -U 3 -H -d -r -N -- video-1.0.1/src/configure.base video-1.0.1.new/src/configure.base --- video-1.0.1/src/configure.base 2008-12-04 12:02:25.000000000 +0100 +++ video-1.0.1.new/src/configure.base 2008-12-04 12:04:30.000000000 +0100 @@ -333,7 +333,8 @@ FFMPEG_FLAGS="-lavcodec -lavutil -lm" echo $FFMPEG_FLAGS else - FFMPEG_FLAGS=`pkg-config libavformat --libs --cflags` + FFMPEG_FLAGS=`pkg-config libavformat libavcodec libavutil libswscale --libs --cflags` + echo $FFMPEG_FLAGS fi AC_CHECK_LIB([avformat], [av_write_frame], [], @@ -342,7 +343,12 @@ AC_CHECK_LIB([avcodec], [av_malloc], [], [AC_MSG_ERROR([need libavcodec from FFMpeg])], [$FFMPEG_FLAGS]) +AC_CHECK_LIB([swscale], [sws_scale], [], + [AC_MSG_ERROR([need libswscale from FFMpeg])], + [$FFMPEG_FLAGS]) +OLD_CPPFLAGS=$CPPFLAGS +CPPFLAGS="$CPPFLAGS $FFMPEG_FLAGS" FFMPEG_DEFS= AC_SUBST(FFMPEG_DEFS) AC_CHECK_HEADERS(ffmpeg/avformat.h, @@ -362,6 +368,7 @@ #elif defined(HAVE_LIBAVFORMAT_AVFORMAT_H) #include #endif]) +CPPFLAGS=$OLD_CPPFLAGS AC_CONFIG_FILES([Makefile]) AC_SUBST([FFMPEG_CONFIG]) diff -U 3 -H -d -r -N -- video-1.0.1/src/Makefile.in video-1.0.1.new/src/Makefile.in --- video-1.0.1/src/Makefile.in 2008-12-04 12:02:25.000000000 +0100 +++ video-1.0.1.new/src/Makefile.in 2008-12-04 12:04:30.000000000 +0100 @@ -4,10 +4,10 @@ FFMPEG_CONFIG = @FFMPEG_CONFIG@ ifdef FFMPEG_CONFIG - FFMPEG_LIBS = $(shell pkg-config libavformat --libs) - FFMPEG_CFLAGS = $(shell pkg-config libavformat --cflags) + FFMPEG_LIBS = $(shell pkg-config libavformat libavcodec libavutil libswscale --libs) + FFMPEG_CFLAGS = $(shell pkg-config libavformat libavcodec libavutil libswscale --cflags) else - FFMPEG_LIBS = -lavformat -lavcodec -lz -lm + FFMPEG_LIBS = -lavformat -lavcodec -lavutil -lswscale -lz -lm FFMPEG_CFLAGS = endif diff -U 3 -H -d -r -N -- video-1.0.1/src/oct-avifile.cc video-1.0.1.new/src/oct-avifile.cc --- video-1.0.1/src/oct-avifile.cc 2008-12-04 12:02:25.000000000 +0100 +++ video-1.0.1.new/src/oct-avifile.cc 2008-12-04 12:04:30.000000000 +0100 @@ -101,15 +101,19 @@ return; } - for (int rgb = 0; rgb < 3; rgb++) { - for (unsigned int y = 0; y < frame_rows; y++) { - for (unsigned int x = 0; x < frame_columns; x++) { - if (bands == 3) - rgbframe->data[0][y * rgbframe->linesize[0] + 3*x + rgb] = (unsigned char)(f(y,x,rgb)*255); - else - rgbframe->data[0][y * rgbframe->linesize[0] + 3*x + rgb] = (unsigned char)(f(y,x)*255); - } + for (unsigned int y = 0; y < frame_rows; y++) { + for (unsigned int x = 0; x < frame_columns; x++) { + if (bands == 3) { + rgbframe->data[0][y * rgbframe->linesize[0] + 3*x + 2] = (unsigned char)(f(y,x,0)*255); + rgbframe->data[0][y * rgbframe->linesize[0] + 3*x + 1] = (unsigned char)(f(y,x,1)*255); + rgbframe->data[0][y * rgbframe->linesize[0] + 3*x + 0] = (unsigned char)(f(y,x,2)*255); + } + else { + rgbframe->data[0][y * rgbframe->linesize[0] + 3*x + 0] = (unsigned char)(f(y,x)*255); + rgbframe->data[0][y * rgbframe->linesize[0] + 3*x + 1] = (unsigned char)(f(y,x)*255); + rgbframe->data[0][y * rgbframe->linesize[0] + 3*x + 2] = (unsigned char)(f(y,x)*255); } + } } if (av->write_frame() < 0) {