libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcvd-members] libcvd configure configure.in cvd/videofilebuff...


From: Edward Rosten
Subject: [libcvd-members] libcvd configure configure.in cvd/videofilebuff...
Date: Tue, 19 Apr 2011 13:12:07 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    libcvd
Changes by:     Edward Rosten <edrosten>        11/04/19 13:12:06

Modified files:
        .              : configure configure.in 
        cvd            : videofilebuffer.h videofilebuffer_frame.h 
        cvd_src        : videofilebuffer.cc 

Log message:
        FFMPEG headers require #defines to be defined which affect the standard
        headers, so includes have to happen in the right order. 
        
        This patch PIMPLifies RawVideoFileBuffer so that it builds without pain
        or the need for -D statements.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/configure?cvsroot=libcvd&r1=1.157&r2=1.158
http://cvs.savannah.gnu.org/viewcvs/libcvd/configure.in?cvsroot=libcvd&r1=1.158&r2=1.159
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/videofilebuffer.h?cvsroot=libcvd&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/videofilebuffer_frame.h?cvsroot=libcvd&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/videofilebuffer.cc?cvsroot=libcvd&r1=1.16&r2=1.17

Patches:
Index: configure
===================================================================
RCS file: /cvsroot/libcvd/libcvd/configure,v
retrieving revision 1.157
retrieving revision 1.158
diff -u -b -r1.157 -r1.158
--- configure   14 Apr 2011 20:50:34 -0000      1.157
+++ configure   19 Apr 2011 13:12:06 -0000      1.158
@@ -11830,76 +11830,6 @@
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
-               if test "$ffmpeg_new_headers" == 1
-               then
-                       { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-
-       if test "" == ""
-       then
-               { $as_echo "$as_me:$LINENO: checking if compiler flag 
-D__STDC_CONSTANT_MACROS works" >&5
-$as_echo_n "checking if compiler flag -D__STDC_CONSTANT_MACROS works... " >&6; 
}
-       else
-               { $as_echo "$as_me:$LINENO: checking " >&5
-$as_echo_n "checking ... " >&6; }
-       fi
-       save_CXXFLAGS="$CXXFLAGS"
-       CXXFLAGS="$CXXFLAGS -D__STDC_CONSTANT_MACROS"
-
-
-
-       cat >conftest.$ac_ext <<_ACEOF
-int main(){}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-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_compile") 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_objext; then
-  cvd_conf_test=1
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       cvd_conf_test=0
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-
-
-
-
-       if test $cvd_conf_test = 1
-       then
-               { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-               ts_success=yes
-       else
-               { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-               CXXFLAGS="$save_CXXFLAGS"
-               ts_success=no
-       fi
-
-               else
-                       { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-               fi
-
                if test "$ffmpeg_old_headers" == 1 || test 
"$ffmpeg_new_headers" == 1
                then
                        if test "$ffmpeg_old_headers" == 1

Index: configure.in
===================================================================
RCS file: /cvsroot/libcvd/libcvd/configure.in,v
retrieving revision 1.158
retrieving revision 1.159
diff -u -b -r1.158 -r1.159
--- configure.in        14 Apr 2011 20:50:34 -0000      1.158
+++ configure.in        19 Apr 2011 13:12:06 -0000      1.159
@@ -806,14 +806,6 @@
                        int main(){}
                ], [ ffmpeg_new_headers=1], [])
 
-               if test "$ffmpeg_new_headers" == 1
-               then
-                       AC_MSG_RESULT(yes)
-                       TEST_AND_SET_CXXFLAG(-D__STDC_CONSTANT_MACROS)
-               else
-                       AC_MSG_RESULT(no)
-               fi
-
                if test "$ffmpeg_old_headers" == 1 || test 
"$ffmpeg_new_headers" == 1
                then
                        if test "$ffmpeg_old_headers" == 1

Index: cvd/videofilebuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/videofilebuffer.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- cvd/videofilebuffer.h       14 Apr 2011 20:50:35 -0000      1.17
+++ cvd/videofilebuffer.h       19 Apr 2011 13:12:06 -0000      1.18
@@ -22,13 +22,11 @@
 #ifndef CVD_VIDEOFILEBUFFER_H
 #define CVD_VIDEOFILEBUFFER_H
 
-#ifndef __STDC_CONSTANT_MACROS
-#define __STDC_CONSTANT_MACROS
-#endif
 #include <vector>
 #include <string>
 #include <fstream>
 #include <errno.h>
+#include <memory>
 
 #include <cvd/localvideobuffer.h>
 #include <cvd/videobufferflags.h>
@@ -39,22 +37,6 @@
 #include <cvd/rgb.h>
 
 #include <cvd/config.h>
-
-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
-}
-
-struct AVFormatContext;
-struct AVFrame; 
-
 namespace CVD
 {
        namespace Exceptions
@@ -110,6 +92,7 @@
 
 
        class A_Frame;
+       class RawVideoFileBufferPIMPL;
 
        /// Internal (non type-safe) class used by VideoFileBuffer
        /// This does the real interfacing with the ffmpeg library
@@ -123,10 +106,7 @@
                        ~RawVideoFileBuffer();
                
                        /// The size of the VideoFrames returned by this buffer
-                       ImageRef size()
-                       {
-                               return my_size;
-                       }
+                       ImageRef size();
 
                        /// Returns the next frame from the buffer. This 
function blocks until a frame is ready.
                        void* get_frame();
@@ -135,10 +115,7 @@
                        void put_frame(void* f);
 
                        /// Is there a frame waiting in the buffer? This 
function does not block. 
-                       bool frame_pending()
-                       {
-                               return frame_ready;
-                       }
+                       bool frame_pending();
 
                        /// Go to a particular point in the video buffer (only 
implemented in buffers of recorded video)
                        /// \param t The frame time in seconds
@@ -146,54 +123,19 @@
                        
                        /// What should the buffer do when it reaches the end 
of the list of files?
                        /// @param behaviour The desired behaviour
-                       void on_end_of_buffer(VideoBufferFlags::OnEndOfBuffer 
behaviour) 
-                       {
-                               end_of_buffer_behaviour = behaviour;
-                       }
+                       void on_end_of_buffer(VideoBufferFlags::OnEndOfBuffer 
behaviour);
                
                        /// What is the (expected) frame rate of this video 
buffer, in frames per second?               
-                       double frames_per_second() 
-                       {
-                        #if LIBAVCODEC_BUILD >= 4754
-                         return pCodecContext->time_base.den / 
static_cast<double>(pCodecContext->time_base.num);
-                        #else
-                                   return pCodecContext->frame_rate / 
static_cast<double>(pCodecContext->frame_rate_base);
-                       #endif
-                       };
+                       double frames_per_second();
                        
                        /// What is the path to the video file?
-                       std::string file_name() 
-                       {
-                               return pFormatContext->filename;
-                       }
+                       std::string file_name();
                        
                        /// What codec is being used to decode this video?
-                       std::string codec_name() 
-                       {
-                               return pCodecContext->codec_name;
-                       }
-               
-               private:
-                       bool read_next_frame();
+                       std::string codec_name();
                                
                private:
-                       ImageRef my_size;
-                       VideoBufferFlags::OnEndOfBuffer end_of_buffer_behaviour;
-                       double start_time;
-                       bool frame_ready;
-
-                       AVFormatContext* pFormatContext;
-                       int video_stream;
-                       AVCodecContext* pCodecContext;
-                   AVFrame* pFrame; 
-               AVFrame* pFrameRGB;
-                       SwsContext *img_convert_ctx;
-                       
-                       CVD::Image<CVD::Rgb<byte> > next_frame_rgb;
-                       CVD::Image<CVD::byte> next_frame;
-                       
-                       double frame_time;
-                       bool is_rgb;
+                       std::auto_ptr<RawVideoFileBufferPIMPL> p;
        };
        }
 

