~ubuntu-branches/ubuntu/trusty/kvirc/trusty

« back to all changes in this revision

Viewing changes to src/kvilib/ext/KviOggTheoraEncoder.h

  • Committer: Bazaar Package Importer
  • Author(s): Kai Wasserbäch, Kai Wasserbäch, Raúl Sánchez Siles
  • Date: 2011-02-12 10:40:21 UTC
  • mfrom: (14.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110212104021-5mh4f75jlku20mnt
The combined "Twisted Experiment" and "Nocturnal Raid" release.

[ Kai Wasserbäch ]
* Synced to upstream's SVN revision 5467.
* debian/rules:
  - Added .PHONY line.
  - Resurrect -DMANUAL_REVISION, got lost somewhere and we build SVN
    revisions again.
  - Replace "-DWITH_NO_EMBEDDED_CODE=YES" with "-DWANT_CRYPTOPP=YES".
  - Change the remaining -DWITH/-DWITHOUT to the new -DWANT syntax.
* debian/control:
  - Removed DMUA, I'm a DD now.
  - Changed my e-mail address.
  - Removed unneeded relationships (no upgrades over two releases are
    supported).
  - Fix Suggests for kvirc-dbg.
  - kvirc-data: Make the "Suggests: kvirc" a Recommends, doesn't make much
    sense to install the -data package without the program.
* debian/source/local-options: Added with "unapply-patches".
* debian/kvirc.lintian-overrides: Updated to work for 4.1.1.
* debian/patches/21_make_shared-mime-info_B-D_superfluous.patch: Updated.
* debian/kvirc-data.install: Added .notifyrc.

[ Raúl Sánchez Siles ]
* Stating the right version where kvirc-data break and replace should happen.
* Fixing link to license file.
* Added French and Portuguese man pages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _KVIOGGTHEORAENCODER_H_
 
2
#define _KVIOGGTHEORAENCODER_H_
 
3
 
 
4
//=============================================================================
 
5
//
 
6
//   File : KviOggTheoraEncoder.h
 
7
//   Creation date : Wed Dec 29 2010 15:51:21 CEST by Elvio Basello
 
8
//
 
9
//   This file is part of the KVIrc irc client distribution
 
10
//   Copyright (C) 2010 Elvio Basello (hellvis69 at gmail dot com)
 
11
//
 
12
//   This program is FREE software. You can redistribute it and/or
 
13
//   modify it under the terms of the GNU General Public License
 
14
//   as published by the Free Software Foundation; either version 2
 
15
//   of the License, or (at your opinion) any later version.
 
16
//
 
17
//   This program is distributed in the HOPE that it will be USEFUL,
 
18
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
20
//   See the GNU General Public License for more details.
 
21
//
 
22
//   You should have received a copy of the GNU General Public License
 
23
//   along with this program. If not, write to the Free Software Foundation,
 
24
//   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
25
//
 
26
//=============================================================================
 
27
 
 
28
/**
 
29
* \file KviOggTheoraEncoder.h
 
30
* \author Elvio Basello
 
31
* \brief Contains the KviOggTheoraEncoder class
 
32
*
 
33
* This file was originally part of KviOggTheoraDecoder.h
 
34
*/
 
35
 
 
36
#ifndef COMPILE_DISABLE_OGG_THEORA
 
37
 
 
38
#include "kvi_settings.h"
 
39
#include "KviOggTheoraGeometry.h"
 
40
 
 
41
#include "theora/theoraenc.h"
 
42
 
 
43
#include <QColor>
 
44
 
 
45
class KviDataBuffer;
 
46
 
 
47
/**
 
48
* \def YUV444_BPP Bytes per pixel in a YUV444 image
 
49
*/
 
50
#define YUV444_BPP 3
 
51
 
 
52
 
 
53
/**
 
54
* \class KviOggTheoraEncoder
 
55
* \brief An ogg/theora+irct encoder class; accepts argb32 images and binary text, outputs an ogg stream
 
56
*/
 
57
class KVILIB_API KviOggTheoraEncoder
 
58
{
 
59
public:
 
60
        /**
 
61
        * \brief Constructs the KviOggTheoraEncoder object
 
62
        * \param stream the output stream object
 
63
        * \param iWidth width of the stream
 
64
        * \param iHeight height of the stream
 
65
        * \param iFpsN frames per second: numerator
 
66
        * \param iFpsD frames per second: denominator
 
67
        * \param iParN aspect ratio: numerator
 
68
        * \param iParD aspect ratio: denominator
 
69
        * \return KviOggTheoraEncoder
 
70
        */
 
71
        KviOggTheoraEncoder(KviDataBuffer * stream, int iWidth=320, int iHeight=240, int iFpsN=5, int iFpsD=1, int iParN=4, int iParD=3);
 
72
 
 
73
        /**
 
74
        * \brief Destroys the KviOggTheoraEncoder object
 
75
        */
 
76
        virtual ~KviOggTheoraEncoder();
 
77
private:
 
78
        KviOggTheoraGeometry   geometry;      /**< Stream geometry definition */
 
79
        KviDataBuffer        * m_pStream;     /**< Stream pointer */
 
80
        quint8               * videoYuv;      /**< Yuv encoded surface pointer */
 
81
 
 
82
        ogg_int64_t            text_sofar;    /**< Number of transmitted text frames */
 
83
 
 
84
        int                    frame_state;   /**< Internal flag used in video frame processing */
 
85
        unsigned char        * yuvframe[3];   /**< Internal struct used in video frame processing */
 
86
 
 
87
        size_t                 y4m_dst_buf_sz;        /**< The size of each converted frame buffer */
 
88
        size_t                 y4m_dst_buf_read_sz;   /**< The amount to read directly into the converted frame buffer */
 
89
        size_t                 y4m_aux_buf_sz;        /**< The size of the auxilliary buffer */
 
90
        size_t                 y4m_aux_buf_read_sz;   /**< The amount to read into the auxilliary buffer */
 
91
 
 
92
        ogg_stream_state       zo;   /**< Take physical pages, weld into a logical stream of irct packets */
 
93
        ogg_stream_state       to;   /**< Take physical pages, weld into a logical stream of theora packets */
 
94
        ogg_page               og;   /**< One Ogg bitstream page. Vorbis packets are inside */
 
95
        ogg_packet             op;   /**< One raw packet of encoded data */
 
96
 
 
97
        th_enc_ctx           * td;   /**< Theora stream encoding struct */
 
98
        th_info                ti;   /**< Theora stream info struct */
 
99
        th_comment             tc;   /**< Theora stream comments struct */
 
100
 
 
101
        int                    textflag;    /**< Internal flag used in text frame processing */
 
102
        int                    videoflag;   /**< Internal flag used in video frame processing */
 
103
public:
 
104
        /**
 
105
        * \brief Appends a video frame to the stream
 
106
        * \param rgb32 video frame as a matrix of rgb32 pixels 
 
107
        * \param videoSize size of the video frame
 
108
        * \return void
 
109
        */
 
110
        void addVideoFrame(QRgb * rgb32, int videoSize);
 
111
 
 
112
        /**
 
113
        * \brief Appends a text frame to the stream
 
114
        * \param textPkt buffer containing the text
 
115
        * \param textSize size of the text buffer
 
116
        * \return void
 
117
        */
 
118
        void addTextFrame(unsigned char* textPkt, int textSize);
 
119
private:
 
120
        /**
 
121
        * \brief Internal function that processes a video frame to create an ogg page
 
122
        * \return int
 
123
        */
 
124
        int fetch_and_process_video(quint8 * videoYuv,ogg_page *videopage,ogg_stream_state *to,th_enc_ctx *td,int videoflag);
 
125
 
 
126
        /**
 
127
        * \brief Internal function that processes a video frame to create an ogg packet
 
128
        * \return int
 
129
        */
 
130
        int fetch_and_process_video_packet(quint8 * videoYuv,th_enc_ctx *td,ogg_packet *op);
 
131
 
 
132
        /**
 
133
        * \brief Internal function used to calculate our granule shift
 
134
        * \return int
 
135
        */
 
136
        static int ilog(unsigned _v);
 
137
};
 
138
 
 
139
#endif // COMPILE_DISABLE_OGG_THEORA
 
140
#endif // _KVIOGGTHEORAENCODER_H_