1
#ifndef _KVIOGGTHEORAENCODER_H_
2
#define _KVIOGGTHEORAENCODER_H_
4
//=============================================================================
6
// File : KviOggTheoraEncoder.h
7
// Creation date : Wed Dec 29 2010 15:51:21 CEST by Elvio Basello
9
// This file is part of the KVIrc irc client distribution
10
// Copyright (C) 2010 Elvio Basello (hellvis69 at gmail dot com)
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.
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.
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.
26
//=============================================================================
29
* \file KviOggTheoraEncoder.h
30
* \author Elvio Basello
31
* \brief Contains the KviOggTheoraEncoder class
33
* This file was originally part of KviOggTheoraDecoder.h
36
#ifndef COMPILE_DISABLE_OGG_THEORA
38
#include "kvi_settings.h"
39
#include "KviOggTheoraGeometry.h"
41
#include "theora/theoraenc.h"
48
* \def YUV444_BPP Bytes per pixel in a YUV444 image
54
* \class KviOggTheoraEncoder
55
* \brief An ogg/theora+irct encoder class; accepts argb32 images and binary text, outputs an ogg stream
57
class KVILIB_API KviOggTheoraEncoder
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
71
KviOggTheoraEncoder(KviDataBuffer * stream, int iWidth=320, int iHeight=240, int iFpsN=5, int iFpsD=1, int iParN=4, int iParD=3);
74
* \brief Destroys the KviOggTheoraEncoder object
76
virtual ~KviOggTheoraEncoder();
78
KviOggTheoraGeometry geometry; /**< Stream geometry definition */
79
KviDataBuffer * m_pStream; /**< Stream pointer */
80
quint8 * videoYuv; /**< Yuv encoded surface pointer */
82
ogg_int64_t text_sofar; /**< Number of transmitted text frames */
84
int frame_state; /**< Internal flag used in video frame processing */
85
unsigned char * yuvframe[3]; /**< Internal struct used in video frame processing */
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 */
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 */
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 */
101
int textflag; /**< Internal flag used in text frame processing */
102
int videoflag; /**< Internal flag used in video frame processing */
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
110
void addVideoFrame(QRgb * rgb32, int videoSize);
113
* \brief Appends a text frame to the stream
114
* \param textPkt buffer containing the text
115
* \param textSize size of the text buffer
118
void addTextFrame(unsigned char* textPkt, int textSize);
121
* \brief Internal function that processes a video frame to create an ogg page
124
int fetch_and_process_video(quint8 * videoYuv,ogg_page *videopage,ogg_stream_state *to,th_enc_ctx *td,int videoflag);
127
* \brief Internal function that processes a video frame to create an ogg packet
130
int fetch_and_process_video_packet(quint8 * videoYuv,th_enc_ctx *td,ogg_packet *op);
133
* \brief Internal function used to calculate our granule shift
136
static int ilog(unsigned _v);
139
#endif // COMPILE_DISABLE_OGG_THEORA
140
#endif // _KVIOGGTHEORAENCODER_H_