tomwalters@397
|
1 // Copyright 2006, Thomas Walters
|
tomwalters@397
|
2 //
|
tomwalters@397
|
3 // AIM-C: A C++ implementation of the Auditory Image Model
|
tomwalters@397
|
4 // http://www.acousticscale.org/AIMC
|
tomwalters@397
|
5 //
|
tomwalters@397
|
6 // Licensed under the Apache License, Version 2.0 (the "License");
|
tomwalters@397
|
7 // you may not use this file except in compliance with the License.
|
tomwalters@397
|
8 // You may obtain a copy of the License at
|
tomwalters@397
|
9 //
|
tomwalters@397
|
10 // http://www.apache.org/licenses/LICENSE-2.0
|
tomwalters@397
|
11 //
|
tomwalters@397
|
12 // Unless required by applicable law or agreed to in writing, software
|
tomwalters@397
|
13 // distributed under the License is distributed on an "AS IS" BASIS,
|
tomwalters@397
|
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
tomwalters@397
|
15 // See the License for the specific language governing permissions and
|
tomwalters@397
|
16 // limitations under the License.
|
tomwalters@397
|
17
|
tomwalters@397
|
18 /*!
|
tomwalters@397
|
19 * \file
|
tomwalters@397
|
20 * \brief Output device for output direct to a movie via local calls to libavcodec
|
tomwalters@397
|
21 *
|
tomwalters@397
|
22 * \author Tom Walters <tom@acousticscale.org>
|
tomwalters@397
|
23 * \date created 2007/10/8
|
tomwalters@397
|
24 * \version \$Id$
|
tomwalters@397
|
25 */
|
tomwalters@397
|
26
|
tomwalters@397
|
27 #ifndef __GRAPHICS_OUTPUT_DEVICE_MOVIE_DIRECT_H__
|
tomwalters@397
|
28 #define __GRAPHICS_OUTPUT_DEVICE_MOVIE_DIRECT_H__
|
tomwalters@397
|
29
|
tomwalters@397
|
30 #include "Modules/Output/Graphics/Devices/GraphicsOutputDeviceMovie.h"
|
tomwalters@397
|
31
|
tomwalters@397
|
32 extern "C" {
|
tomwalters@397
|
33 #include <ffmpeg/avformat.h>
|
tomwalters@397
|
34 #include <ffmpeg/swscale.h>
|
tomwalters@397
|
35 }
|
tomwalters@397
|
36
|
tom@400
|
37 namespace aimc {
|
tom@400
|
38
|
tomwalters@397
|
39 /*!
|
tomwalters@397
|
40 * \class LibavformatWriter "Output/GraphicsOutputDeviceMovieDirect.h"
|
tomwalters@397
|
41 * \brief Helper class to use libavcodec to write a movie file
|
tomwalters@397
|
42 */
|
tomwalters@397
|
43 class LibavformatWriter {
|
tomwalters@397
|
44 public:
|
tomwalters@397
|
45 LibavformatWriter();
|
tomwalters@398
|
46 ~LibavformatWriter() { };
|
tomwalters@398
|
47 bool Init(const char *sMovieFile, int width, int height, float framerate);
|
tomwalters@398
|
48 void WriteFrame(unsigned char *pFrameBuffer);
|
tomwalters@398
|
49 void End();
|
tomwalters@397
|
50 private:
|
tomwalters@397
|
51 AVFrame *picture, *tmp_picture;
|
tomwalters@397
|
52 uint8_t *video_outbuf;
|
tomwalters@397
|
53 int frame_count, video_outbuf_size;
|
tomwalters@397
|
54 int sws_flags;
|
tomwalters@397
|
55 PixelFormat pixfmt;
|
tomwalters@397
|
56 AVOutputFormat *fmt;
|
tomwalters@397
|
57 AVFormatContext *oc;
|
tomwalters@397
|
58 AVStream *video_st;
|
tomwalters@397
|
59 double video_pts;
|
tomwalters@397
|
60 int i;
|
tomwalters@397
|
61 AVStream* add_video_stream(AVFormatContext *oc, CodecID codec_id, int width, int height, float framerate);
|
tomwalters@397
|
62 AVFrame* alloc_picture(int pix_fmt, int width, int height);
|
tomwalters@397
|
63 void open_video(AVFormatContext *oc, AVStream *st);
|
tomwalters@397
|
64 void close_video(AVFormatContext *oc, AVStream *st);
|
tomwalters@397
|
65 void fill_image(AVFrame *pict,unsigned char *pFrameBuffer , int width, int height);
|
tomwalters@397
|
66 };
|
tomwalters@397
|
67
|
tomwalters@397
|
68 /*!
|
tomwalters@397
|
69 * \class GraphicsOutputDeviceMovie "Output/GraphicsOutputDeviceMovie.h"
|
tomwalters@397
|
70 * \brief Output class for output to a movie
|
tomwalters@397
|
71 */
|
tomwalters@397
|
72 class GraphicsOutputDeviceMovieDirect : public GraphicsOutputDeviceMovie {
|
tomwalters@397
|
73 public:
|
tomwalters@397
|
74 GraphicsOutputDeviceMovieDirect(AimParameters *pParam);
|
tomwalters@398
|
75 virtual ~GraphicsOutputDeviceMovieDirect() { };
|
tomwalters@398
|
76 /*! \brief Initializes this output device, prepares plotting tools.
|
tomwalters@398
|
77 * \param sSoundFile Sound file for the movie
|
tomwalters@398
|
78 * \param sMovieFile Movie filename to produce
|
tomwalters@398
|
79 * \return true on success, false on failure.
|
tomwalters@398
|
80 *
|
tomwalters@398
|
81 * As usual, make sure to call this function before any other. If this
|
tomwalters@398
|
82 * Initialize() failed, you shouldn't try the other functions either.
|
tomwalters@398
|
83 */
|
tomwalters@398
|
84 bool Initialize(const char *sSoundFile, const char *sMovieFile);
|
tomwalters@398
|
85 void Stop();
|
tomwalters@397
|
86 void gRelease();
|
tomwalters@397
|
87 private:
|
tomwalters@398
|
88 LibavformatWriter* m_pOutputMovie;
|
tomwalters@397
|
89 };
|
tom@400
|
90 } // namespace aimc
|
tomwalters@397
|
91 #endif /* __GRAPHICS_OUTPUT_DEVICE_MOVIE_DIRECT_H__ */
|