rfc4175.h
Go to the documentation of this file.
/*
* rfc4175.h
*
* RFC4175 transport for uncompressed video
*
* Open Phone Abstraction Library
*
* Copyright (C) 2007 Post Increment
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Open Phone Abstraction Library.
*
* The Initial Developer of the Original Code is Post Increment
*
* Contributor(s): ______________________________________.
*
* $Revision: 24413 $
* $Author: rjongbloed $
* $Date: 2010-05-27 19:41:47 -0500 (Thu, 27 May 2010) $
*/
#ifndef OPAL_CODEC_RFC4175_H
#define OPAL_CODEC_RFC4175_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <ptlib.h>
#include <opal/buildopts.h>
#if OPAL_RFC4175
#include <ptclib/random.h>
#include <opal/transcoders.h>
#include <codec/opalplugin.h>
#include <codec/vidcodec.h>
#define OPAL_RFC4175_YCbCr420 "RFC4175_YCbCr-4:2:0"
extern const OpalVideoFormat & GetOpalRFC4175_YCbCr420();
#define OpalRFC4175YCbCr420 GetOpalRFC4175_YCbCr420()
#define OPAL_RFC4175_RGB "RFC4175_RGB"
extern const OpalVideoFormat & GetOpalRFC4175_RGB();
#define OpalRFC4175RGB GetOpalRFC4175_RGB()
class OpalRFC4175Transcoder : public OpalVideoTranscoder
{
PCLASSINFO(OpalRFC4175Transcoder, OpalVideoTranscoder);
public:
OpalRFC4175Transcoder(
const OpalMediaFormat & inputMediaFormat,
const OpalMediaFormat & outputMediaFormat
);
virtual PINDEX GetPgroupSize() const = 0;
virtual PINDEX GetColsPerPgroup() const = 0;
virtual PINDEX GetRowsPerPgroup() const = 0;
virtual PINDEX PixelsToBytes(PINDEX pixels) const = 0;
PINDEX RFC4175HeaderSize(PINDEX lines);
struct ScanLineHeader {
PUInt16b m_length;
PUInt16b m_y; // has field flag in top bit
PUInt16b m_offset; // has last line flag in top bit
};
};
class OpalRFC4175Encoder : public OpalRFC4175Transcoder
{
PCLASSINFO(OpalRFC4175Encoder, OpalRFC4175Transcoder);
public:
OpalRFC4175Encoder(
const OpalMediaFormat & inputMediaFormat,
const OpalMediaFormat & outputMediaFormat
);
bool ConvertFrames(const RTP_DataFrame & input, RTP_DataFrameList & output);
protected:
virtual void StartEncoding(const RTP_DataFrame & input);
virtual void EndEncoding() = 0;
void EncodeFullFrame();
void EncodeScanLineSegment(PINDEX y, PINDEX offs, PINDEX width);
void AddNewDstFrame();
void FinishOutputFrame();
DWORD m_extendedSequenceNumber;
PINDEX m_maximumPacketSize;
unsigned m_frameHeight;
unsigned m_frameWidth;
DWORD m_srcTimestamp;
RTP_DataFrameList * m_dstFrames;
std::vector<PINDEX> m_dstScanlineCounts;
PINDEX m_dstScanLineCount;
PINDEX m_dstPacketSize;
ScanLineHeader * m_dstScanLineTable;
};
class OpalRFC4175Decoder : public OpalRFC4175Transcoder
{
PCLASSINFO(OpalRFC4175Decoder, OpalRFC4175Transcoder);
public:
OpalRFC4175Decoder(
const OpalMediaFormat & inputMediaFormat,
const OpalMediaFormat & outputMediaFormat
);
~OpalRFC4175Decoder();
virtual PINDEX PixelsToBytes(PINDEX pixels) const = 0;
virtual PINDEX BytesToPixels(PINDEX pixels) const = 0;
bool ConvertFrames(const RTP_DataFrame & input, RTP_DataFrameList & output);
protected:
void DecodeFramesAndSetFrameSize(RTP_DataFrameList & output);
virtual bool DecodeFrames(RTP_DataFrameList & output) = 0;
RTP_DataFrameList m_inputFrames;
std::vector<PINDEX> m_scanlineCounts;
PINDEX m_frameWidth, m_frameHeight;
bool m_first;
bool m_missingPackets;
PINDEX m_maxWidth;
PINDEX m_maxHeight;
DWORD m_nextSequenceNumber;
DWORD m_lastTimeStamp;
DWORD m_timeStampOfFrame;
DWORD m_firstSequenceOfFrame;
};
class Opal_RFC4175YCbCr420_to_YUV420P : public OpalRFC4175Decoder
{
PCLASSINFO(Opal_RFC4175YCbCr420_to_YUV420P, OpalRFC4175Decoder);
public:
Opal_RFC4175YCbCr420_to_YUV420P() : OpalRFC4175Decoder(OpalRFC4175YCbCr420, OpalYUV420P) { }
PINDEX GetPgroupSize() const { return 6; }
PINDEX GetColsPerPgroup() const { return 2; }
PINDEX GetRowsPerPgroup() const { return 2; }
PINDEX PixelsToBytes(PINDEX pixels) const { return pixels*12/8; }
PINDEX BytesToPixels(PINDEX bytes) const { return bytes*8/12; }
bool DecodeFrames(RTP_DataFrameList & output);
};
class Opal_YUV420P_to_RFC4175YCbCr420 : public OpalRFC4175Encoder
{
PCLASSINFO(Opal_YUV420P_to_RFC4175YCbCr420, OpalRFC4175Encoder);
public:
Opal_YUV420P_to_RFC4175YCbCr420() : OpalRFC4175Encoder(OpalYUV420P, OpalRFC4175YCbCr420) { }
PINDEX GetPgroupSize() const { return 6; }
PINDEX GetColsPerPgroup() const { return 2; }
PINDEX GetRowsPerPgroup() const { return 2; }
PINDEX PixelsToBytes(PINDEX pixels) const { return pixels * 12 / 8; }
PINDEX BytesToPixels(PINDEX bytes) const { return bytes * 8 / 12; }
void StartEncoding(const RTP_DataFrame & input);
void EndEncoding();
protected:
BYTE * m_srcYPlane;
BYTE * m_srcCbPlane;
BYTE * m_srcCrPlane;
};
class Opal_RFC4175RGB_to_RGB24 : public OpalRFC4175Decoder
{
PCLASSINFO(Opal_RFC4175RGB_to_RGB24, OpalRFC4175Decoder);
public:
Opal_RFC4175RGB_to_RGB24() : OpalRFC4175Decoder(OpalRFC4175RGB, OpalRGB24) { }
PINDEX GetPgroupSize() const { return 3; }
PINDEX GetColsPerPgroup() const { return 1; }
PINDEX GetRowsPerPgroup() const { return 1; }
PINDEX PixelsToBytes(PINDEX pixels) const { return pixels * 3; }
PINDEX BytesToPixels(PINDEX bytes) const { return bytes / 3; }
bool DecodeFrames(RTP_DataFrameList & output);
};
class Opal_RGB24_to_RFC4175RGB : public OpalRFC4175Encoder
{
PCLASSINFO(Opal_RGB24_to_RFC4175RGB, OpalRFC4175Encoder);
public:
Opal_RGB24_to_RFC4175RGB() : OpalRFC4175Encoder(OpalRGB24, OpalRFC4175RGB) { }
PINDEX GetPgroupSize() const { return 3; }
PINDEX GetColsPerPgroup() const { return 1; }
PINDEX GetRowsPerPgroup() const { return 1; }
PINDEX PixelsToBytes(PINDEX pixels) const { return pixels * 3; }
PINDEX BytesToPixels(PINDEX bytes) const { return bytes / 3; }
void StartEncoding(const RTP_DataFrame & input);
void EndEncoding();
protected:
BYTE * m_rgbBase;
};
#define OPAL_REGISTER_RFC4175_VIDEO(oformat, rformat) \
OPAL_REGISTER_TRANSCODER(Opal_RFC4175##rformat##_to_##oformat, OpalRFC4175##rformat, Opal##oformat); \
OPAL_REGISTER_TRANSCODER(Opal_##oformat##_to_RFC4175##rformat, Opal##oformat, OpalRFC4175##rformat);
#define OPAL_REGISTER_RFC4175() \
OPAL_REGISTER_RFC4175_VIDEO(YUV420P, YCbCr420); \
OPAL_REGISTER_RFC4175_VIDEO(RGB24, RGB)
#endif // OPAL_RFC4175
#endif // OPAL_CODEC_RFC4175_H
vidcodec.h
OpalRFC4175Encoder
Definition: rfc4175.h:86
Opal_YUV420P_to_RFC4175YCbCr420::m_srcCbPlane
BYTE * m_srcCbPlane
Definition: rfc4175.h:191
OpalRFC4175Decoder::~OpalRFC4175Decoder
~OpalRFC4175Decoder()
OpalRFC4175Encoder::StartEncoding
virtual void StartEncoding(const RTP_DataFrame &input)
Opal_RGB24_to_RFC4175RGB::m_rgbBase
BYTE * m_rgbBase
Definition: rfc4175.h:228
Opal_RGB24_to_RFC4175RGB::EndEncoding
void EndEncoding()
Opal_RGB24_to_RFC4175RGB::GetColsPerPgroup
PINDEX GetColsPerPgroup() const
Definition: rfc4175.h:218
OpalRFC4175Decoder::m_firstSequenceOfFrame
DWORD m_firstSequenceOfFrame
Definition: rfc4175.h:152
opalplugin.h
buildopts.h
Opal_YUV420P_to_RFC4175YCbCr420::PixelsToBytes
PINDEX PixelsToBytes(PINDEX pixels) const
Definition: rfc4175.h:183
Opal_YUV420P_to_RFC4175YCbCr420::Opal_YUV420P_to_RFC4175YCbCr420
Opal_YUV420P_to_RFC4175YCbCr420()
Definition: rfc4175.h:178
Opal_RGB24_to_RFC4175RGB::GetRowsPerPgroup
PINDEX GetRowsPerPgroup() const
Definition: rfc4175.h:219
OpalRFC4175Decoder
Definition: rfc4175.h:122
Opal_RFC4175RGB_to_RGB24::GetRowsPerPgroup
PINDEX GetRowsPerPgroup() const
Definition: rfc4175.h:204
OpalRFC4175Encoder::m_dstScanLineCount
PINDEX m_dstScanLineCount
Definition: rfc4175.h:115
Opal_RFC4175YCbCr420_to_YUV420P::GetColsPerPgroup
PINDEX GetColsPerPgroup() const
Definition: rfc4175.h:165
Opal_RGB24_to_RFC4175RGB::PixelsToBytes
PINDEX PixelsToBytes(PINDEX pixels) const
Definition: rfc4175.h:221
OpalRFC4175Encoder::OpalRFC4175Encoder
OpalRFC4175Encoder(const OpalMediaFormat &inputMediaFormat, const OpalMediaFormat &outputMediaFormat)
Opal_YUV420P_to_RFC4175YCbCr420::GetColsPerPgroup
PINDEX GetColsPerPgroup() const
Definition: rfc4175.h:180
Opal_YUV420P_to_RFC4175YCbCr420::m_srcYPlane
BYTE * m_srcYPlane
Definition: rfc4175.h:190
OpalRFC4175Encoder::EncodeFullFrame
void EncodeFullFrame()
OpalRFC4175Transcoder::GetPgroupSize
virtual PINDEX GetPgroupSize() const =0
OpalRFC4175Encoder::m_dstScanLineTable
ScanLineHeader * m_dstScanLineTable
Definition: rfc4175.h:117
Opal_RFC4175YCbCr420_to_YUV420P::GetPgroupSize
PINDEX GetPgroupSize() const
Definition: rfc4175.h:164
Opal_RGB24_to_RFC4175RGB::BytesToPixels
PINDEX BytesToPixels(PINDEX bytes) const
Definition: rfc4175.h:222
Opal_RFC4175YCbCr420_to_YUV420P::BytesToPixels
PINDEX BytesToPixels(PINDEX bytes) const
Definition: rfc4175.h:169
OpalRFC4175Transcoder
Definition: rfc4175.h:62
Opal_RFC4175YCbCr420_to_YUV420P::DecodeFrames
bool DecodeFrames(RTP_DataFrameList &output)
Opal_RFC4175RGB_to_RGB24
Definition: rfc4175.h:197
OpalRFC4175Decoder::ConvertFrames
bool ConvertFrames(const RTP_DataFrame &input, RTP_DataFrameList &output)
OpalRFC4175Decoder::m_inputFrames
RTP_DataFrameList m_inputFrames
Definition: rfc4175.h:141
OpalRFC4175Decoder::m_lastTimeStamp
DWORD m_lastTimeStamp
Definition: rfc4175.h:150
OpalRFC4175Decoder::m_maxHeight
PINDEX m_maxHeight
Definition: rfc4175.h:148
OpalRFC4175Encoder::m_dstScanlineCounts
std::vector< PINDEX > m_dstScanlineCounts
Definition: rfc4175.h:114
GetOpalRFC4175_YCbCr420
const OpalVideoFormat & GetOpalRFC4175_YCbCr420()
OpalRGB24
#define OpalRGB24
Definition: vidcodec.h:59
Opal_YUV420P_to_RFC4175YCbCr420::GetPgroupSize
PINDEX GetPgroupSize() const
Definition: rfc4175.h:179
Opal_RFC4175RGB_to_RGB24::PixelsToBytes
PINDEX PixelsToBytes(PINDEX pixels) const
Definition: rfc4175.h:206
RTP_DataFrame
Definition: rtp.h:71
OpalRFC4175Encoder::AddNewDstFrame
void AddNewDstFrame()
OpalMediaFormat
Definition: mediafmt.h:724
OpalRFC4175Transcoder::ScanLineHeader::m_offset
PUInt16b m_offset
Definition: rfc4175.h:80
Opal_RFC4175YCbCr420_to_YUV420P::PixelsToBytes
PINDEX PixelsToBytes(PINDEX pixels) const
Definition: rfc4175.h:168
OpalRFC4175Decoder::m_nextSequenceNumber
DWORD m_nextSequenceNumber
Definition: rfc4175.h:149
OpalRFC4175Transcoder::ScanLineHeader
Definition: rfc4175.h:77
Opal_RFC4175YCbCr420_to_YUV420P::Opal_RFC4175YCbCr420_to_YUV420P
Opal_RFC4175YCbCr420_to_YUV420P()
Definition: rfc4175.h:163
OpalRFC4175Transcoder::ScanLineHeader::m_length
PUInt16b m_length
Definition: rfc4175.h:78
Opal_RFC4175RGB_to_RGB24::GetPgroupSize
PINDEX GetPgroupSize() const
Definition: rfc4175.h:202
OpalRFC4175Encoder::m_srcTimestamp
DWORD m_srcTimestamp
Definition: rfc4175.h:111
OpalRFC4175RGB
#define OpalRFC4175RGB
Definition: rfc4175.h:57
OpalRFC4175Decoder::m_scanlineCounts
std::vector< PINDEX > m_scanlineCounts
Definition: rfc4175.h:142
transcoders.h
OpalRFC4175Encoder::EncodeScanLineSegment
void EncodeScanLineSegment(PINDEX y, PINDEX offs, PINDEX width)
OpalRFC4175Encoder::m_dstPacketSize
PINDEX m_dstPacketSize
Definition: rfc4175.h:116
OpalMediaFormatPair::inputMediaFormat
OpalMediaFormat inputMediaFormat
Definition: transcoders.h:107
OpalRFC4175Encoder::m_frameWidth
unsigned m_frameWidth
Definition: rfc4175.h:109
Opal_YUV420P_to_RFC4175YCbCr420::EndEncoding
void EndEncoding()
OpalRFC4175Transcoder::OpalRFC4175Transcoder
OpalRFC4175Transcoder(const OpalMediaFormat &inputMediaFormat, const OpalMediaFormat &outputMediaFormat)
OpalRFC4175Decoder::DecodeFramesAndSetFrameSize
void DecodeFramesAndSetFrameSize(RTP_DataFrameList &output)
OpalRFC4175Encoder::ConvertFrames
bool ConvertFrames(const RTP_DataFrame &input, RTP_DataFrameList &output)
Opal_YUV420P_to_RFC4175YCbCr420::BytesToPixels
PINDEX BytesToPixels(PINDEX bytes) const
Definition: rfc4175.h:184
OpalRFC4175Transcoder::PixelsToBytes
virtual PINDEX PixelsToBytes(PINDEX pixels) const =0
Opal_RFC4175YCbCr420_to_YUV420P::GetRowsPerPgroup
PINDEX GetRowsPerPgroup() const
Definition: rfc4175.h:166
OpalRFC4175Decoder::m_frameHeight
PINDEX m_frameHeight
Definition: rfc4175.h:143
Opal_RGB24_to_RFC4175RGB::GetPgroupSize
PINDEX GetPgroupSize() const
Definition: rfc4175.h:217
OpalRFC4175YCbCr420
#define OpalRFC4175YCbCr420
Definition: rfc4175.h:53
OpalRFC4175Decoder::DecodeFrames
virtual bool DecodeFrames(RTP_DataFrameList &output)=0
OpalRFC4175Decoder::m_timeStampOfFrame
DWORD m_timeStampOfFrame
Definition: rfc4175.h:151
Opal_RFC4175YCbCr420_to_YUV420P
Definition: rfc4175.h:159
Opal_RGB24_to_RFC4175RGB
Definition: rfc4175.h:212
Opal_RFC4175RGB_to_RGB24::GetColsPerPgroup
PINDEX GetColsPerPgroup() const
Definition: rfc4175.h:203
GetOpalRFC4175_RGB
const OpalVideoFormat & GetOpalRFC4175_RGB()
OpalRFC4175Encoder::EndEncoding
virtual void EndEncoding()=0
OpalRFC4175Decoder::m_maxWidth
PINDEX m_maxWidth
Definition: rfc4175.h:147
Opal_RFC4175RGB_to_RGB24::DecodeFrames
bool DecodeFrames(RTP_DataFrameList &output)
Opal_RFC4175RGB_to_RGB24::Opal_RFC4175RGB_to_RGB24
Opal_RFC4175RGB_to_RGB24()
Definition: rfc4175.h:201
OpalRFC4175Encoder::m_frameHeight
unsigned m_frameHeight
Definition: rfc4175.h:108
Opal_YUV420P_to_RFC4175YCbCr420::StartEncoding
void StartEncoding(const RTP_DataFrame &input)
OpalRFC4175Transcoder::RFC4175HeaderSize
PINDEX RFC4175HeaderSize(PINDEX lines)
OpalRFC4175Decoder::m_frameWidth
PINDEX m_frameWidth
Definition: rfc4175.h:143
Opal_RFC4175RGB_to_RGB24::BytesToPixels
PINDEX BytesToPixels(PINDEX bytes) const
Definition: rfc4175.h:207
OpalRFC4175Transcoder::GetColsPerPgroup
virtual PINDEX GetColsPerPgroup() const =0
OpalRFC4175Encoder::m_maximumPacketSize
PINDEX m_maximumPacketSize
Definition: rfc4175.h:107
Opal_YUV420P_to_RFC4175YCbCr420::m_srcCrPlane
BYTE * m_srcCrPlane
Definition: rfc4175.h:192
OpalYUV420P
#define OpalYUV420P
Definition: vidcodec.h:61
OpalRFC4175Transcoder::GetRowsPerPgroup
virtual PINDEX GetRowsPerPgroup() const =0
OpalRFC4175Decoder::BytesToPixels
virtual PINDEX BytesToPixels(PINDEX pixels) const =0
Opal_YUV420P_to_RFC4175YCbCr420::GetRowsPerPgroup
PINDEX GetRowsPerPgroup() const
Definition: rfc4175.h:181
OpalRFC4175Transcoder::ScanLineHeader::m_y
PUInt16b m_y
Definition: rfc4175.h:79
OpalRFC4175Encoder::m_dstFrames
RTP_DataFrameList * m_dstFrames
Definition: rfc4175.h:113
OpalVideoFormat
Definition: mediafmt.h:1306
Opal_RGB24_to_RFC4175RGB::Opal_RGB24_to_RFC4175RGB
Opal_RGB24_to_RFC4175RGB()
Definition: rfc4175.h:216
OpalMediaFormatPair::outputMediaFormat
OpalMediaFormat outputMediaFormat
Definition: transcoders.h:108
OpalRFC4175Encoder::m_extendedSequenceNumber
DWORD m_extendedSequenceNumber
Definition: rfc4175.h:106
OpalRFC4175Decoder::OpalRFC4175Decoder
OpalRFC4175Decoder(const OpalMediaFormat &inputMediaFormat, const OpalMediaFormat &outputMediaFormat)
Opal_YUV420P_to_RFC4175YCbCr420
Definition: rfc4175.h:174
OpalRFC4175Decoder::m_missingPackets
bool m_missingPackets
Definition: rfc4175.h:146
Opal_RGB24_to_RFC4175RGB::StartEncoding
void StartEncoding(const RTP_DataFrame &input)
OpalRFC4175Encoder::FinishOutputFrame
void FinishOutputFrame()
OpalRFC4175Decoder::PixelsToBytes
virtual PINDEX PixelsToBytes(PINDEX pixels) const =0
OpalRFC4175Decoder::m_first
bool m_first
Definition: rfc4175.h:145
OpalVideoTranscoder
Definition: vidcodec.h:72