[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcvd-members] libcvd configure configure.in cvd_src/videofile...
From: |
Edward Rosten |
Subject: |
[libcvd-members] libcvd configure configure.in cvd_src/videofile... |
Date: |
Tue, 19 Apr 2011 13:37:12 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: libcvd
Changes by: Edward Rosten <edrosten> 11/04/19 13:37:11
Modified files:
. : configure configure.in
cvd_src : videofilebuffer.cc
Log message:
Add in support for newer FFMPEG to avoide deprecated functions.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/configure?cvsroot=libcvd&r1=1.159&r2=1.160
http://cvs.savannah.gnu.org/viewcvs/libcvd/configure.in?cvsroot=libcvd&r1=1.160&r2=1.161
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/videofilebuffer.cc?cvsroot=libcvd&r1=1.18&r2=1.19
Patches:
Index: configure
===================================================================
RCS file: /cvsroot/libcvd/libcvd/configure,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -b -r1.159 -r1.160
--- configure 19 Apr 2011 13:23:31 -0000 1.159
+++ configure 19 Apr 2011 13:37:11 -0000 1.160
@@ -11680,15 +11680,8 @@
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- if test "$ffmpeg_old_headers" == 1 || test
"$ffmpeg_new_headers" == 1
+ if test "$ffmpeg_new_headers" == 1
then
- if test "$ffmpeg_old_headers" == 1
- then
- cat >>confdefs.h <<\_ACEOF
-#define CVD_INTERNAL_HAVE_FFMPEG_OLD_HEADERS 1
-_ACEOF
-
- fi
{ $as_echo "$as_me:$LINENO: checking for main in -lavutil" >&5
@@ -12063,6 +12056,85 @@
a=1
fi
+
+ have_avcodec_decode_video2=0
+ { $as_echo "$as_me:$LINENO: checking for
avcodec_decode_video2 in -lavcodec" >&5
+$as_echo_n "checking for avcodec_decode_video2 in -lavcodec... " >&6; }
+if test "${ac_cv_lib_avcodec_avcodec_decode_video2+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lavcodec $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 avcodec_decode_video2 ();
+int
+main ()
+{
+return avcodec_decode_video2 ();
+ ;
+ 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 ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$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
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_cxx_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ ac_cv_lib_avcodec_avcodec_decode_video2=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_lib_avcodec_avcodec_decode_video2=no
+fi
+
+rm -rf conftest.dSYM
+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
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_avcodec_avcodec_decode_video2"
>&5
+$as_echo "$ac_cv_lib_avcodec_avcodec_decode_video2" >&6; }
+if test "x$ac_cv_lib_avcodec_avcodec_decode_video2" = x""yes; then
+ have_avcodec_decode_video2=1
+fi
+
+ if test $have_avcodec_decode_video2==1
+ then
+ cat >>confdefs.h <<\_ACEOF
+#define CVD_INTERNAL_FFMPEG_USE_AVCODEC_DECODE_VIDEO2 1
+_ACEOF
+
+ fi
+
else
a=1
fi
@@ -12071,22 +12143,6 @@
{ $as_echo "$as_me:$LINENO: WARNING: FFMPEG currently requires
the use of --enable-gpl" >&5
$as_echo "$as_me: WARNING: FFMPEG currently requires the use of --enable-gpl"
>&2;}
fi
- #if test "$with_ffmpeg" != yes
- #then
-# APPEND(LIBS, [-L $with_ffmpeg])
-# fi
-# if test "`$CXX -dumpversion`" = 4.1.0
-# then
-# APPEND(CXXFLAGS, -D__STDC_CONSTANT_MACROS)
-# fi
-
- #Old ffmpeg?
- #AC_CHECK_HEADERS(ffmpeg/avcodec.h ffmpeg/avformat.h, [], [a=1])
- #AC_CHECK_LIB(avutil, main, [], [a=1])
- #AC_CHECK_LIB(avformat, av_open_input_file, [], [a=1])
- #AC_CHECK_LIB(avformat, av_read_frame, [ffmpeg_recent=yes], [a=1])
#only in >= 0.4.9
- #AC_CHECK_LIB(avcodec, avcodec_open, [], [a=1])
-
if test x$a == x
Index: configure.in
===================================================================
RCS file: /cvsroot/libcvd/libcvd/configure.in,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -b -r1.160 -r1.161
--- configure.in 19 Apr 2011 13:23:31 -0000 1.160
+++ configure.in 19 Apr 2011 13:37:11 -0000 1.161
@@ -811,6 +811,14 @@
AC_CHECK_LIB(avformat, av_read_frame,
[ffmpeg_recent=yes], [a=1]) #only in >= 0.4.9
AC_CHECK_LIB(avcodec, avcodec_open, [], [a=1])
AC_CHECK_LIB(swscale, sws_getContext, [], [a=1])
+
+ have_avcodec_decode_video2=0
+ AC_CHECK_LIB(avcodec, avcodec_decode_video2,
[have_avcodec_decode_video2=1])
+ if test $have_avcodec_decode_video2==1
+ then
+
AC_DEFINE(CVD_INTERNAL_FFMPEG_USE_AVCODEC_DECODE_VIDEO2)
+ fi
+
else
a=1
fi
Index: cvd_src/videofilebuffer.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/videofilebuffer.cc,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- cvd_src/videofilebuffer.cc 19 Apr 2011 13:23:32 -0000 1.18
+++ cvd_src/videofilebuffer.cc 19 Apr 2011 13:37:11 -0000 1.19
@@ -27,19 +27,11 @@
#endif
extern "C" {
-#ifdef CVD_INTERNAL_HAVE_FFMPEG_OLD_HEADERS
- #include <ffmpeg/avcodec.h>
- #include <ffmpeg/avformat.h>
- #include <ffmpeg/swscale.h>
-#else
- #include <libavcodec/avcodec.h>
- #include <libavformat/avformat.h>
- #include <libswscale/swscale.h>
-#endif
+#include <libavcodec/avcodec.h>
+#include <libavformat/avformat.h>
+#include <libswscale/swscale.h>
}
-//struct AVFormatContext;
-//struct AVFrame;
#include <string>
#include <sstream>
@@ -206,7 +198,7 @@
// We shall just use the first video stream
video_stream = -1;
- for(int i=0; i < pFormatContext->nb_streams && video_stream ==
-1; i++)
+ for(unsigned int i=0; i < pFormatContext->nb_streams &&
video_stream == -1; i++)
{
if(pFormatContext->streams[i]->codec->codec_type ==
CODEC_TYPE_VIDEO)
video_stream = i; // Found one!
@@ -320,6 +312,7 @@
AVPacket packet;
+ av_init_packet(&packet);
packet.stream_index = -1;
// How many frames do we read looking for our video stream?
@@ -346,8 +339,11 @@
// Decode video frame
int got_picture;
- if(avcodec_decode_video(pCodecContext, pFrame,
&got_picture,
- packet.data, packet.size) == -1)
+ #ifdef CVD_INTERNAL_FFMPEG_USE_AVCODEC_DECODE_VIDEO2
+ if(avcodec_decode_video2(pCodecContext, pFrame,
&got_picture, & packet) == -1)
+ #else
+ if(avcodec_decode_video(pCodecContext, pFrame,
&got_picture, packet.data, packet.size) == -1)
+ #endif
{
throw BadDecode(frame_time);
}
@@ -540,8 +536,9 @@
// Now read frames until we get to the time we want
AVPacket packet;
+ av_init_packet(&packet);
int gotFrame;
- int64_t pts;
+ int64_t pts=0;
// Decode frame by frame until we reach the desired point.
do {
@@ -554,7 +551,11 @@
// Timestamp of the decoded frame.
pts = static_cast<int64_t>(packet.pts / packet.duration *
AV_TIME_BASE / frame_rate + 0.5);
+ #ifdef CVD_INTERNAL_FFMPEG_USE_AVCODEC_DECODE_VIDEO2
+ avcodec_decode_video2(pCodecContext, pFrame, &gotFrame,
&packet);
+ #else
avcodec_decode_video(pCodecContext, pFrame, &gotFrame,
packet.data, packet.size);
+ #endif
av_free_packet(&packet);
} while (pts < targetPts);