tomwalters@397: // Copyright 2006, Thomas Walters tomwalters@397: // tomwalters@397: // AIM-C: A C++ implementation of the Auditory Image Model tomwalters@397: // http://www.acousticscale.org/AIMC tomwalters@397: // tomwalters@397: // Licensed under the Apache License, Version 2.0 (the "License"); tomwalters@397: // you may not use this file except in compliance with the License. tomwalters@397: // You may obtain a copy of the License at tomwalters@397: // tomwalters@397: // http://www.apache.org/licenses/LICENSE-2.0 tomwalters@397: // tomwalters@397: // Unless required by applicable law or agreed to in writing, software tomwalters@397: // distributed under the License is distributed on an "AS IS" BASIS, tomwalters@397: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. tomwalters@397: // See the License for the specific language governing permissions and tomwalters@397: // limitations under the License. tomwalters@397: tomwalters@397: /*! tomwalters@397: * \file tomwalters@397: * \brief Output device for output direct to a movie via local calls to libavcodec tomwalters@397: * tomwalters@397: * \author Tom Walters tomwalters@397: * \date created 2007/10/8 tomwalters@397: * \version \$Id$ tomwalters@397: */ tomwalters@397: tomwalters@397: #ifndef __GRAPHICS_OUTPUT_DEVICE_MOVIE_DIRECT_H__ tomwalters@397: #define __GRAPHICS_OUTPUT_DEVICE_MOVIE_DIRECT_H__ tomwalters@397: tomwalters@397: #include "Modules/Output/Graphics/Devices/GraphicsOutputDeviceMovie.h" tomwalters@397: tomwalters@397: extern "C" { tomwalters@397: #include tomwalters@397: #include tomwalters@397: } tomwalters@397: tom@400: namespace aimc { tom@400: tomwalters@397: /*! tomwalters@397: * \class LibavformatWriter "Output/GraphicsOutputDeviceMovieDirect.h" tomwalters@397: * \brief Helper class to use libavcodec to write a movie file tomwalters@397: */ tomwalters@397: class LibavformatWriter { tomwalters@397: public: tomwalters@397: LibavformatWriter(); tomwalters@398: ~LibavformatWriter() { }; tomwalters@398: bool Init(const char *sMovieFile, int width, int height, float framerate); tomwalters@398: void WriteFrame(unsigned char *pFrameBuffer); tomwalters@398: void End(); tomwalters@397: private: tomwalters@397: AVFrame *picture, *tmp_picture; tomwalters@397: uint8_t *video_outbuf; tomwalters@397: int frame_count, video_outbuf_size; tomwalters@397: int sws_flags; tomwalters@397: PixelFormat pixfmt; tomwalters@397: AVOutputFormat *fmt; tomwalters@397: AVFormatContext *oc; tomwalters@397: AVStream *video_st; tomwalters@397: double video_pts; tomwalters@397: int i; tomwalters@397: AVStream* add_video_stream(AVFormatContext *oc, CodecID codec_id, int width, int height, float framerate); tomwalters@397: AVFrame* alloc_picture(int pix_fmt, int width, int height); tomwalters@397: void open_video(AVFormatContext *oc, AVStream *st); tomwalters@397: void close_video(AVFormatContext *oc, AVStream *st); tomwalters@397: void fill_image(AVFrame *pict,unsigned char *pFrameBuffer , int width, int height); tomwalters@397: }; tomwalters@397: tomwalters@397: /*! tomwalters@397: * \class GraphicsOutputDeviceMovie "Output/GraphicsOutputDeviceMovie.h" tomwalters@397: * \brief Output class for output to a movie tomwalters@397: */ tomwalters@397: class GraphicsOutputDeviceMovieDirect : public GraphicsOutputDeviceMovie { tomwalters@397: public: tomwalters@397: GraphicsOutputDeviceMovieDirect(AimParameters *pParam); tomwalters@398: virtual ~GraphicsOutputDeviceMovieDirect() { }; tomwalters@398: /*! \brief Initializes this output device, prepares plotting tools. tomwalters@398: * \param sSoundFile Sound file for the movie tomwalters@398: * \param sMovieFile Movie filename to produce tomwalters@398: * \return true on success, false on failure. tomwalters@398: * tomwalters@398: * As usual, make sure to call this function before any other. If this tomwalters@398: * Initialize() failed, you shouldn't try the other functions either. tomwalters@398: */ tomwalters@398: bool Initialize(const char *sSoundFile, const char *sMovieFile); tomwalters@398: void Stop(); tomwalters@397: void gRelease(); tomwalters@397: private: tomwalters@398: LibavformatWriter* m_pOutputMovie; tomwalters@397: }; tom@400: } // namespace aimc tomwalters@397: #endif /* __GRAPHICS_OUTPUT_DEVICE_MOVIE_DIRECT_H__ */