/*----------------------------------------------------------------------------*/ void Extractor::exec(std::istream &bitstream) { Decoder::State decoder{PictureOutput::Disabled}; CmdQueue cmdQueue; SNUQueue snuQueue; SNUQueue cvs; size_t cvsSizeInBytes = 0; while(!bitstream.eof()) { const auto p = bitstream.tellg(); auto snuPayload = parse(bitstream); /* parse only */ { /* use "const L-value &" as payload (no ownership transfer) */ snuQueue.push(makeHandle<SNU>(snuPayload)); decoder.exec(CmdId::ParseSNU, snuQueue); } const NalUnitType nut = *toNalUnit(*decoder.snu).getSubtree<NUH>()->get<NUH::NalUnitType>(); /* release all resources consumed by decoder while parsing current SNU */ destruct(decoder.snu); if(isIDR(nut) || isBLA(nut) || isCRA(nut)) { std::unique_lock<std::mutex> lock(m_mutex); m_queue.push({cvsSizeInBytes, std::move(cvs)}); m_queueSizeInBytes += cvsSizeInBytes; cvsSizeInBytes = 0; m_popCond.notify_one(); if(State::StopReq == m_state) { bitstream.seekg(p); break; } while(m_queueSizeInBytes > m_queueMaxSizeInBytes) { m_pushCond.wait(lock); } } cvsSizeInBytes += snuPayload.size(); /* use "R-value &" as payload (ownership transfer) */ cvs.push(makeHandle<SNU>(std::move(snuPayload))); } { std::unique_lock<std::mutex> lock(m_mutex); m_state = State::Stopped; m_popCond.notify_one(); } }
bool isRAP(uint8_t unit_type) { return isIDR(unit_type) || isBLA(unit_type) || isCRA(unit_type); }