[Opalvoip-svn] SF.net SVN: opalvoip:[34707] opal/trunk
Brought to you by:
csoutheren,
rjongbloed
From: <rjo...@us...> - 2016-03-21 14:47:05
|
Revision: 34707 http://sourceforge.net/p/opalvoip/code/34707 Author: rjongbloed Date: 2016-03-21 14:47:03 +0000 (Mon, 21 Mar 2016) Log Message: ----------- Fixed "coding style" for PluginCodec_Video_FrameHeader size and ptr calculation functions. Modified Paths: -------------- opal/trunk/include/codec/opalplugin.h opal/trunk/samples/codectest/main.cxx opal/trunk/src/codec/opalpluginmgr.cxx opal/trunk/src/codec/rfc4175.cxx opal/trunk/src/ep/opalmixer.cxx opal/trunk/src/opal/mediastrm.cxx opal/trunk/src/opal/recording.cxx Modified: opal/trunk/include/codec/opalplugin.h =================================================================== --- opal/trunk/include/codec/opalplugin.h 2016-03-21 13:37:59 UTC (rev 34706) +++ opal/trunk/include/codec/opalplugin.h 2016-03-21 14:47:03 UTC (rev 34707) @@ -428,7 +428,18 @@ #define PLUGINCODEC_SQCIF_WIDTH 128 #define PLUGINCODEC_SQCIF_HEIGHT 96 +#ifdef __cplusplus +}; +inline size_t OpalDataSizeYUV420P(unsigned width, unsigned height) +{ + return ((width+1)&~1) * ((height+1)&~1) * 3 / 2; +} + +extern "C" { +#endif + + #ifndef __TIMESTAMP__ #define __TIMESTAMP__ "0" #endif @@ -914,12 +925,25 @@ #ifdef __cplusplus }; -inline size_t OPAL_VIDEO_FRAME_DATA_SIZE(const PluginCodec_Video_FrameHeader * base) -{ return ((base->width-base->x+1)&~1) * ((base->height-base->y+1)&~1) + sizeof(PluginCodec_Video_FrameHeader); } +inline size_t OpalVideoFrameSizeForResolution(unsigned width, unsigned height) +{ + return sizeof(PluginCodec_Video_FrameHeader) + OpalDataSizeYUV420P(width, height); +} -inline unsigned char * OPAL_VIDEO_FRAME_DATA_PTR(const PluginCodec_Video_FrameHeader * base) -{ return (((unsigned char *)base) + sizeof(PluginCodec_Video_FrameHeader)); } +inline size_t OpalVideoFrameDataLen(const PluginCodec_Video_FrameHeader * base) +{ + return OpalVideoFrameSizeForResolution(base->width - base->x, base->height - base->y); +} +inline unsigned char * OpalVideoFrameDataPtr(const PluginCodec_Video_FrameHeader * base) +{ + return (((unsigned char *)base) + sizeof(PluginCodec_Video_FrameHeader)); +} + +// For backward compatibility +inline unsigned char * OPAL_VIDEO_FRAME_DATA_PTR1(const PluginCodec_Video_FrameHeader * base) +{ return OpalVideoFrameDataPtr(base); } + extern "C" { #endif Modified: opal/trunk/samples/codectest/main.cxx =================================================================== --- opal/trunk/samples/codectest/main.cxx 2016-03-21 13:37:59 UTC (rev 34706) +++ opal/trunk/samples/codectest/main.cxx 2016-03-21 14:47:03 UTC (rev 34707) @@ -1278,9 +1278,9 @@ frame->x = frame->y = 0; frame->width = width; frame->height = height; - data.SetPayloadSize(OPAL_VIDEO_FRAME_DATA_SIZE(frame)); + data.SetPayloadSize(OpalVideoFrameDataLen(frame)); - return m_grabber->GetFrameData(OPAL_VIDEO_FRAME_DATA_PTR(frame)); + return m_grabber->GetFrameData(OpalVideoFrameDataPtr(frame)); } @@ -1292,8 +1292,8 @@ const OpalVideoTranscoder::FrameHeader * frame = (const OpalVideoTranscoder::FrameHeader *)data.GetPayloadPtr(); m_display->SetFrameSize(frame->width, frame->height); return m_display->SetFrameData(frame->x, frame->y, - frame->width, frame->height, - OPAL_VIDEO_FRAME_DATA_PTR(frame), data.GetMarker()); + frame->width, frame->height, + OpalVideoFrameDataPtr(frame), data.GetMarker()); } Modified: opal/trunk/src/codec/opalpluginmgr.cxx =================================================================== --- opal/trunk/src/codec/opalpluginmgr.cxx 2016-03-21 13:37:59 UTC (rev 34706) +++ opal/trunk/src/codec/opalpluginmgr.cxx 2016-03-21 14:47:03 UTC (rev 34707) @@ -1192,7 +1192,7 @@ return false; } - if (payloadSize < OPAL_VIDEO_FRAME_DATA_SIZE(videoHeader)) { + if (payloadSize < OpalVideoFrameDataLen(videoHeader)) { PTRACE(1, "OpalPlugin\tInvalid video frame size, error in plug in\n" << *m_bufferRTP); return false; } Modified: opal/trunk/src/codec/rfc4175.cxx =================================================================== --- opal/trunk/src/codec/rfc4175.cxx 2016-03-21 13:37:59 UTC (rev 34706) +++ opal/trunk/src/codec/rfc4175.cxx 2016-03-21 14:47:03 UTC (rev 34707) @@ -533,7 +533,7 @@ hdr->width = m_frameWidth; hdr->height = m_frameHeight; - BYTE * payload = OPAL_VIDEO_FRAME_DATA_PTR(hdr); + BYTE * payload = OpalVideoFrameDataPtr(hdr); BYTE * dstYPlane = payload; BYTE * dstCbPlane = dstYPlane + (m_frameWidth * m_frameHeight); BYTE * dstCrPlane = dstCbPlane + (m_frameWidth * m_frameHeight / 4); @@ -646,7 +646,7 @@ hdr->width = m_frameWidth; hdr->height = m_frameHeight; - BYTE * rgbDest = OPAL_VIDEO_FRAME_DATA_PTR(hdr); + BYTE * rgbDest = OpalVideoFrameDataPtr(hdr); // pass through all of the input frames, and extract information PINDEX f = 0; Modified: opal/trunk/src/ep/opalmixer.cxx =================================================================== --- opal/trunk/src/ep/opalmixer.cxx 2016-03-21 13:37:59 UTC (rev 34706) +++ opal/trunk/src/ep/opalmixer.cxx 2016-03-21 14:47:03 UTC (rev 34707) @@ -600,7 +600,7 @@ PluginCodec_Video_FrameHeader * video = (PluginCodec_Video_FrameHeader *)frame.GetPayloadPtr(); video->width = m_width; video->height = m_height; - memcpy(OPAL_VIDEO_FRAME_DATA_PTR(video), m_frameStore, m_frameStore.GetSize()); + memcpy(OpalVideoFrameDataPtr(video), m_frameStore, m_frameStore.GetSize()); return true; } @@ -758,7 +758,7 @@ << " -> " << x << ',' << y << '/' << w << 'x' << h); PColourConverter::CopyYUV420P(0, 0, header->width, header->height, - header->width, header->height, OPAL_VIDEO_FRAME_DATA_PTR(header), + header->width, header->height, OpalVideoFrameDataPtr(header), x, y, w, h, m_mixer.m_width, m_mixer.m_height, m_mixer.m_frameStore.GetPointer(), PVideoFrameInfo::eScale); @@ -1987,9 +1987,9 @@ resized->width = width; resized->height = height; PColourConverter::CopyYUV420P(0, 0, header->width, header->height, - header->width, header->height, OPAL_VIDEO_FRAME_DATA_PTR(header), + header->width, header->height, OpalVideoFrameDataPtr(header), 0, 0, width, height, - width, height, OPAL_VIDEO_FRAME_DATA_PTR(resized), + width, height, OpalVideoFrameDataPtr(resized), PVideoFrameInfo::eScale); } } Modified: opal/trunk/src/opal/mediastrm.cxx =================================================================== --- opal/trunk/src/opal/mediastrm.cxx 2016-03-21 13:37:59 UTC (rev 34706) +++ opal/trunk/src/opal/mediastrm.cxx 2016-03-21 14:47:03 UTC (rev 34707) @@ -1339,7 +1339,7 @@ bool keyFrame = m_needKeyFrame; PINDEX bytesReturned = size - sizeof(OpalVideoTranscoder::FrameHeader); - BYTE * frameData = OPAL_VIDEO_FRAME_DATA_PTR(frame); + BYTE * frameData = OpalVideoFrameDataPtr(frame); if (!m_inputDevice->GetFrameData(frameData, &bytesReturned, keyFrame)) { PTRACE(2, "Failed to grab frame from " << m_inputDevice->GetDeviceName()); return false; @@ -1406,7 +1406,7 @@ return false; } - ApplyWatermark(frame->width, frame->height, OPAL_VIDEO_FRAME_DATA_PTR(frame)); + ApplyWatermark(frame->width, frame->height, OpalVideoFrameDataPtr(frame)); if (!m_outputDevice->Start()) { PTRACE(1, "Could not start video display device"); @@ -1416,7 +1416,7 @@ bool keyFrameNeeded = false; if (!m_outputDevice->SetFrameData(frame->x, frame->y, frame->width, frame->height, - OPAL_VIDEO_FRAME_DATA_PTR(frame), + OpalVideoFrameDataPtr(frame), marker, keyFrameNeeded)) return false; Modified: opal/trunk/src/opal/recording.cxx =================================================================== --- opal/trunk/src/opal/recording.cxx 2016-03-21 13:37:59 UTC (rev 34706) +++ opal/trunk/src/opal/recording.cxx 2016-03-21 14:47:03 UTC (rev 34707) @@ -690,7 +690,7 @@ } PINDEX bytesReturned = PVideoFrameInfo::CalculateFrameBytes(m_options.m_videoWidth, m_options.m_videoHeight); - if (m_videoConverter != NULL && !m_videoConverter->Convert(OPAL_VIDEO_FRAME_DATA_PTR(header), m_videoBuffer.GetPointer(), &bytesReturned)) { + if (m_videoConverter != NULL && !m_videoConverter->Convert(OpalVideoFrameDataPtr(header), m_videoBuffer.GetPointer(), &bytesReturned)) { PTRACE(2, "Conversion of YUV420P to RGB24 failed!"); return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |