nsresult VorbisState::PageIn(ogg_page* aPage) { if (!mActive) return NS_OK; NS_ASSERTION(static_cast<uint32_t>(ogg_page_serialno(aPage)) == mSerial, "Page must be for this stream!"); if (ogg_stream_pagein(&mState, aPage) == -1) return NS_ERROR_FAILURE; bool foundGp; nsresult res = PacketOutUntilGranulepos(foundGp); if (NS_FAILED(res)) return res; if (foundGp && mDoneReadingHeaders) { // We've found a packet with a granulepos, and we've loaded our metadata // and initialized our decoder. Determine granulepos of buffered packets. ReconstructVorbisGranulepos(); for (uint32_t i = 0; i < mUnstamped.Length(); ++i) { ogg_packet* packet = mUnstamped[i]; AssertHasRecordedPacketSamples(packet); NS_ASSERTION(!IsHeader(packet), "Don't try to recover header packet gp"); NS_ASSERTION(packet->granulepos != -1, "Packet must have gp by now"); mPackets.Append(packet); } mUnstamped.Clear(); } return NS_OK; }
nsresult OggCodecState::PacketOutUntilGranulepos(bool& aFoundGranulepos) { int r; aFoundGranulepos = false; // Extract packets from the sync state until either no more packets // come out, or we get a data packet with non -1 granulepos. do { ogg_packet packet; r = ogg_stream_packetout(&mState, &packet); if (r == 1) { ogg_packet* clone = Clone(&packet); if (IsHeader(&packet)) { // Header packets go straight into the packet queue. mPackets.Append(clone); } else { // We buffer data packets until we encounter a granulepos. We'll // then use the granulepos to figure out the granulepos of the // preceeding packets. mUnstamped.AppendElement(clone); aFoundGranulepos = packet.granulepos > 0; } } } while (r != 0 && !aFoundGranulepos); if (ogg_stream_check(&mState)) { NS_WARNING("Unrecoverable error in ogg_stream_packetout"); return NS_ERROR_FAILURE; } return NS_OK; }
/* * Parses autopilot info message (page 0) */ bool tCanKingProtocol::AutopilotInfo( const quint8* pData, quint8& mode, quint8& autopilotRespLevel, quint8& stationKeepRespLevel, quint8& standbyRespLevel ) { if( IsHeader( pData ) ) { mode = pData[ 1 ]; autopilotRespLevel = pData[ 2 ]; stationKeepRespLevel = pData[ 3 ]; standbyRespLevel = pData[ 4 ]; return true; } return false; }
// --------------------------------------------------------- // CMailToHandler::FieldStart() // --------------------------------------------------------- // TInt CMailToHandler::FieldStart(const TDesC& aHeader) { CLOG_ENTERFN( "CMailToHandler::FieldStart()" ); TPtrC path = iParsedUrl->Des(); TInt retVal = path.Length(); /* find the starting position of the specific filed */ if( IsHeader( aHeader ) ) { retVal = path.FindF( aHeader ) + aHeader.Length(); } CLOG_LEAVEFN( "CMailToHandler::FieldStart()" ); return retVal; }
// --------------------------------------------------------- // CMailToHandler::FieldEnd() // --------------------------------------------------------- // TInt CMailToHandler::FieldEnd(const TDesC& aHeader) { CLOG_ENTERFN( "CMailToHandler::FieldEnd()" ); TPtrC path = iParsedUrl->Des(); TInt length = path.Length(); // length of the scheme TInt retVal = length; TInt startPos = FieldStart( aHeader ); if( IsHeader( aHeader ) ) { TInt temp = GetNextField( startPos ); /* we need to subtract 1 if the result is not equal to length because of the & or ? */ retVal = ( temp == length ) ? length : ( temp - 1); } CLOG_LEAVEFN( "CMailToHandler::FieldEnd()" ); return retVal; }
nsresult OpusState::PageIn(ogg_page* aPage) { if (!mActive) return NS_OK; NS_ASSERTION(static_cast<uint32_t>(ogg_page_serialno(aPage)) == mSerial, "Page must be for this stream!"); if (ogg_stream_pagein(&mState, aPage) == -1) return NS_ERROR_FAILURE; bool haveGranulepos; nsresult rv = PacketOutUntilGranulepos(haveGranulepos); if (NS_FAILED(rv) || !haveGranulepos || mPacketCount < 2) return rv; if(!ReconstructOpusGranulepos()) return NS_ERROR_FAILURE; for (uint32_t i = 0; i < mUnstamped.Length(); i++) { ogg_packet* packet = mUnstamped[i]; NS_ASSERTION(!IsHeader(packet), "Don't try to play a header packet"); NS_ASSERTION(packet->granulepos != -1, "Packet should have a granulepos"); mPackets.Append(packet); } mUnstamped.Clear(); return NS_OK; }
bool c4_FileMark::IsOldHeader()const { return IsHeader() && _data[3] == 0x80; }
bool BlockMergePass::MergeBlocks(Function* func) { bool modified = false; for (auto bi = func->begin(); bi != func->end();) { // Find block with single successor which has no other predecessors. auto ii = bi->end(); --ii; Instruction* br = &*ii; if (br->opcode() != SpvOpBranch) { ++bi; continue; } const uint32_t lab_id = br->GetSingleWordInOperand(0); if (cfg()->preds(lab_id).size() != 1) { ++bi; continue; } bool pred_is_merge = IsMerge(&*bi); bool succ_is_merge = IsMerge(lab_id); if (pred_is_merge && succ_is_merge) { // Cannot merge two merges together. ++bi; continue; } Instruction* merge_inst = bi->GetMergeInst(); bool pred_is_header = IsHeader(&*bi); if (pred_is_header && lab_id != merge_inst->GetSingleWordInOperand(0u)) { bool succ_is_header = IsHeader(lab_id); if (pred_is_header && succ_is_header) { // Cannot merge two headers together when the successor is not the merge // block of the predecessor. ++bi; continue; } // If this is a header block and the successor is not its merge, we must // be careful about which blocks we are willing to merge together. // OpLoopMerge must be followed by a conditional or unconditional branch. // The merge must be a loop merge because a selection merge cannot be // followed by an unconditional branch. BasicBlock* succ_block = context()->get_instr_block(lab_id); SpvOp succ_term_op = succ_block->terminator()->opcode(); assert(merge_inst->opcode() == SpvOpLoopMerge); if (succ_term_op != SpvOpBranch && succ_term_op != SpvOpBranchConditional) { ++bi; continue; } } // Merge blocks. context()->KillInst(br); auto sbi = bi; for (; sbi != func->end(); ++sbi) if (sbi->id() == lab_id) break; // If bi is sbi's only predecessor, it dominates sbi and thus // sbi must follow bi in func's ordering. assert(sbi != func->end()); // Update the inst-to-block mapping for the instructions in sbi. for (auto& inst : *sbi) { context()->set_instr_block(&inst, &*bi); } // Now actually move the instructions. bi->AddInstructions(&*sbi); if (merge_inst) { if (pred_is_header && lab_id == merge_inst->GetSingleWordInOperand(0u)) { // Merging the header and merge blocks, so remove the structured control // flow declaration. context()->KillInst(merge_inst); } else { // Move the merge instruction to just before the terminator. merge_inst->InsertBefore(bi->terminator()); } } context()->ReplaceAllUsesWith(lab_id, bi->id()); context()->KillInst(sbi->GetLabelInst()); (void)sbi.Erase(); // Reprocess block. modified = true; } return modified; }
bool BlockMergePass::IsHeader(uint32_t id) { return IsHeader(context()->get_instr_block(get_def_use_mgr()->GetDef(id))); }