//C.5.2.2 bool VaapiDecoderH265::DPB::init(const PicturePtr& picture, const H265SliceHdr *const slice, const H265NalUnit *const nalu, bool newStream) { forEach(markUnusedReference); if (!initReference(picture, slice, nalu, newStream)) return false; if (isIrap(nalu) && picture->m_noRaslOutputFlag && !newStream) { bool noOutputOfPriorPicsFlag; //TODO how to check C.5.2.2 item 1's second otherwise if (isCra(nalu)) noOutputOfPriorPicsFlag = true; else noOutputOfPriorPicsFlag = slice->no_output_of_prior_pics_flag; clearRefSet(); if (!noOutputOfPriorPicsFlag) { removeUnused(); bumpAll(); } m_pictures.clear(); return true; } removeUnused(); const H265PPS* const pps = slice->pps; const H265SPS* const sps = pps->sps; while (checkReorderPics(sps) || checkLatency(sps) || checkDpbSize(sps)) bump(); return true; }
void Input::serve(){ char userPageName[NAME_BUFFER_SIZE]; snprintf(userPageName, NAME_BUFFER_SIZE, SHM_USERS, streamName.c_str()); userPage.init(userPageName, PLAY_EX_SIZE, true); if (!isBuffer){ for (std::map<unsigned int,DTSC::Track>::iterator it = myMeta.tracks.begin(); it != myMeta.tracks.end(); it++){ bufferFrame(it->first, 1); } } DEBUG_MSG(DLVL_DEVEL,"Input for stream %s started", streamName.c_str()); long long int activityCounter = Util::bootSecs(); while ((Util::bootSecs() - activityCounter) < 10 && config->is_active){//10 second timeout Util::wait(1000); removeUnused(); userPage.parseEach(callbackWrapper); if (userPage.amount){ activityCounter = Util::bootSecs(); DEBUG_MSG(DLVL_INSANE, "Connected users: %d", userPage.amount); }else{ DEBUG_MSG(DLVL_INSANE, "Timer running"); } } finish(); DEBUG_MSG(DLVL_DEVEL,"Input for stream %s closing clean", streamName.c_str()); //end player functionality }
void Index::createBase() { for (std::vector<std::string>::size_type i = 0; i < directories_.size(); ++i) { processDirectory(directories_.at(i), std::string()); } removeUnused(); }
void Input::finish(){ for( std::map<unsigned int, std::map<unsigned int, unsigned int> >::iterator it = pageCounter.begin(); it != pageCounter.end(); it++){ for (std::map<unsigned int, unsigned int>::iterator it2 = it->second.begin(); it2 != it->second.end(); it2++){ it2->second = 1; } } removeUnused(); if (standAlone){ for (std::map<unsigned long, IPC::sharedPage>::iterator it = metaPages.begin(); it != metaPages.end(); it++){ it->second.master = true; } } }
bool BBLSGraph::simplify() { int numProcesses; MPI_Comm_size(MCW, &numProcesses); MPI_Status status; Command command; int numWorking = 0; bool continueSimplifying = true; bool anySimplified = false; bool shutdownProcesses = false; BBLSNode node; map<unsigned int, BBLSNode*>::iterator itr; double startTime = MPI_Wtime(); int originalEntries = gateMap.size(); do { itr = gateMap.begin(); continueSimplifying = removeDuplicates(); do { MPI_Recv(&command, 1, MPI_ENUM, MPI_ANY_SOURCE, MPI_ANY_TAG, MCW, &status); if(status.MPI_ERROR == 0) { int source = status.MPI_SOURCE; int tag = status.MPI_TAG; if(command == REQUEST_DATA) { if(shutdownProcesses) { itr = gateMap.end(); sendMessage(END_PROCESS, 0, source); numProcesses--; } else if(itr == gateMap.end()) { sendMessage(NO_DATA, 0, source); } else { node.output = itr->second->output; node.type = itr->second->type; node.inputLeft = itr->second->inputLeft; node.inputRight = itr->second->inputRight; sendMessage(DATA, 1, source); MPI_Send(&node, 1, mpi_nodeType, source, 1, MCW); if(node.type != ConstantWire && node.type != VariableWire) { MPI_Send(gateMap[node.inputLeft], 1, mpi_nodeType, source, 1, MCW); if(node.type != NotGate) { MPI_Send(gateMap[node.inputRight], 1, mpi_nodeType, source, 1, MCW); } } numWorking++; itr++; } } else if(command == RESULT) { if(tag == UPDATE_NODE) { MPI_Recv(&node, 1, mpi_nodeType, source, MPI_ANY_TAG, MCW, &status); if(status.MPI_ERROR == 0) { continueSimplifying |= updateNode(node.output, node.type, node.inputLeft, node.inputRight); } numWorking--; } else if(tag == REPLACE_INPUTS) { unsigned int oldInput, newInput; MPI_Recv(&oldInput, 1, MPI_UNSIGNED, source, MPI_ANY_TAG, MCW, &status); MPI_Recv(&newInput, 1, MPI_UNSIGNED, source, MPI_ANY_TAG, MCW, &status); continueSimplifying |= replaceInputs(oldInput, newInput); numWorking--; } else if (tag == NOCHANGE) { numWorking--; } } } } while(itr != gateMap.end() || numWorking > 0); continueSimplifying |= removeUnused(); anySimplified |= continueSimplifying; if(!continueSimplifying) { shutdownProcesses = true; } } while(numProcesses > 1); double endTime = MPI_Wtime(); std::cout << "We went from " << originalEntries << " to " << gateMap.size() << " in " << endTime - startTime << std::endl; return anySimplified; }
int main(int argc, char* argv[]) { if (argc != 5) { cout << "\t./p5exe N K A directory\n"; exit(1); } // Data structures hash_map<string, int> wordMap; hash_map<string, int> index; vector <pair<string, vector<bool> > > bitVectors; vector<pair<int, pair<string,string> > > clust; vector<string> files; vector<vector<string> > clusters; vector<vector<int> > matrix(26, vector<int> (26, 0)); int numElts = 0, algorithm = atoi(argv[3]); // Read files in directory and create bitVectors readDir(atoi(argv[1]), argv[4], wordMap, numElts, bitVectors); removeUnused(numElts, bitVectors); // Print similarity matrix simMatrix(numElts, bitVectors, clust, index, matrix, files); greedy(atoi(argv[2]), bitVectors, clust, index, matrix, clusters); if (algorithm == 2) { simulatedAnnealing(clusters, matrix, index); } if (algorithm == 3) // i don't consider if the solution returns less than/greater than k clusters { vector<int> diameters; int maxDiam = 0; for (int i = 0; i < clusters.size(); i++) { int diam = 0; for (int j = 0; j < clusters.at(i).size(); j++) { for (int k = j; k < clusters.at(i).size(); k++) { hash_map <string, int>::iterator It1 = index.find(clusters.at(i).at(j)); hash_map <string, int>::iterator It2 = index.find(clusters.at(i).at(k)); int tmpDist = matrix.at(It1 -> second).at(It2 -> second); if (tmpDist > diam) { diam = tmpDist; } } } diameters.push_back(diam); if (diam > maxDiam) { maxDiam = diam; } } vector<vector<string> > empty; int curDiam = 0; branchAndBound(files, clusters, empty, maxDiam, curDiam, matrix, index, atoi(argv[2])); } sortClustering(clusters); printClusteredMatrix(clusters, matrix, index); return 0; }