vector<cv::Point2f> roundedRectToPoints (cv::RotatedRect rr) { typedef cv::Point2f P; vector<P> ret; float px = rr.center.x; float py = rr.center.y; float ox = rr.size.width / 2; float oy = rr.size.height / 2; double rads = rr.angle * M_PI / 180; double vsin = sin (rads); double vcos = cos (rads); #define ROT(sx,sy) (P ( \ px + (sx) * ox * vcos - (sy) * oy * vsin, \ py + (sy) * oy * vcos + (sx) * ox * vsin \ )) ret.push_back (ROT (-1, -1)); ret.push_back (ROT (+1, -1)); ret.push_back (ROT (+1, +1)); ret.push_back (ROT (-1, +1)); #undef ROT return ret; }
ErrVal NalUnitParser::destroy() { ROT( m_bInitialized ); ROT( m_bNalUnitInitialized ); delete this; return Err::m_nOK; }
Int H264AVCEncoderTest::padBuf(UChar *output, Int iStrideOut, Int width, Int height, Int width_out, Int height_out, Int fillMode) { int j; UChar *pDst; enum FillMode { FILL_CLEAR = 0, FILL_FRAME, FILL_FIELD }; //horizontal; if(width < width_out) { pDst = output; for(j=0; j<height; j++) { memset(pDst+width, 0, (width_out-width)*sizeof(UChar)); pDst += iStrideOut; } } if(height < height_out) { if(FILL_CLEAR == fillMode) { pDst = output +height*iStrideOut; for(j=height; j<height_out; j++) { memset(pDst, 0, width_out*sizeof(UChar)); pDst += iStrideOut; } } else if(FILL_FRAME == fillMode ) { pDst = output +height*iStrideOut; for(j=height; j<height_out; j++) { memcpy(pDst, pDst-iStrideOut, iStrideOut*sizeof(UChar)); pDst += iStrideOut; } } else if(FILL_FIELD == fillMode) { ROT( (height_out - height) & 1 ); pDst = output +height*iStrideOut; for(j=height; j<height_out; j+=2) { memcpy(pDst, pDst-2*iStrideOut, 2*iStrideOut*sizeof(UChar)); pDst += iStrideOut*2; } } else ROT(!"Not supported yet!\n"); } return Err::m_nOK; }
uint32_t rand_prng_get(prng_t* p_prng) { /* Bob Jenkins' small PRNG http://burtleburtle.net/bob/rand/smallprng.html */ uint32_t e = p_prng->a - ROT(p_prng->b, 27); p_prng->a = p_prng->b ^ ROT(p_prng->c, 17); p_prng->b = p_prng->c + p_prng->d; p_prng->c = p_prng->d + e; p_prng->d = e + p_prng->a; return p_prng->d; }
ErrVal ControlData::initFGSData( UInt uiNumMb ) { ROT( m_pacFGSMbQP ); ROT( m_pauiFGSMbCbp ); ROT( m_pabFGS8x8Trafo ); ROFS( ( m_pacFGSMbQP = new UChar [uiNumMb] ) ); ROFS( ( m_pauiFGSMbCbp = new UInt [uiNumMb] ) ); ROFS( ( m_pabFGS8x8Trafo = new Bool [uiNumMb] ) ); return Err::m_nOK; }
ErrVal MbDataCtrl::initFgsBQData( UInt uiNumMb ) { ROT( m_pacFgsBQMbQP ); ROT( m_pauiFgsBQMbCbp ); ROT( m_pauiFgsBQBCBP ); ROT( m_pabFgsBQ8x8Trafo ); ROFS( ( m_pacFgsBQMbQP = new UChar [uiNumMb] ) ); ROFS( ( m_pauiFgsBQMbCbp = new UInt [uiNumMb] ) ); ROFS( ( m_pauiFgsBQBCBP = new UInt [uiNumMb] ) ); ROFS( ( m_pabFgsBQ8x8Trafo = new Bool [uiNumMb] ) ); return Err::m_nOK; }
ErrVal NalUnitParser::init( BitReadBuffer* pcBitReadBuffer, HeaderSymbolReadIf* pcHeaderSymbolReadIf ) { ROT( m_bInitialized ); ROT( m_bNalUnitInitialized ); ROF( pcBitReadBuffer ); ROF( pcHeaderSymbolReadIf ); m_bInitialized = true; m_bNalUnitInitialized = false; m_pcBitReadBuffer = pcBitReadBuffer; m_pcHeaderSymbolReadIf = pcHeaderSymbolReadIf; return Err::m_nOK; }
ErrVal MbDataCtrl::xCreateData( UInt uiSize ) { uiSize++; ROT( NULL == ( m_pcMbTCoeffs = new MbTransformCoeffs [ uiSize ] ) ); ROT( NULL == ( m_apcMbMotionData[0] = new MbMotionData [ uiSize ] ) ); ROT( NULL == ( m_apcMbMotionData[1] = new MbMotionData [ uiSize ] ) ); ROT( NULL == ( m_apcMbMotionDataBase[0] = new MbMotionData [ uiSize ] ) ); ROT( NULL == ( m_apcMbMotionDataBase[1] = new MbMotionData [ uiSize ] ) ); ROT( NULL == ( m_apcMbMvdData[0] = new MbMvData [ uiSize ] ) ); ROT( NULL == ( m_apcMbMvdData[1] = new MbMvData [ uiSize ] ) ); ROT( NULL == ( m_pcMbData = new MbData [ uiSize ] ) ); for( UInt uiIdx = 0; uiIdx < uiSize; uiIdx++ ) { m_pcMbData[ uiIdx ].init( m_pcMbTCoeffs + uiIdx, m_apcMbMvdData [0] + uiIdx, m_apcMbMvdData [1] + uiIdx, m_apcMbMotionData[0] + uiIdx, m_apcMbMotionData[1] + uiIdx, m_apcMbMotionDataBase[0] + uiIdx, m_apcMbMotionDataBase[1] + uiIdx ); } // clear outside mb data m_pcMbData[uiSize-1].getMbTCoeffs().setAllCoeffCount( 0 ); m_pcMbData[uiSize-1].initMbData( 0, MSYS_UINT_MAX ); return Err::m_nOK; }
static void splice(edge_ref a, edge_ref b) { edge_ref ta, tb; edge_ref alpha = ROT(ONEXT(a)); edge_ref beta = ROT(ONEXT(b)); ta = ONEXT(a); tb = ONEXT(b); ONEXT(a) = tb; ONEXT(b) = ta; ta = ONEXT(alpha); tb = ONEXT(beta); ONEXT(alpha) = tb; ONEXT(beta) = ta; }
ErrVal ControlData::initBQData( UInt uiNumMb ) { ROT( m_pacBQMbQP ); ROT( m_pauiBQMbCbp ); ROT( m_pabBQ8x8Trafo ); ROFS( ( m_pacBQMbQP = new UChar [uiNumMb] ) ); ROFS( ( m_pauiBQMbCbp = new UInt [uiNumMb] ) ); ROFS( ( m_pabBQ8x8Trafo = new Bool [uiNumMb] ) ); ROFS( ( m_paeBQMbMode = new MbMode[uiNumMb] ) ); ROFS( ( m_pusBQFwdBwd = new UShort[uiNumMb] ) ); ROFS( ( m_paacBQMotionData[0] = new MbMotionData[uiNumMb] ) ); ROFS( ( m_paacBQMotionData[1] = new MbMotionData[uiNumMb] ) ); return Err::m_nOK; }
ErrVal MotionEstimationCost::xInitRateDistortionModel( Int iSubPelSearchLimit, RateDistortionIf* pcRateDistortionIf ) { ROT( NULL == pcRateDistortionIf ) m_pcRateDistortionIf = pcRateDistortionIf; // make it larger iSubPelSearchLimit += 4; iSubPelSearchLimit *= 8; if( m_iSearchLimit != iSubPelSearchLimit ) { RNOK( xUninit() ) m_iSearchLimit = iSubPelSearchLimit; m_puiComponentCostOriginP = new UInt[ 4 * iSubPelSearchLimit ]; iSubPelSearchLimit *= 2; m_puiComponentCost = m_puiComponentCostOriginP + iSubPelSearchLimit; for( Int n = -iSubPelSearchLimit; n < iSubPelSearchLimit; n++) { m_puiComponentCost[n] = getComponentBits( n ); } } return Err::m_nOK; }
ErrVal NalUnitParser::create( NalUnitParser*& rpcNalUnitParser ) { rpcNalUnitParser = new NalUnitParser; ROT( NULL == rpcNalUnitParser ); return Err::m_nOK; }
ErrVal MbDataCtrl::init( const SequenceParameterSet& rcSPS ) { AOT_DBG( m_bInitDone ); UInt uiSize = rcSPS.getMbInFrame(); ROT( 0 == uiSize ); if( m_uiSize == uiSize ) { RNOK( xResetData() ); } else { RNOK( xDeleteData() ); RNOK( xCreateData( uiSize ) ); m_uiSize = uiSize; } m_iMbPerLine = rcSPS.getFrameWidthInMbs(); RNOK( m_cpDFPBuffer.init( uiSize+1 ) ); m_cpDFPBuffer.clear(); m_bInitDone = true; return Err::m_nOK; }
ErrVal BitReadBuffer::initPacket( UInt* puiBits, UInt uiBitsInPacket ) { // invalidate all members if something is wrong m_pulStreamPacket = NULL; m_ulCurrentBits = 0xdeaddead; m_uiNextBits = 0xdeaddead; m_uiBitsLeft = 0; m_iValidBits = 0; m_uiDWordsLeft = 0; ROT( NULL == puiBits ); // now init the Bitstream object m_pulStreamPacket = puiBits; m_uiBitsLeft = uiBitsInPacket; m_uiDWordsLeft = m_uiBitsLeft >> 5; m_iValidBits = -32; // preload first two dwords if valid xReadNextWord(); xReadNextWord(); return Err::m_nOK; }
ErrVal QualityLevelParameter::create( QualityLevelParameter*& rpcQualityLevelParameter ) { rpcQualityLevelParameter = new QualityLevelParameter; ROT( NULL == rpcQualityLevelParameter ); return Err::m_nOK; }
//----------------------------------------------------------------------------- // 説明: 関節回転量の設定(クォータニオン) // 引数: // frm [in] フレーム番号 // jid [in] 関節インデクス // q [in] 回転クォータニオン // 返り値: // true 設定成功 // false 設定失敗 // その他: //----------------------------------------------------------------------------- bool CMotionData::SetRotation(size_t frm, size_t jid, const Quaternionf &q) { if (!IsRange(frm, jid)) return false; ROT(frm, jid) = q; return true; }
ErrVal ReconstructionBypass::xPad8x8Blk_MbAff( YuvMbBufferExtension* pcBuffer, UInt ui8x8Blk, Bool bV0, Bool bV1, Bool bH, Bool bC0, Bool bC1 ) { Bool bSwitch = ( !bV0 && bV1 && bH ) || ( !bV0 && !bH && !bC0 && ( bV1 || bC1 ) ); Bool bDouble = ( bV0 && bV1 ) || ( ( bV0 || bC0 ) && !bH && ( bV1 || bC1 ) ); ROT( bSwitch && bDouble ); Bool bFromAbove = ( ui8x8Blk < 2 ); Bool bFromLeft = ( ui8x8Blk % 2 == 0 ); B8x8Idx cIdx( (Par8x8)ui8x8Blk ); if( bDouble ) { RNOK( xPadBlock_MbAff( pcBuffer, cIdx, bV0, bH, bC0, true, bFromAbove, bFromLeft ) ); RNOK( xPadBlock_MbAff( pcBuffer, cIdx, bV1, bH, bC1, true, !bFromAbove, bFromLeft ) ); } else if( bSwitch ) { RNOK( xPadBlock_MbAff( pcBuffer, cIdx, bV1, bH, bC1, false, !bFromAbove, bFromLeft ) ); } else { RNOK( xPadBlock_MbAff( pcBuffer, cIdx, bV0, bH, bC0, false, bFromAbove, bFromLeft ) ); } return Err::m_nOK; }
ErrVal PreProcessorParameter::create( PreProcessorParameter*& rpcPreProcessorParameter ) { rpcPreProcessorParameter = new PreProcessorParameter; ROT( NULL == rpcPreProcessorParameter ); return Err::m_nOK; }
ErrVal ControlMngH264AVCDecoder::create( ControlMngH264AVCDecoder*& rpcControlMngH264AVCDecoder ) { rpcControlMngH264AVCDecoder = new ControlMngH264AVCDecoder; ROT( NULL == rpcControlMngH264AVCDecoder ); return Err::m_nOK; }
ErrVal ReadYuvFile::readFrame( UChar *pLum, UChar *pCb, UChar *pCr, UInt uiBufHeight, UInt uiBufWidth, UInt uiBufStride) { //printf("Llegirem els tres plans de l'arxiu %s\n",m_cFileName); ROT( uiBufHeight < m_uiLumPicHeight || uiBufWidth < m_uiLumPicWidth ); UInt uiPicHeight = m_uiLumPicHeight; UInt uiPicWidth = m_uiLumPicWidth; UInt uiClearSize = uiBufWidth - uiPicWidth; UInt uiStartLine = m_uiStartLine; UInt uiEndLine = m_uiEndLine; RNOKS( xReadPlane( pLum, uiBufHeight, uiBufWidth, uiBufStride, uiPicHeight, uiPicWidth, uiStartLine, uiEndLine ) ); uiPicHeight >>= 1; uiPicWidth >>= 1; uiClearSize >>= 1; uiBufHeight >>= 1; uiBufWidth >>= 1; uiBufStride >>= 1; uiStartLine >>= 1; uiEndLine >>= 1; RNOKS( xReadPlane( pCb, uiBufHeight, uiBufWidth, uiBufStride, uiPicHeight, uiPicWidth, uiStartLine, uiEndLine ) ); RNOKS( xReadPlane( pCr, uiBufHeight, uiBufWidth, uiBufStride, uiPicHeight, uiPicWidth, uiStartLine, uiEndLine ) ); return Err::m_nOK; }
ErrVal PictureParameterSet::create( PictureParameterSet*& rpcPPS ) { rpcPPS = new PictureParameterSet; ROT( NULL == rpcPPS ); return Err::m_nOK; }
ErrVal PictureParameterSet::xReadFrext( HeaderSymbolReadIf* pcReadIf ) { const CommonMainH264* pcMainH264 = CommonMain::getMainH264(); ASSERT(pcMainH264 != NULL); const CommonElt* pcCurrent = pcMainH264->getEltCurrent(); const CommonSyntax* pcSyntax; const CommonControl* pcControlIf0 = pcCurrent->addControl("if" , "more_rbsp_data", pcReadIf->moreRBSPData()); ROTRS( ! pcReadIf->moreRBSPData(), Err::m_nOK ); pcSyntax = pcCurrent->addSyntax("transform_8x8_mode_flag", "u(1)"); RNOK ( pcReadIf->getFlag ( m_bTransform8x8ModeFlag, "PPS: transform_8x8_mode_flag" ) ); pcSyntax->setValue(m_bTransform8x8ModeFlag); pcSyntax = pcCurrent->addSyntax("pic_scaling_matrix_present_flag", "u(1)"); RNOK ( pcReadIf->getFlag ( m_bPicScalingMatrixPresentFlag, "PPS: pic_scaling_matrix_present_flag" ) ); pcSyntax->setValue(m_bPicScalingMatrixPresentFlag); const CommonControl* pcControlIf1 = pcCurrent->addControl("if" , "pic_scaling_matrix_present_flag", m_bPicScalingMatrixPresentFlag); if( m_bPicScalingMatrixPresentFlag ) { pcMainH264->setEltCurrent(pcControlIf1); RNOK( m_cPicScalingMatrix.read( pcReadIf, m_bTransform8x8ModeFlag ) ); pcMainH264->setEltCurrent(pcCurrent); } pcSyntax = pcCurrent->addSyntax("second_chroma_qp_index_offset", "se(v)"); RNOK ( pcReadIf->getSvlc ( m_iSecondChromaQpIndexOffset, "PPS: second_chroma_qp_index_offset" ) ); pcSyntax->setValue(m_iSecondChromaQpIndexOffset); ROT ( m_iSecondChromaQpIndexOffset < -12 || m_iSecondChromaQpIndexOffset > 12 ); return Err::m_nOK; }
ErrVal ReadYuvFile::readFrame( UChar *pLum, UChar *pCb, UChar *pCr, UInt uiBufHeight, UInt uiBufWidth, UInt uiBufStride) { ROT( uiBufHeight < m_uiLumPicHeight || uiBufWidth < m_uiLumPicWidth ); UInt uiPicHeight = m_uiLumPicHeight; UInt uiPicWidth = m_uiLumPicWidth; UInt uiClearSize = uiBufWidth - uiPicWidth; UInt uiStartLine = m_uiStartLine; UInt uiEndLine = m_uiEndLine; RNOKS( xReadPlane( pLum, uiBufHeight, uiBufWidth, uiBufStride, uiPicHeight, uiPicWidth, uiStartLine, uiEndLine ) ); uiPicHeight >>= 1; uiPicWidth >>= 1; uiClearSize >>= 1; uiBufHeight >>= 1; uiBufWidth >>= 1; uiBufStride >>= 1; uiStartLine >>= 1; uiEndLine >>= 1; RNOKS( xReadPlane( pCb, uiBufHeight, uiBufWidth, uiBufStride, uiPicHeight, uiPicWidth, uiStartLine, uiEndLine ) ); RNOKS( xReadPlane( pCr, uiBufHeight, uiBufWidth, uiBufStride, uiPicHeight, uiPicWidth, uiStartLine, uiEndLine ) ); return Err::m_nOK; }
ErrVal WriteBitstreamToFile::destroy() { ROT( m_cFile.is_open() ); RNOK( uninit() ); delete this; return Err::m_nOK; }
ErrVal RecPicBuffer::destroy() { ROT( m_bInitDone ); delete this; return Err::m_nOK; }
ErrVal MbCoder::create( MbCoder*& rpcMbCoder ) { rpcMbCoder = new MbCoder; ROT( NULL == rpcMbCoder ); return Err::m_nOK; }
ErrVal UvlcReader::create( UvlcReader*& rpcUvlcReader ) { rpcUvlcReader = new UvlcReader; ROT( NULL == rpcUvlcReader ); return Err::m_nOK; }
ErrVal CabaEncoder::init( BitWriteBufferIf* pcBitWriteBufferIf ) { ROT( NULL == pcBitWriteBufferIf ) m_pcBitWriteBufferIf = pcBitWriteBufferIf; return Err::m_nOK; }
ErrVal MbCoder::initSlice( const SliceHeader& rcSH, MbSymbolWriteIf* pcMbSymbolWriteIf, RateDistortionIf* pcRateDistortionIf ) { ROT( NULL == pcMbSymbolWriteIf ); ROT( NULL == pcRateDistortionIf ); m_pcMbSymbolWriteIf = pcMbSymbolWriteIf; m_pcRateDistortionIf = pcRateDistortionIf; m_bCabac = rcSH.getPPS().getEntropyCodingModeFlag(); m_bPrevIsSkipped = false; m_bInitDone = true; return Err::m_nOK; }
ErrVal RecPicBufUnit::markOutputted() { ROT( m_bOutputted ); m_bOutputted = true; m_pcPicBuffer = NULL; return Err::m_nOK; }