OPAL  Version 3.18.8
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 
27 #ifndef OPAL_CODEC_RFC4175_H
28 #define OPAL_CODEC_RFC4175_H
29 
30 #ifdef P_USE_PRAGMA
31 #pragma interface
32 #endif
33 
34 #include <ptlib.h>
35 
36 #include <opal_config.h>
37 
38 #if OPAL_RFC4175
39 
40 #include <ptclib/random.h>
41 
42 #include <opal/transcoders.h>
43 #include <codec/opalplugin.h>
44 #include <codec/vidcodec.h>
45 
46 
47 #define OPAL_RFC4175_YCbCr420 "RFC4175_YCbCr-4:2:0"
49 #define OpalRFC4175YCbCr420 GetOpalRFC4175_YCbCr420()
50 
51 #define OPAL_RFC4175_RGB "RFC4175_RGB"
52 extern const OpalVideoFormat & GetOpalRFC4175_RGB();
53 #define OpalRFC4175RGB GetOpalRFC4175_RGB()
54 
55 
57 
59 {
61  public:
65  );
66  virtual PINDEX GetPgroupSize() const = 0;
67  virtual PINDEX GetColsPerPgroup() const = 0;
68  virtual PINDEX GetRowsPerPgroup() const = 0;
69 
70  virtual PINDEX PixelsToBytes(PINDEX pixels) const = 0;
71  PINDEX RFC4175HeaderSize(PINDEX lines);
72 
73  struct ScanLineHeader {
74  PUInt16b m_length;
75  PUInt16b m_y; // has field flag in top bit
76  PUInt16b m_offset; // has last line flag in top bit
77  };
78 };
79 
81 
83 {
85  public:
89  );
90 
91  bool ConvertFrames(const RTP_DataFrame & input, RTP_DataFrameList & output);
92 
93  protected:
94  virtual void StartEncoding(const RTP_DataFrame & input);
95  virtual void EndEncoding() = 0;
96 
97  void EncodeFullFrame();
98  void EncodeScanLineSegment(PINDEX y, PINDEX offs, PINDEX width);
99  void AddNewDstFrame();
100  void FinishOutputFrame();
101 
104  unsigned m_frameHeight;
105  unsigned m_frameWidth;
106 
108 
109  RTP_DataFrameList * m_dstFrames;
110  std::vector<PINDEX> m_dstScanlineCounts;
114 };
115 
117 
119 {
121  public:
125  );
127 
128  virtual PINDEX PixelsToBytes(PINDEX pixels) const = 0;
129  virtual PINDEX BytesToPixels(PINDEX pixels) const = 0;
130 
131  bool ConvertFrames(const RTP_DataFrame & input, RTP_DataFrameList & output);
132 
133  protected:
134  void DecodeFramesAndSetFrameSize(RTP_DataFrameList & output);
135  virtual bool DecodeFrames(RTP_DataFrameList & output) = 0;
136 
137  RTP_DataFrameList m_inputFrames;
138  std::vector<PINDEX> m_scanlineCounts;
140 
141  bool m_first;
143  PINDEX m_maxWidth;
144  PINDEX m_maxHeight;
149 };
150 
152 
156 {
158  public:
160  PINDEX GetPgroupSize() const { return 6; }
161  PINDEX GetColsPerPgroup() const { return 2; }
162  PINDEX GetRowsPerPgroup() const { return 2; }
163 
164  PINDEX PixelsToBytes(PINDEX pixels) const { return pixels*12/8; }
165  PINDEX BytesToPixels(PINDEX bytes) const { return bytes*8/12; }
166 
167  bool DecodeFrames(RTP_DataFrameList & output);
168 };
169 
171 {
173  public:
175  PINDEX GetPgroupSize() const { return 6; }
176  PINDEX GetColsPerPgroup() const { return 2; }
177  PINDEX GetRowsPerPgroup() const { return 2; }
178 
179  PINDEX PixelsToBytes(PINDEX pixels) const { return pixels * 12 / 8; }
180  PINDEX BytesToPixels(PINDEX bytes) const { return bytes * 8 / 12; }
181 
182  void StartEncoding(const RTP_DataFrame & input);
183  void EndEncoding();
184 
185  protected:
186  BYTE * m_srcYPlane;
187  BYTE * m_srcCbPlane;
188  BYTE * m_srcCrPlane;
189 };
190 
194 {
196  public:
198  PINDEX GetPgroupSize() const { return 3; }
199  PINDEX GetColsPerPgroup() const { return 1; }
200  PINDEX GetRowsPerPgroup() const { return 1; }
201 
202  PINDEX PixelsToBytes(PINDEX pixels) const { return pixels * 3; }
203  PINDEX BytesToPixels(PINDEX bytes) const { return bytes / 3; }
204 
205  bool DecodeFrames(RTP_DataFrameList & output);
206 };
207 
209 {
211  public:
213  PINDEX GetPgroupSize() const { return 3; }
214  PINDEX GetColsPerPgroup() const { return 1; }
215  PINDEX GetRowsPerPgroup() const { return 1; }
216 
217  PINDEX PixelsToBytes(PINDEX pixels) const { return pixels * 3; }
218  PINDEX BytesToPixels(PINDEX bytes) const { return bytes / 3; }
219 
220  void StartEncoding(const RTP_DataFrame & input);
221  void EndEncoding();
222 
223  protected:
224  BYTE * m_rgbBase;
225 };
226 
227 
228 #define OPAL_REGISTER_RFC4175_VIDEO(oformat, rformat) \
229  OPAL_REGISTER_TRANSCODER(Opal_RFC4175##rformat##_to_##oformat, OpalRFC4175##rformat, Opal##oformat); \
230  OPAL_REGISTER_TRANSCODER(Opal_##oformat##_to_RFC4175##rformat, Opal##oformat, OpalRFC4175##rformat);
231 
232 #define OPAL_REGISTER_RFC4175() \
233  OPAL_REGISTER_RFC4175_VIDEO(YUV420P, YCbCr420); \
234  OPAL_REGISTER_RFC4175_VIDEO(RGB24, RGB)
235 
236 
238 
239 #endif // OPAL_RFC4175
240 
241 #endif // OPAL_CODEC_RFC4175_H
Definition: rfc4175.h:82
BYTE * m_srcCbPlane
Definition: rfc4175.h:187
virtual void StartEncoding(const RTP_DataFrame &input)
BYTE * m_rgbBase
Definition: rfc4175.h:224
PINDEX GetColsPerPgroup() const
Definition: rfc4175.h:214
DWORD m_firstSequenceOfFrame
Definition: rfc4175.h:148
PINDEX PixelsToBytes(PINDEX pixels) const
Definition: rfc4175.h:179
Opal_YUV420P_to_RFC4175YCbCr420()
Definition: rfc4175.h:174
PINDEX GetRowsPerPgroup() const
Definition: rfc4175.h:215
Definition: rfc4175.h:118
PINDEX GetRowsPerPgroup() const
Definition: rfc4175.h:200
PINDEX m_dstScanLineCount
Definition: rfc4175.h:111
PINDEX GetColsPerPgroup() const
Definition: rfc4175.h:161
PINDEX PixelsToBytes(PINDEX pixels) const
Definition: rfc4175.h:217
OpalRFC4175Encoder(const OpalMediaFormat &inputMediaFormat, const OpalMediaFormat &outputMediaFormat)
PINDEX GetColsPerPgroup() const
Definition: rfc4175.h:176
BYTE * m_srcYPlane
Definition: rfc4175.h:186
virtual PINDEX GetPgroupSize() const =0
ScanLineHeader * m_dstScanLineTable
Definition: rfc4175.h:113
PINDEX GetPgroupSize() const
Definition: rfc4175.h:160
PINDEX BytesToPixels(PINDEX bytes) const
Definition: rfc4175.h:218
PINDEX BytesToPixels(PINDEX bytes) const
Definition: rfc4175.h:165
Definition: rfc4175.h:58
bool DecodeFrames(RTP_DataFrameList &output)
Definition: rfc4175.h:193
bool ConvertFrames(const RTP_DataFrame &input, RTP_DataFrameList &output)
RTP_DataFrameList m_inputFrames
Definition: rfc4175.h:137
DWORD m_lastTimeStamp
Definition: rfc4175.h:146
PINDEX m_maxHeight
Definition: rfc4175.h:144
std::vector< PINDEX > m_dstScanlineCounts
Definition: rfc4175.h:110
const OpalVideoFormat & GetOpalRFC4175_YCbCr420()
#define OpalRGB24
Definition: vidcodec.h:54
PINDEX GetPgroupSize() const
Definition: rfc4175.h:175
PINDEX PixelsToBytes(PINDEX pixels) const
Definition: rfc4175.h:202
Definition: rtp.h:540
Definition: mediafmt.h:806
PUInt16b m_offset
Definition: rfc4175.h:76
PINDEX PixelsToBytes(PINDEX pixels) const
Definition: rfc4175.h:164
DWORD m_nextSequenceNumber
Definition: rfc4175.h:145
Opal_RFC4175YCbCr420_to_YUV420P()
Definition: rfc4175.h:159
PUInt16b m_length
Definition: rfc4175.h:74
PINDEX GetPgroupSize() const
Definition: rfc4175.h:198
DWORD m_srcTimestamp
Definition: rfc4175.h:107
#define OpalRFC4175RGB
Definition: rfc4175.h:53
std::vector< PINDEX > m_scanlineCounts
Definition: rfc4175.h:138
void EncodeScanLineSegment(PINDEX y, PINDEX offs, PINDEX width)
PINDEX m_dstPacketSize
Definition: rfc4175.h:112
OpalMediaFormat inputMediaFormat
Definition: transcoders.h:104
unsigned m_frameWidth
Definition: rfc4175.h:105
OpalRFC4175Transcoder(const OpalMediaFormat &inputMediaFormat, const OpalMediaFormat &outputMediaFormat)
void DecodeFramesAndSetFrameSize(RTP_DataFrameList &output)
bool ConvertFrames(const RTP_DataFrame &input, RTP_DataFrameList &output)
PINDEX BytesToPixels(PINDEX bytes) const
Definition: rfc4175.h:180
virtual PINDEX PixelsToBytes(PINDEX pixels) const =0
PINDEX GetRowsPerPgroup() const
Definition: rfc4175.h:162
PINDEX m_frameHeight
Definition: rfc4175.h:139
PINDEX GetPgroupSize() const
Definition: rfc4175.h:213
#define OpalRFC4175YCbCr420
Definition: rfc4175.h:49
virtual bool DecodeFrames(RTP_DataFrameList &output)=0
DWORD m_timeStampOfFrame
Definition: rfc4175.h:147
Definition: rfc4175.h:155
Definition: rfc4175.h:208
PINDEX GetColsPerPgroup() const
Definition: rfc4175.h:199
const OpalVideoFormat & GetOpalRFC4175_RGB()
virtual void EndEncoding()=0
PINDEX m_maxWidth
Definition: rfc4175.h:143
bool DecodeFrames(RTP_DataFrameList &output)
Opal_RFC4175RGB_to_RGB24()
Definition: rfc4175.h:197
unsigned m_frameHeight
Definition: rfc4175.h:104
void StartEncoding(const RTP_DataFrame &input)
PINDEX RFC4175HeaderSize(PINDEX lines)
PINDEX m_frameWidth
Definition: rfc4175.h:139
PINDEX BytesToPixels(PINDEX bytes) const
Definition: rfc4175.h:203
virtual PINDEX GetColsPerPgroup() const =0
PINDEX m_maximumPacketSize
Definition: rfc4175.h:103
BYTE * m_srcCrPlane
Definition: rfc4175.h:188
#define OpalYUV420P
Definition: vidcodec.h:58
virtual PINDEX GetRowsPerPgroup() const =0
virtual PINDEX BytesToPixels(PINDEX pixels) const =0
PINDEX GetRowsPerPgroup() const
Definition: rfc4175.h:177
PUInt16b m_y
Definition: rfc4175.h:75
RTP_DataFrameList * m_dstFrames
Definition: rfc4175.h:109
Definition: mediafmt.h:1481
Opal_RGB24_to_RFC4175RGB()
Definition: rfc4175.h:212
OpalMediaFormat outputMediaFormat
Definition: transcoders.h:105
DWORD m_extendedSequenceNumber
Definition: rfc4175.h:102
OpalRFC4175Decoder(const OpalMediaFormat &inputMediaFormat, const OpalMediaFormat &outputMediaFormat)
Definition: rfc4175.h:170
bool m_missingPackets
Definition: rfc4175.h:142
void StartEncoding(const RTP_DataFrame &input)
virtual PINDEX PixelsToBytes(PINDEX pixels) const =0
bool m_first
Definition: rfc4175.h:141
Definition: vidcodec.h:142