OPAL  Version 3.10.10
rfc4175.h
Go to the documentation of this file.
1 /*
2  * rfc4175.h
3  *
4  * RFC4175 transport for uncompressed video
5  *
6  * Open Phone Abstraction Library
7  *
8  * Copyright (C) 2007 Post Increment
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Open Phone Abstraction Library.
21  *
22  * The Initial Developer of the Original Code is Post Increment
23  *
24  * Contributor(s): ______________________________________.
25  *
26  * $Revision: 24413 $
27  * $Author: rjongbloed $
28  * $Date: 2010-05-27 19:41:47 -0500 (Thu, 27 May 2010) $
29  */
30 
31 #ifndef OPAL_CODEC_RFC4175_H
32 #define OPAL_CODEC_RFC4175_H
33 
34 #ifdef P_USE_PRAGMA
35 #pragma interface
36 #endif
37 
38 #include <ptlib.h>
39 
40 #include <opal/buildopts.h>
41 
42 #if OPAL_RFC4175
43 
44 #include <ptclib/random.h>
45 
46 #include <opal/transcoders.h>
47 #include <codec/opalplugin.h>
48 #include <codec/vidcodec.h>
49 
50 
51 #define OPAL_RFC4175_YCbCr420 "RFC4175_YCbCr-4:2:0"
53 #define OpalRFC4175YCbCr420 GetOpalRFC4175_YCbCr420()
54 
55 #define OPAL_RFC4175_RGB "RFC4175_RGB"
56 extern const OpalVideoFormat & GetOpalRFC4175_RGB();
57 #define OpalRFC4175RGB GetOpalRFC4175_RGB()
58 
59 
61 
63 {
65  public:
69  );
70  virtual PINDEX GetPgroupSize() const = 0;
71  virtual PINDEX GetColsPerPgroup() const = 0;
72  virtual PINDEX GetRowsPerPgroup() const = 0;
73 
74  virtual PINDEX PixelsToBytes(PINDEX pixels) const = 0;
75  PINDEX RFC4175HeaderSize(PINDEX lines);
76 
77  struct ScanLineHeader {
78  PUInt16b m_length;
79  PUInt16b m_y; // has field flag in top bit
80  PUInt16b m_offset; // has last line flag in top bit
81  };
82 };
83 
85 
87 {
89  public:
93  );
94 
95  bool ConvertFrames(const RTP_DataFrame & input, RTP_DataFrameList & output);
96 
97  protected:
98  virtual void StartEncoding(const RTP_DataFrame & input);
99  virtual void EndEncoding() = 0;
100 
101  void EncodeFullFrame();
102  void EncodeScanLineSegment(PINDEX y, PINDEX offs, PINDEX width);
103  void AddNewDstFrame();
104  void FinishOutputFrame();
105 
108  unsigned m_frameHeight;
109  unsigned m_frameWidth;
110 
112 
113  RTP_DataFrameList * m_dstFrames;
114  std::vector<PINDEX> m_dstScanlineCounts;
118 };
119 
121 
123 {
125  public:
129  );
131 
132  virtual PINDEX PixelsToBytes(PINDEX pixels) const = 0;
133  virtual PINDEX BytesToPixels(PINDEX pixels) const = 0;
134 
135  bool ConvertFrames(const RTP_DataFrame & input, RTP_DataFrameList & output);
136 
137  protected:
138  void DecodeFramesAndSetFrameSize(RTP_DataFrameList & output);
139  virtual bool DecodeFrames(RTP_DataFrameList & output) = 0;
140 
141  RTP_DataFrameList m_inputFrames;
142  std::vector<PINDEX> m_scanlineCounts;
143  PINDEX m_frameWidth, m_frameHeight;
144 
145  bool m_first;
147  PINDEX m_maxWidth;
148  PINDEX m_maxHeight;
153 };
154 
156 
160 {
162  public:
164  PINDEX GetPgroupSize() const { return 6; }
165  PINDEX GetColsPerPgroup() const { return 2; }
166  PINDEX GetRowsPerPgroup() const { return 2; }
167 
168  PINDEX PixelsToBytes(PINDEX pixels) const { return pixels*12/8; }
169  PINDEX BytesToPixels(PINDEX bytes) const { return bytes*8/12; }
170 
171  bool DecodeFrames(RTP_DataFrameList & output);
172 };
173 
175 {
177  public:
179  PINDEX GetPgroupSize() const { return 6; }
180  PINDEX GetColsPerPgroup() const { return 2; }
181  PINDEX GetRowsPerPgroup() const { return 2; }
182 
183  PINDEX PixelsToBytes(PINDEX pixels) const { return pixels * 12 / 8; }
184  PINDEX BytesToPixels(PINDEX bytes) const { return bytes * 8 / 12; }
185 
186  void StartEncoding(const RTP_DataFrame & input);
187  void EndEncoding();
188 
189  protected:
190  BYTE * m_srcYPlane;
191  BYTE * m_srcCbPlane;
192  BYTE * m_srcCrPlane;
193 };
194 
198 {
200  public:
202  PINDEX GetPgroupSize() const { return 3; }
203  PINDEX GetColsPerPgroup() const { return 1; }
204  PINDEX GetRowsPerPgroup() const { return 1; }
205 
206  PINDEX PixelsToBytes(PINDEX pixels) const { return pixels * 3; }
207  PINDEX BytesToPixels(PINDEX bytes) const { return bytes / 3; }
208 
209  bool DecodeFrames(RTP_DataFrameList & output);
210 };
211 
213 {
215  public:
217  PINDEX GetPgroupSize() const { return 3; }
218  PINDEX GetColsPerPgroup() const { return 1; }
219  PINDEX GetRowsPerPgroup() const { return 1; }
220 
221  PINDEX PixelsToBytes(PINDEX pixels) const { return pixels * 3; }
222  PINDEX BytesToPixels(PINDEX bytes) const { return bytes / 3; }
223 
224  void StartEncoding(const RTP_DataFrame & input);
225  void EndEncoding();
226 
227  protected:
228  BYTE * m_rgbBase;
229 };
230 
231 
232 #define OPAL_REGISTER_RFC4175_VIDEO(oformat, rformat) \
233  OPAL_REGISTER_TRANSCODER(Opal_RFC4175##rformat##_to_##oformat, OpalRFC4175##rformat, Opal##oformat); \
234  OPAL_REGISTER_TRANSCODER(Opal_##oformat##_to_RFC4175##rformat, Opal##oformat, OpalRFC4175##rformat);
235 
236 #define OPAL_REGISTER_RFC4175() \
237  OPAL_REGISTER_RFC4175_VIDEO(YUV420P, YCbCr420); \
238  OPAL_REGISTER_RFC4175_VIDEO(RGB24, RGB)
239 
240 
242 
243 #endif // OPAL_RFC4175
244 
245 #endif // OPAL_CODEC_RFC4175_H
Definition: rfc4175.h:86
BYTE * m_srcCbPlane
Definition: rfc4175.h:191
BYTE * m_rgbBase
Definition: rfc4175.h:228
PINDEX GetColsPerPgroup() const
Definition: rfc4175.h:218
DWORD m_firstSequenceOfFrame
Definition: rfc4175.h:152
PINDEX PixelsToBytes(PINDEX pixels) const
Definition: rfc4175.h:183
Opal_YUV420P_to_RFC4175YCbCr420()
Definition: rfc4175.h:178
PINDEX GetRowsPerPgroup() const
Definition: rfc4175.h:219
Definition: rfc4175.h:122
PINDEX GetRowsPerPgroup() const
Definition: rfc4175.h:204
PINDEX m_dstScanLineCount
Definition: rfc4175.h:115
PINDEX GetColsPerPgroup() const
Definition: rfc4175.h:165
PINDEX PixelsToBytes(PINDEX pixels) const
Definition: rfc4175.h:221
PINDEX GetColsPerPgroup() const
Definition: rfc4175.h:180
BYTE * m_srcYPlane
Definition: rfc4175.h:190
virtual PINDEX GetPgroupSize() const =0
ScanLineHeader * m_dstScanLineTable
Definition: rfc4175.h:117
PINDEX GetPgroupSize() const
Definition: rfc4175.h:164
PINDEX BytesToPixels(PINDEX bytes) const
Definition: rfc4175.h:222
PINDEX BytesToPixels(PINDEX bytes) const
Definition: rfc4175.h:169
Definition: rfc4175.h:62
Definition: rfc4175.h:197
RTP_DataFrameList m_inputFrames
Definition: rfc4175.h:141
DWORD m_lastTimeStamp
Definition: rfc4175.h:150
PINDEX m_maxHeight
Definition: rfc4175.h:148
std::vector< PINDEX > m_dstScanlineCounts
Definition: rfc4175.h:114
const OpalVideoFormat & GetOpalRFC4175_YCbCr420()
#define OpalRGB24
Definition: vidcodec.h:59
PINDEX GetPgroupSize() const
Definition: rfc4175.h:179
PINDEX PixelsToBytes(PINDEX pixels) const
Definition: rfc4175.h:206
Definition: rtp.h:71
Definition: mediafmt.h:724
PUInt16b m_offset
Definition: rfc4175.h:80
PINDEX PixelsToBytes(PINDEX pixels) const
Definition: rfc4175.h:168
DWORD m_nextSequenceNumber
Definition: rfc4175.h:149
Opal_RFC4175YCbCr420_to_YUV420P()
Definition: rfc4175.h:163
PUInt16b m_length
Definition: rfc4175.h:78
PINDEX GetPgroupSize() const
Definition: rfc4175.h:202
DWORD m_srcTimestamp
Definition: rfc4175.h:111
#define OpalRFC4175RGB
Definition: rfc4175.h:57
std::vector< PINDEX > m_scanlineCounts
Definition: rfc4175.h:142
PINDEX m_dstPacketSize
Definition: rfc4175.h:116
virtual PBoolean ConvertFrames(const RTP_DataFrame &input, RTP_DataFrameList &output)
OpalMediaFormat inputMediaFormat
Definition: transcoders.h:107
unsigned m_frameWidth
Definition: rfc4175.h:109
OpalRFC4175Transcoder(const OpalMediaFormat &inputMediaFormat, const OpalMediaFormat &outputMediaFormat)
PINDEX BytesToPixels(PINDEX bytes) const
Definition: rfc4175.h:184
virtual PINDEX PixelsToBytes(PINDEX pixels) const =0
PINDEX GetRowsPerPgroup() const
Definition: rfc4175.h:166
PINDEX GetPgroupSize() const
Definition: rfc4175.h:217
#define OpalRFC4175YCbCr420
Definition: rfc4175.h:53
DWORD m_timeStampOfFrame
Definition: rfc4175.h:151
Definition: rfc4175.h:159
Definition: rfc4175.h:212
PINDEX GetColsPerPgroup() const
Definition: rfc4175.h:203
const OpalVideoFormat & GetOpalRFC4175_RGB()
PINDEX m_maxWidth
Definition: rfc4175.h:147
Opal_RFC4175RGB_to_RGB24()
Definition: rfc4175.h:201
unsigned m_frameHeight
Definition: rfc4175.h:108
PINDEX RFC4175HeaderSize(PINDEX lines)
PINDEX m_frameWidth
Definition: rfc4175.h:143
PINDEX BytesToPixels(PINDEX bytes) const
Definition: rfc4175.h:207
virtual PINDEX GetColsPerPgroup() const =0
PINDEX m_maximumPacketSize
Definition: rfc4175.h:107
BYTE * m_srcCrPlane
Definition: rfc4175.h:192
#define OpalYUV420P
Definition: vidcodec.h:61
virtual PINDEX GetRowsPerPgroup() const =0
PINDEX GetRowsPerPgroup() const
Definition: rfc4175.h:181
PUInt16b m_y
Definition: rfc4175.h:79
RTP_DataFrameList * m_dstFrames
Definition: rfc4175.h:113
Definition: mediafmt.h:1306
Opal_RGB24_to_RFC4175RGB()
Definition: rfc4175.h:216
OpalMediaFormat outputMediaFormat
Definition: transcoders.h:108
DWORD m_extendedSequenceNumber
Definition: rfc4175.h:106
Definition: rfc4175.h:174
bool m_missingPackets
Definition: rfc4175.h:146
bool m_first
Definition: rfc4175.h:145
Definition: vidcodec.h:72