📄 processorhandler.cc
字号:
//// Copyright (c) 2003 by Istv醤 V醨adi//// This file is part of dxr3Player, a DVD player written specifically // for the DXR3 (aka Hollywood+) decoder card.// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA//------------------------------------------------------------------------------#include "ProcessorHandler.h"#include "dvd/vm/ProcessorCommandQueue.h"#include "dvd/vm/SetSectorProcessorCommand.h"#include "dvd/vm/HighlightButtonProcessorCommand.h"#include "dvd/vm/TargetPosition.h"#include "dvd/demux/DemultiplexerParameters.h"#include "output/AVAttributes.h"#include "util/Config.h"//------------------------------------------------------------------------------using dvd::reader::ProcessorHandler;using dvd::demux::DemultiplexerParameters;using dvd::vm::ProcessorCommandQueue;using dvd::vm::ProcessorCommand;using dvd::vm::SimpleProcessorCommand;using dvd::vm::SetSectorProcessorCommand;using dvd::vm::HighlightButtonProcessorCommand;using dvd::vm::Position;using dvd::vm::State;using dvd::vm::SPRM;using output::AVAttributes;//------------------------------------------------------------------------------ProcessorHandler::ProcessorHandler(ProcessorCommandQueue& commandQueue, dvd::DVD* dvd) : processor(dvd), commandQueue(commandQueue), lastCommandID(ProcessorCommand::INVALID_ID){} //------------------------------------------------------------------------------void ProcessorHandler::reset(){ commandQueue.reset(); lastCommandID = ProcessorCommand::INVALID_ID;}//------------------------------------------------------------------------------size_t ProcessorHandler::getLastCommandID(){ size_t id = lastCommandID; lastCommandID = ProcessorCommand::INVALID_ID; return id;}//------------------------------------------------------------------------------void ProcessorHandler::getStreamAttributes(AVAttributes& attributes) const{ const Position& position = getPosition(); const IFO* ifo = position.findIFO(); if (ifo!=0) { unsigned audioStreamNumber = processor.getSPRM().getASTN(); unsigned numAudioStreams = ifo->getNumberOfAudioStreams(position.isInMenu()); if (audioStreamNumber<numAudioStreams) { AudioStreamAttributes attrs = ifo->getAudioStreamAttributes(position.isInMenu(), audioStreamNumber); attrs.set(attributes.audio); } VideoStreamAttributes attrs = ifo->getVideoStreamAttributes(position.isInMenu()); attrs.set(attributes.video); } }//------------------------------------------------------------------------------void ProcessorHandler::getSPUPalette(palette_t palette) const{ getPosition().getPGC().getSPUPalette(palette);}//------------------------------------------------------------------------------void ProcessorHandler::getDemultiplexerParameters(DemultiplexerParameters& parameters) const{ parameters.audioStreamNumber = 0; parameters.spuStreamNumber = 0; const Position& position = getPosition(); const IFO* ifo = position.findIFO(); if (ifo==0) return; parameters.audioStreamNumber = processor.getAudioStreamNumber(); bool isInMenu = position.isInMenu(); VideoStreamAttributes videoStreamAttributes = ifo->getVideoStreamAttributes(isInMenu); aspectRatio_t aspectRatio = videoStreamAttributes.getDisplayAspectRatio(); parameters.displayFormat = Config::get().forcedDisplayFormat; if (parameters.displayFormat==DF_NONE) parameters.displayFormat = videoStreamAttributes.getDisplayFormat(); // FIXME: for different HW we may need to be more intelligent with // the display mode selection parameters.spuStreamNumber = processor.getSPUStreamNumber(aspectRatio, parameters.displayFormat, parameters.spuForcedOnly);}//------------------------------------------------------------------------------void ProcessorHandler::resetProcessor(){ processor.reset(); processor.executeFirstPlayPGC(); enqueueCommand(SimpleProcessorCommand::RESET);}//------------------------------------------------------------------------------void ProcessorHandler::setState(const dvd::vm::State& state){ processor.setState(state);}//------------------------------------------------------------------------------void ProcessorHandler::branch(const State& state){ setState(state); enqueueCommand(SimpleProcessorCommand::SET_STATE);}//------------------------------------------------------------------------------void ProcessorHandler::setSectorNumber(size_t sectorNo){ processor.setSectorNumber(sectorNo); enqueueCommand(new SetSectorProcessorCommand(sectorNo, getState()));}//------------------------------------------------------------------------------void ProcessorHandler::setHighlightedButtonNumber(size_t buttonNo){ processor.setHighlightedButtonNumber(buttonNo); enqueueCommand(new HighlightButtonProcessorCommand(buttonNo, getState()));}//------------------------------------------------------------------------------// static size_t cellCount = 1;bool ProcessorHandler::nextCell(unsigned& stillTime){ bool hadCell = processor.nextCell(stillTime);// This can be used to simulate an EXIT instruction after a certain// number of cells.// if ((--cellCount)==0) {// dvd::vm::State state(processor.getState());// dvd::vm::TargetPosition targetPosition(state.getPosition());// targetPosition.exit();// state.setPosition(targetPosition); // processor.setState(state);// } enqueueCommand(SimpleProcessorCommand::NEXT_CELL); return hadCell;}//------------------------------------------------------------------------------bool ProcessorHandler::previousCell(){ bool hadCell = processor.previousCell(); enqueueCommand(SimpleProcessorCommand::PREVIOUS_CELL); return hadCell;}//------------------------------------------------------------------------------void ProcessorHandler::enqueueCommand(SimpleProcessorCommand::command_t cmd){ enqueueCommand(new SimpleProcessorCommand(cmd, getState()));}//------------------------------------------------------------------------------void ProcessorHandler::enqueueCommand(ProcessorCommand* command){ assert(lastCommandID==ProcessorCommand::INVALID_ID); commandQueue.put(command); lastCommandID = command->getID();}//------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -