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