Debian Codegraph @

gui/qffmpeg/QVideoEncoder.h

raw symbols SCIP
1 /*
2 QTFFmpegWrapper - QT FFmpeg Wrapper Class
3 Copyright (C) 2009-2012:
4 Daniel Roggen, [email protected]
5
6 All rights reserved.
7
8 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
9
10 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
11 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
12
13 THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 */
15
16 #ifndef __QVideoEncoder_H
17 #define __QVideoEncoder_H
18
19
20 #include <QIODevice>
21 #include <QFile>
22 #include <QImage>
23
24 #include "ffmpeg.h"
25
26 class QVideoEncoder
27 {
28 protected:
29 unsigned Width,Height;
30 unsigned Bitrate;
31 unsigned Gop;
32 bool ok;
33
34 // FFmpeg stuff
35 ffmpeg::AVFormatContext *pFormatCtx;
36 ffmpeg::AVOutputFormat *pOutputFormat;
37 ffmpeg::AVCodecContext *pCodecCtx;
38 ffmpeg::AVStream *pVideoStream;
39 ffmpeg::AVCodec *pCodec;
40 // Frame data
41 ffmpeg::AVFrame *ppicture;
42 uint8_t *picture_buf;
43 // Compressed data
44 int outbuf_size;
45 uint8_t* outbuf;
46 // Conversion
47 ffmpeg::SwsContext *img_convert_ctx;
48 // Packet
49 ffmpeg::AVPacket pkt;
50
51 QString fileName;
52
53 unsigned getWidth();
54 unsigned getHeight();
55 bool isSizeValid();
56
57 void initVars();
58 bool initCodec();
59
60 // Alloc/free the output buffer
61 bool initOutputBuf();
62 void freeOutputBuf();
63
64 // Alloc/free a frame
65 bool initFrame();
66 void freeFrame();
67
68 // Frame conversion
69 bool convertImage(const QImage &img);
70 bool convertImage_sws(const QImage &img);
71
72 virtual int encodeImage_p(const QImage &,bool custompts=false,unsigned pts=0);
73
74
75 public:
76 QVideoEncoder();
77 virtual ~QVideoEncoder();
78
79 bool createFile(QString filename,unsigned width,unsigned height,unsigned bitrate,unsigned gop,unsigned fps=25);
80 virtual bool close();
81
82 virtual int encodeImage(const QImage &);
83 virtual int encodeImagePts(const QImage &,unsigned pts);
84 virtual bool isOk();
85
86 };
87
88
89
90
91 #endif // QVideoEncoder_H