Index: cvd/videofilebuffer_frame.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/videofilebuffer_frame.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- cvd/videofilebuffer_frame.h 24 May 2006 13:09:18 -0000      1.8
+++ cvd/videofilebuffer_frame.h 19 Apr 2011 13:12:06 -0000      1.9
@@ -34,7 +34,7 @@
 {
        namespace VFB
        {
-               class RawVideoFileBuffer;
+               class RawVideoFileBufferPIMPL;
        }
 
        /// A frame from a VideoFileBuffer.
@@ -44,7 +44,7 @@
        template<class T> 
        class VideoFileFrame: public CVD::LocalVideoFrame<T>
        {
-               friend class VFB::RawVideoFileBuffer;
+               friend class VFB::RawVideoFileBufferPIMPL;
 
                public:
                        inline void delete_self() {  delete this; }

Index: cvd_src/videofilebuffer.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/videofilebuffer.cc,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- cvd_src/videofilebuffer.cc  14 Aug 2008 16:12:28 -0000      1.16
+++ cvd_src/videofilebuffer.cc  19 Apr 2011 13:12:06 -0000      1.17
@@ -21,6 +21,26 @@
 // Paul Smith 1 March 2005
 // Uses ffmpeg libraries to play most types of video file
 
+
+#ifndef __STDC_CONSTANT_MACROS
+#define __STDC_CONSTANT_MACROS
+#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
+}
+
+//struct AVFormatContext;
+//struct AVFrame; 
+
 #include <string>
 #include <sstream>
 
@@ -40,39 +60,128 @@
 
 Exceptions::VideoFileBuffer::FileOpen::FileOpen(const std::string& name, const 
string& error)
 {
-       what = "RawVideoFileBuffer: Error opening file \"" + name + "\": " + 
error;
+       what = "RawVideoFileBufferPIMPL: Error opening file \"" + name + "\": " 
+ error;
 }
 
 Exceptions::VideoFileBuffer::BadFrameAlloc::BadFrameAlloc()
 {
-       what = "RawVideoFileBuffer: Unable to allocate video frame.";
+       what = "RawVideoFileBufferPIMPL: Unable to allocate video frame.";
 }
 
 Exceptions::VideoFileBuffer::BadDecode::BadDecode(double t)
 {
        ostringstream os;
-       os << "RawVideoFileBuffer: Error decoding video frame at time " << t << 
".";
+       os << "RawVideoFileBufferPIMPL: Error decoding video frame at time " << 
t << ".";
        what = os.str();
 }
 
 Exceptions::VideoFileBuffer::EndOfFile::EndOfFile()
 {
-       what =  "RawVideoFileBuffer: Tried to read off the end of the file.";
+       what =  "RawVideoFileBufferPIMPL: Tried to read off the end of the 
file.";
 }
 
 Exceptions::VideoFileBuffer::BadSeek::BadSeek(double t)
 {
        ostringstream ss;
-       ss << "RawVideoFileBuffer: Seek to time " << t << "s failed.";
+       ss << "RawVideoFileBufferPIMPL: Seek to time " << t << "s failed.";
        what = ss.str();
 }
 
 namespace VFB
 {
+
+
+       /// Internal (non type-safe) class used by VideoFileBuffer
+       /// This does the real interfacing with the ffmpeg library
+       class RawVideoFileBufferPIMPL 
+       {
+               public:
+                       /// Construct a video buffer to play this file
+                       /// @param file The path to the video file
+                       /// @param is_rgb Is RGB data wanted?
+                       RawVideoFileBufferPIMPL(const std::string& file, bool 
is_rgb);
+                       ~RawVideoFileBufferPIMPL();
+               
+                       /// The size of the VideoFrames returned by this buffer
+                       ImageRef size()
+                       {
+                               return my_size;
+                       }
+
+                       /// Returns the next frame from the buffer. This 
function blocks until a frame is ready.
+                       void* get_frame();
+                       /// Tell the buffer that you are finished with this 
frame.
+                       /// \param f The frame that you are finished with.
+                       void put_frame(void* f);
+
+                       /// Is there a frame waiting in the buffer? This 
function does not block. 
+                       bool frame_pending()
+                       {
+                               return frame_ready;
+                       }
+
+                       /// Go to a particular point in the video buffer (only 
implemented in buffers of recorded video)
+                       /// \param t The frame time in seconds
+                       void seek_to(double t);
+                       
+                       /// What should the buffer do when it reaches the end 
of the list of files?
+                       /// @param behaviour The desired behaviour
+                       void on_end_of_buffer(VideoBufferFlags::OnEndOfBuffer 
behaviour) 
+                       {
+                               end_of_buffer_behaviour = behaviour;
+                       }
+               
+                       /// What is the (expected) frame rate of this video 
buffer, in frames per second?               
+                       double frames_per_second() 
+                       {
+                        #if LIBAVCODEC_BUILD >= 4754
+                         return pCodecContext->time_base.den / 
static_cast<double>(pCodecContext->time_base.num);
+                        #else
+                                   return pCodecContext->frame_rate / 
static_cast<double>(pCodecContext->frame_rate_base);
+                       #endif
+                       };
+                       
+                       /// What is the path to the video file?
+                       std::string file_name() 
+                       {
+                               return pFormatContext->filename;
+                       }
+                       
+                       /// What codec is being used to decode this video?
+                       std::string codec_name() 
+                       {
+                               return pCodecContext->codec_name;
+                       }
+               
+               private:
+                       bool read_next_frame();
+                               
+               private:
+                       ImageRef my_size;
+                       VideoBufferFlags::OnEndOfBuffer end_of_buffer_behaviour;
+                       double start_time;
+                       bool frame_ready;
+
+                       AVFormatContext* pFormatContext;
+                       int video_stream;
+                       AVCodecContext* pCodecContext;
+                   AVFrame* pFrame; 
+               AVFrame* pFrameRGB;
+                       SwsContext *img_convert_ctx;
+                       
+                       CVD::Image<CVD::Rgb<byte> > next_frame_rgb;
+                       CVD::Image<CVD::byte> next_frame;
+                       
+                       double frame_time;
+                       bool is_rgb;
+       };
+
+
+
 //
 // CONSTRUCTOR
 //
-RawVideoFileBuffer::RawVideoFileBuffer(const std::string& file, bool rgbp) :
+RawVideoFileBufferPIMPL::RawVideoFileBufferPIMPL(const std::string& file, bool 
rgbp) :
        end_of_buffer_behaviour(VideoBufferFlags::RepeatLastFrame),
        pFormatContext(0),
        pCodecContext(0),
@@ -196,7 +305,7 @@
 //
 // DESTRUCTOR
 //
-RawVideoFileBuffer::~RawVideoFileBuffer()
+RawVideoFileBufferPIMPL::~RawVideoFileBufferPIMPL()
 {
     //delete [] buffer;
     av_free(pFrameRGB);
@@ -209,7 +318,7 @@
 //
 // READ NEXT FRAME
 //
-bool RawVideoFileBuffer::read_next_frame()
+bool RawVideoFileBufferPIMPL::read_next_frame()
 {
        uint8_t* data;
 
@@ -301,7 +410,7 @@
 //
 // GET FRAME
 //
-void* RawVideoFileBuffer::get_frame()
+void* RawVideoFileBufferPIMPL::get_frame()
 {
 
        if(!frame_pending())
@@ -365,7 +474,7 @@
 //
 // PUT FRAME
 //
-void RawVideoFileBuffer::put_frame(void* f)
+void RawVideoFileBufferPIMPL::put_frame(void* f)
 {
        if(is_rgb)
                delete_frame_or_throw<Rgb<byte> >(f);
@@ -376,7 +485,7 @@
 //
 // SEEK TO
 //
-void RawVideoFileBuffer::seek_to(double t)
+void RawVideoFileBufferPIMPL::seek_to(double t)
 {      
        // The call to av_seek_frame only searches to the keyframe immediately 
prior to the desired frame.
        // To continue from there, we must decode one frame at a time until we 
reach the required frame.
@@ -401,7 +510,7 @@
        // we do not have the info from the previous frames and keyframe, hence 
the BACKWARD flag.
        if (av_seek_frame(pFormatContext, -1, seekToPts, AVSEEK_FLAG_BACKWARD) 
< 0)
        #else
-       if (av_seek_frame(pFormatContext, -1, seekToPts < 0)
+       if (av_seek_frame(pFormatContext, -1, seekToPts < 0))
        #endif
        {
                cerr << "av_seek_frame not supported by this codec: performing 
(slow) manual seek" << endl;
@@ -482,6 +591,54 @@
        read_next_frame();
 }
 
+///Public implementation of RawVideoFileBuffer
+RawVideoFileBuffer::RawVideoFileBuffer(const std::string& file, bool is_rgb)
+:p(new RawVideoFileBufferPIMPL(file, is_rgb))
+{}
+
+RawVideoFileBuffer::~RawVideoFileBuffer()
+{}
+
+ImageRef RawVideoFileBuffer::size()
+{
+       return p->size();
+}
+
+bool RawVideoFileBuffer::frame_pending()
+{
+       return p->frame_pending();
+}
+
+void* RawVideoFileBuffer::get_frame()
+{
+       return p->get_frame();
+}
+
+void RawVideoFileBuffer::put_frame(void* f)
+{
+       p->put_frame(f);
+}
+
+void RawVideoFileBuffer::seek_to(double t)
+{
+       p->seek_to(t);
+}
+
+void RawVideoFileBuffer::on_end_of_buffer(VideoBufferFlags::OnEndOfBuffer b)
+{
+       p->on_end_of_buffer(b);
+}
+
+double RawVideoFileBuffer::frames_per_second()
+{
+       return p->frames_per_second();
+}
+
+string RawVideoFileBuffer::codec_name()
+{
+       return p->codec_name();
+}
+
 
 }
 } // namespace CVD



reply via email to

[Prev in Thread] Current Thread [Next in Thread]